This commit is contained in:
2024-02-22 14:52:53 -05:00
parent 72c94666c5
commit 29b417e3f7
445 changed files with 360852 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
namespace MarketData.Integration
{
public class NetworkStatus
{
private NetworkStatus()
{
}
/// <summary>
/// Indicates whether any network connection is available
/// Filter connections below a specified speed, as well as virtual network cards.
/// </summary>
/// <returns>
/// <c>true</c> if a network connection is available; otherwise, <c>false</c>.
/// </returns>
public static bool IsNetworkAvailable()
{
return IsNetworkAvailable(0);
}
public static bool IsInternetConnected()
{
try
{
Ping myPing = new Ping();
String host = "google.com";
byte[] buffer = new byte[32];
int timeout = 1000;
PingOptions pingOptions = new PingOptions();
PingReply reply = myPing.Send(host, timeout, buffer, pingOptions);
if (reply.Status == IPStatus.Success)
{
return true;
}
else if (reply.Status == IPStatus.TimedOut)
{
return true;
}
else
{
return false;
}
}
catch (Exception)
{
return false;
}
}
/// <summary>
/// Indicates whether any network connection is available.
/// Filter connections below a specified speed, as well as virtual network cards.
/// </summary>
/// <param name="minimumSpeed">The minimum speed required. Passing 0 will not filter connection using speed.</param>
/// <returns>
/// <c>true</c> if a network connection is available; otherwise, <c>false</c>.
/// </returns>
public static bool IsNetworkAvailable(long minimumSpeed)
{
if (!NetworkInterface.GetIsNetworkAvailable())
return false;
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
// discard because of standard reasons
if ((ni.OperationalStatus != OperationalStatus.Up) ||
(ni.NetworkInterfaceType == NetworkInterfaceType.Loopback) ||
(ni.NetworkInterfaceType == NetworkInterfaceType.Tunnel))
continue;
// this allow to filter modems, serial, etc.
// I use 10000000 as a minimum speed for most cases
if (ni.Speed < minimumSpeed)
continue;
// discard virtual cards (virtual box, virtual pc, etc.)
if ((ni.Description.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0) ||
(ni.Name.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0))
continue;
// discard "Microsoft Loopback Adapter", it will not show as NetworkInterfaceType.Loopback but as Ethernet Card.
if (ni.Description.Equals("Microsoft Loopback Adapter", StringComparison.OrdinalIgnoreCase))
continue;
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace MarketData.Integration
{
public class SMSClient
{
private SMSClient()
{
}
// <add key="sms_smtpaddress" value="smtp.gmail.com"/>
// <add key="sms_smsusername" value="skessler1964@gmail.com"/>
// <add key="sms_smspassword" value="hebo cfmi qpjf oyii"/>
// <add key="sms_smsrecipients" value="6315252496@vtext.com"/>
public static void SendSMSEmail(string message, String from, String[] recipients,String smtpAddress,String userName,String password,int port=587)
{
String subject = string.Format("{0} {1}", message, DateTime.Now);
try
{
if (!NetworkStatus.IsInternetConnected())
{
MDTrace.WriteLine(LogLevel.DEBUG,"The internet is not connected. Cannot send SMSEmail.");
return;
}
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(from);
mailMessage.Body = message;
mailMessage.Subject = subject;
mailMessage.IsBodyHtml = false;
foreach (String recipient in recipients)
{
mailMessage.To.Add(new MailAddress(recipient));
}
SmtpClient smtpClient = new SmtpClient(smtpAddress,port); // smtp.gmail.com
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(userName,password); // skessler1964@gmail.com MN5191306B
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
smtpClient.Dispose();
}
catch (System.Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,exception.ToString());
}
}
public static void SendEmail(string message, String from, String[] recipients,String smtpAddress,String userName,String password,int port=587)
{
String subject = string.Format("{0} {1}", message, DateTime.Now);
try
{
if (!NetworkStatus.IsInternetConnected())
{
MDTrace.WriteLine(LogLevel.DEBUG,"The internet is not connected. Cannot send Email.");
return;
}
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(from);
mailMessage.Body = message;
mailMessage.Subject = subject;
mailMessage.IsBodyHtml = false;
foreach (String recipient in recipients)
{
mailMessage.To.Add(new MailAddress(recipient));
}
SmtpClient smtpClient = new SmtpClient(smtpAddress,port); // smtp.gmail.com
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(userName,password); // skessler1964@gmail.com MN5191306B
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
smtpClient.Dispose();
}
catch (System.Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,exception.ToString());
}
}
}
}

View File

@@ -0,0 +1,548 @@
using System;
using System.Collections;
using System.Net.Sockets;
using System.Diagnostics;
using System.Net;
using System.IO;
using System.Text;
// Filename: Socket.cs
// Author:Sean Kessler
namespace MarketData.Integration
{
internal class ContentHeader
{
private String server;
private String date;
private String pragma;
private String connection;
private String contentLength;
private String contentType;
private String cookie;
private String cache;
public ContentHeader()
{
}
public String Server
{
get { return server; }
set { server = value; }
}
public String Date
{
get { return date; }
set { date = value; }
}
public String Pragma
{
get { return pragma; }
set { pragma = value; }
}
public String Connection
{
get { return connection; }
set { connection = value; }
}
public String ContentLength
{
get { return contentLength; }
set { contentLength = value; }
}
public String ContentType
{
get { return contentType; }
set { contentType = value; }
}
public String Cookie
{
get { return cookie; }
set { cookie = value; }
}
public String Cache
{
get { return cache; }
set { cache = value; }
}
}
public class SocketConnector : TcpClient
{
public SocketConnector(Socket serverSocket)
{
Client = serverSocket;
}
}
public class ServerSocketControl
{
private Socket acceptSocket;
private IPEndPoint ipLocalEndPoint;
public ServerSocketControl(int port)
{
int index;
acceptSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
acceptSocket.ReceiveTimeout = -1;
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddress = null;
for (index = 0; index < hostEntry.AddressList.Length; index++)
{
if (IPAddress.TryParse(hostEntry.AddressList[index].ToString(), out ipAddress))
{
switch (ipAddress.AddressFamily)
{
case System.Net.Sockets.AddressFamily.InterNetwork:
break;
case System.Net.Sockets.AddressFamily.InterNetworkV6:
ipAddress = null;
break;
default:
ipAddress = null;
break;
}
if (null != ipAddress) break;
}
}
if (null == ipAddress) throw new Exception("Could not determine IPV4 address.");
ipLocalEndPoint = new IPEndPoint(ipAddress, port);
SocketControl.TraceOut("[ServerSocketControl] Binding to endpoint " + ipLocalEndPoint);
acceptSocket.Bind(ipLocalEndPoint);
SocketControl.TraceOut("[ServerSocketControl] socket bound");
acceptSocket.Listen(-1);
}
public ServerSocketControl()
{
int index;
acceptSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
acceptSocket.ReceiveTimeout = -1;
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddress = null;
for (index = 0; index < hostEntry.AddressList.Length; index++)
{
if (IPAddress.TryParse(hostEntry.AddressList[index].ToString(), out ipAddress))
{
switch (ipAddress.AddressFamily)
{
case System.Net.Sockets.AddressFamily.InterNetwork:
break;
case System.Net.Sockets.AddressFamily.InterNetworkV6:
ipAddress = null;
break;
default:
ipAddress = null;
break;
}
if (null != ipAddress) break;
}
}
if (null == ipAddress) throw new Exception("Could not determine IPV4 address.");
ipLocalEndPoint = new IPEndPoint(ipAddress, 0);
SocketControl.TraceOut("[ServerSocketControl] Binding to endpoint " + ipLocalEndPoint);
acceptSocket.Bind(ipLocalEndPoint);
SocketControl.TraceOut("[ServerSocketControl] socket bound");
acceptSocket.Listen(-1);
ipLocalEndPoint = (IPEndPoint)acceptSocket.LocalEndPoint;
}
public IPEndPoint LocalEndPoint()
{
return ipLocalEndPoint;
}
public IPAddress Address()
{
return ipLocalEndPoint.Address;
}
public int Port()
{
return ipLocalEndPoint.Port;
}
public void Close()
{
if (null == acceptSocket) return;
acceptSocket.Shutdown(SocketShutdown.Both);
acceptSocket.Close();
acceptSocket = null;
}
public SocketControl Accept()
{
Socket socket = acceptSocket.Accept();
ipLocalEndPoint = (IPEndPoint)socket.LocalEndPoint;
SocketControl.TraceOut("[ServerSocketControl::Accept] connect accepted on " + ipLocalEndPoint);
SocketConnector socketConnector = new SocketConnector(socket);
return new SocketControl(socketConnector);
}
}
public class SocketControl
{
public const int OkResult = 220;
public const int ErrorResult = 500;
private TcpClient tcpClient;
private NetworkStream networkStream;
private BinaryWriter binaryWriter;
private BinaryReader binaryReader;
private bool isConnected = false;
public SocketControl(SocketConnector socketConnector)
{
tcpClient = socketConnector;
tcpClient.LingerState = new LingerOption(false, 0);
tcpClient.ReceiveTimeout = -1;
networkStream = tcpClient.GetStream();
binaryWriter = new BinaryWriter(networkStream);
binaryReader = new BinaryReader(networkStream);
isConnected = true;
}
public SocketControl(String strHost, int port)
{
tcpClient = new TcpClient();
tcpClient.Connect(strHost, port);
tcpClient.LingerState = new LingerOption(false, 0);
tcpClient.ReceiveTimeout = -1;
networkStream = tcpClient.GetStream();
binaryWriter = new BinaryWriter(networkStream);
binaryReader = new BinaryReader(networkStream);
isConnected = true;
}
public void Close()
{
if (!isConnected) return;
isConnected = false;
binaryWriter.Close();
binaryWriter = null;
binaryReader.Close();
binaryReader = null;
tcpClient.Close();
tcpClient = null;
}
public string ReadLine()
{
StringBuilder strLine = new StringBuilder();
if (!isConnected) return null;
byte[] streamByte = new byte[1];
while (true)
{
binaryReader.Read(streamByte, 0, 1);
if (13 == streamByte[0]) continue;
else if (10 == streamByte[0]) break;
else if ('\0' == (char)streamByte[0]) break;
strLine.Append((char)streamByte[0]);
streamByte[0] = 0;
}
return strLine.ToString();
}
public bool WriteLine(string strLine)
{
if (!isConnected || 0 == strLine.Length) return false;
strLine += "\r\n";
char[] streamData = strLine.ToCharArray();
binaryWriter.Write(streamData);
binaryWriter.Flush();
return true;
}
public int GetResultCode(string strLine)
{
if (0 == strLine.Length) return 0;
string strResult = "";
int strIndex = 0;
while (true)
{
if (strIndex >= 3) break;
if (' ' == strLine[strIndex]) break;
strResult += strLine[strIndex];
strIndex++;
}
if (0 == strResult.Length) return 0;
return int.Parse(strResult);
}
public string GetResult(string strLine)
{
string strResult = "";
int strIndex = 0;
int strLength = strLine.Length;
if (0 == strLength) return strResult;
while (' ' != strLine[strIndex] && strIndex < strLength) strIndex++;
strIndex++;
if (strIndex >= strLength) return strResult;
while (strIndex < strLength)
{
strResult += strLine[strIndex];
strIndex++;
}
return strResult;
}
public char[] GetRequest(string strRequest, int max)
{
if (!isConnected || null == strRequest || 0 == max) return null;
WriteLine("GET " + strRequest);
return Receive(max);
}
public MemoryStream GetRequest(string strRequest)
{
if (!isConnected || null == strRequest) return null;
WriteLine("GET " + strRequest);
return Receive();
}
public String GetRequestToString(String strRequest)
{
if (!isConnected || null == strRequest) return null;
WriteLine("GET " + strRequest);
MemoryStream memoryStream = Receive();
memoryStream.Seek(0, SeekOrigin.Begin);
StreamReader streamReader = new StreamReader(memoryStream);
String strResponse = streamReader.ReadToEnd();
streamReader.Close();
memoryStream.Close();
return strResponse;
}
public bool Write(char[] chars)
{
if (!isConnected || null == chars || 0 == chars.Length) return false;
binaryWriter.Write(chars);
binaryWriter.Flush();
return true;
}
public bool Write(byte[] bytes)
{
if (!isConnected || null == bytes || 0 == bytes.Length) return false;
binaryWriter.Write(bytes);
binaryWriter.Flush();
return true;
}
public bool Write(byte[] bytes, int length)
{
if (!isConnected || null == bytes || 0 == bytes.Length) return false;
binaryWriter.Write(bytes, 0, length);
binaryWriter.Flush();
return true;
}
public int ReadInt()
{
char[] chars = new char[4];
Receive(chars);
return (((byte)chars[3]) << 24) | (((byte)chars[2]) << 16) + (((byte)chars[1]) << 8) + ((byte)chars[0]);
}
public bool IsConnected()
{
return isConnected;
}
public bool Receive(char[] streamChars)
{
byte[] cb;
int count = 0;
int max;
int readCount;
max = streamChars.Length;
if (!isConnected || 0 == max) return false;
cb = new byte[1];
while (true)
{
readCount = binaryReader.Read(cb, 0, 1);
if (0 == readCount) break;
streamChars[count++] = (char)cb[0];
if (count >= max) break;
}
return count == max;
}
public int Receive(ref byte[] streamBytes)
{
int count = 0;
int max;
int readLength = 0;
max = streamBytes.Length;
if (!isConnected || 0 == max) return count;
while (true)
{
readLength = binaryReader.Read(streamBytes, count, max - count);
if (0 == readLength) break;
count += readLength;
if (count >= max) break;
}
if (0 == count) return count;
byte[] stream = new byte[count];
Array.Copy(streamBytes, stream, count);
streamBytes = stream;
return count;
}
public char[] Receive(int maxChars)
{
char[] streamChar;
char[] stream;
byte[] cb;
int count = 0;
int readCount = 0;
if (!isConnected || 0 == maxChars) return null;
streamChar = new char[maxChars];
while (true)
{
cb = new byte[1];
readCount = binaryReader.Read(cb, 0, 1);
if (0 == readCount) break;
streamChar[count++] = (char)cb[0];
if (count >= maxChars) break;
}
stream = new char[count];
Array.Copy(streamChar, stream, count);
return stream;
}
public MemoryStream Receive()
{
MemoryStream memoryStream = new MemoryStream();
byte[] cb;
int readCount = 0;
if (!isConnected) return null;
while (true)
{
cb = new byte[1];
readCount = binaryReader.Read(cb, 0, 1);
if (0 == readCount) break;
memoryStream.WriteByte(cb[0]);
}
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
}
public bool Receive(ArrayList receiveStrings, ArrayList responseStrings)
{
bool isInMultiLine = false;
bool returnCode = true;
string seriesItem = "";
string stringData = "";
receiveStrings.Clear();
if (!isConnected) return false;
while (true)
{
stringData = ReadLine();
if (null == stringData || 0 == stringData.Length) break;
if (0 == receiveStrings.Count)
{
seriesItem = stringData.Substring(0, 3);
if (!IsInResponse(seriesItem, responseStrings))
{
returnCode = false;
receiveStrings.Add(stringData);
break;
}
if ('-' == stringData[3]) isInMultiLine = true;
}
if (0 != receiveStrings.Count && isInMultiLine && '-' != stringData[3] &&
stringData.Substring(0, 3).Equals(seriesItem))
{
receiveStrings.Add(stringData);
break;
}
receiveStrings.Add(stringData);
if (!isInMultiLine) break;
}
return returnCode;
}
public bool Receive(ArrayList receiveStrings)
{
bool isInMultiLine = false;
string seriesItem = "";
string stringData = "";
receiveStrings.Clear();
if (!isConnected) return false;
while (true)
{
stringData = ReadLine();
if (null == stringData || 0 == stringData.Length) break;
if (0 == receiveStrings.Count)
{
seriesItem = stringData.Substring(0, 3);
try { if ('-' == stringData[3])isInMultiLine = true; }
catch (Exception) { ;}
}
if (0 != receiveStrings.Count && isInMultiLine && '-' != stringData[3] &&
stringData.Substring(0, 3).Equals(seriesItem))
{
receiveStrings.Add(stringData);
break;
}
receiveStrings.Add(stringData);
if (!isInMultiLine) break;
}
if (0 != receiveStrings.Count) return true;
return false;
}
public bool ReceivePage(ArrayList stringArray)
{
string stringData = "";
int reps = 0;
stringArray.Clear();
if (!isConnected) return false;
while (true)
{
stringData = ReadLine();
if (null == stringData || 0 == stringData.Length) reps++;
else
{
stringArray.Add(stringData);
reps = 0;
}
if (2 == reps) break;
}
return 0 != stringArray.Count ? true : false;
}
public MemoryStream ReceivePage()
{
MemoryStream memoryStream;
ContentHeader contentHeader;
contentHeader = ReadContentHeader();
byte[] bytes = new byte[int.Parse(contentHeader.ContentLength)];
Receive(ref bytes);
memoryStream = new MemoryStream(bytes);
return memoryStream;
}
public bool IsInResponse(string responseString, ArrayList responseStrings)
{
if (0 == responseStrings.Count) return false;
for (int index = 0; index < responseStrings.Count; index++)
{
if (responseString.Equals((string)responseStrings[index])) return true;
}
return false;
}
private ContentHeader ReadContentHeader()
{
ContentHeader contentHeader;
String stringLine;
String token;
String value;
contentHeader = new ContentHeader();
while (true)
{
stringLine = ReadLine();
if (null == stringLine || 0 == stringLine.Length) break;
String[] elements = stringLine.Split(':');
if (2 != elements.Length) continue;
token = elements[0].Trim().ToUpper();
value = elements[1].Trim().ToUpper();
if ("SERVER".Equals(token)) contentHeader.Server = value;
else if ("DATE".Equals(token)) contentHeader.Date = value;
else if ("PRAGMA".Equals(token)) contentHeader.Pragma = value;
else if ("CACHE-CONTROL".Equals(token)) contentHeader.Cache = value;
else if ("CONNECTION".Equals(token)) contentHeader.Connection = value;
else if ("CONTENT-LENGTH".Equals(token)) contentHeader.ContentLength = value;
else if ("CONTENT-TYPE".Equals(token)) contentHeader.ContentType = value;
else if ("SET-COOKIE".Equals(token)) contentHeader.Cookie = value;
}
return contentHeader;
}
[Conditional("TRACENET")]
public static void TraceOut(String strLine)
{
String strThread = "[Thread=" + System.Threading.Thread.CurrentThread.GetHashCode() + "]";
String strDate = "[" + DateTime.Now.ToString() + "]";
Trace.WriteLine(strThread + "[]" + strDate + strLine);
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MarketData.Integration
{
public class UserAgent
{
private static UserAgent instance=null;
//private bool useVersioning=false;
private String[] userAgents=
{
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
"Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko)",
"Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13G36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) Internet Explorer 6",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063",
"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15",
"Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko",
"Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko)",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)",
"Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0",
"Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2)",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0",
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
};
private Random random=new Random();
private UserAgent()
{
}
public static UserAgent GetInstance()
{
lock(typeof(UserAgent))
{
if(null==instance) instance=new UserAgent();
return instance;
}
}
//public bool GetVersioning()
//{
// lock(this)
// {
// return useVersioning;
// }
//}
//public void setVersioning(bool versioning)
//{
// lock(this)
// {
// useVersioning=versioning;
// }
//}
public String GetUserAgent()
{
lock(this)
{
double randomNumber=random.NextDouble(); // number between 0 and 1
int index=(int)(randomNumber*((double)userAgents.Length));
return userAgents[index];
}
}
}
}