internal void AddProxiesToMod() { protocol = (ProxyTypeIndex == 0) ? ProxyProtocol.HTTP : ProxyProtocol.SOCKS5; switch (ProxyFormatIndex) { case 0: Format4(); break; case 1: Format0('@'); break; case 2: Format0('|'); break; case 3: Format2(); break; case 4: Format3(); break; } AddProxies(proxiesColl); }
public RequestObj(string defaultHost, ProxyProtocol proxyProtocol) { // Client elements this.ClientRequestObj = new ClientRequest(defaultHost); // Server elements this.ServerResponseObj = new ServerResponse(); // Request object elements this.InitRequestValues(); this.ProxyProtocol = proxyProtocol; this.IsServerKeepAlive = false; this.HttpLogData = string.Empty; this.Counter = 0; this.ProxyDataTransmissionModeS2C = DataTransmissionMode.Undefined; // Determine request identifier this.Id = System.IO.Path.GetRandomFileName(); try { this.Id = this.Id.Replace(".", string.Empty); // Remove period. } catch (Exception) { this.Id = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff"); } }
public void ProxyCollInit() { XDocument doc = new XDocument(); string proxiesFile = @"proxies.xml"; if (!File.Exists(proxiesFile)) { return; } try { doc = XDocument.Load(proxiesFile); foreach (XElement el in doc.Root.Elements()) { string ip = el.Element("ip").Value; string port = el.Element("port").Value; string login = el.Element("login").Value; string pwd = el.Element("pwd").Value; string protocol_ = el.Element("protocol_type").Value; protocol = (protocol_ == "HTTP") ? ProxyProtocol.HTTP : ProxyProtocol.SOCKS5; Proxy pr = new Proxy(ip, port, login, pwd, protocol); AddNewProxy(pr); } } catch (Exception ex) { if (SendMessage != null) { SendMessage("Не удалось загрузить прокси, возможно файл proxies.xml повреждён"); } L.LW(ex); } }
public HostRecord(string method, ProxyProtocol proxyProtocol, string host, string path) { this.Method = method; this.ProxyProtocol = proxyProtocol; this.Host = host; this.Path = path; this.Counter = 0; }
public Proxy(string ip, string port, string login, string pwd, ProxyProtocol protocol) { Ip = ip; Port = port; Login = login; Pwd = pwd; ProxyProtocol = protocol; }
public BaseSocketProxyServer(ProxyProtocol protocol, IServiceProvider serviceProvider, IOptions <BindingOptions> bindingOptons, IOptions <ProxyRemoteOptions> proxyOptions) : base(serviceProvider, proxyOptions) { Protocol = protocol; BindingOptions = bindingOptons; }
public MyBinaryReader(ProxyProtocol proxyProtocol, Stream stream, int bufferSize, Encoding encoding, string clientConnectionId) : base(stream, encoding) { this.encoding = encoding; this.decoder = encoding.GetDecoder(); this.clientConnectionId = clientConnectionId; //base.BaseStream.ReadTimeout = 10000; //base.BaseStream.WriteTimeout = 10000; }
public Proxy(int id, string ip, string port, string login, string pwd, ProxyProtocol protocol, ProxyWorkStatus status) { Id = id; Ip = ip; Port = port; Login = login; Pwd = pwd; ProxyProtocol = protocol; Status = status; }
public void LogMessage(string requestId, ProxyProtocol proxyProtocol, Loglevel logLevel, string message, params object[] messageParams) { if (string.IsNullOrEmpty(message) || string.IsNullOrWhiteSpace(message)) { return; } if (logLevel < this.CurrentLoggingLevel) { return; } if (string.IsNullOrEmpty(requestId)) { requestId = "UNDEF"; } try { // Prepare log message var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (messageParams != null && messageParams.Length > 0) { message = string.Format(message, messageParams); } message = message.Trim(); lock (this.syncObj) { var logMessage = $"{timestamp} {requestId} {proxyProtocol}: {message}"; logFileStreamWriter.WriteLine(logMessage); logFileStreamWriter.Flush(); logFileStreamWriter.BaseStream.Flush(); Console.WriteLine(logMessage); // If testing this application add record to array if (this.IsInTestingMode) { var logLine = $"{timestamp} {requestId}: {message}{Environment.NewLine}"; this.logs.Add(logLine); } } } catch (Exception ex) { if (logLevel == Loglevel.Debug) { Console.WriteLine("ERROR: Error occurred in LogMessage: {0}", ex.Message); } } }
private void InitPersons() { XDocument doc = new XDocument(); string profilesFile = @"profiles.xml"; if (!File.Exists(profilesFile)) { return; } try { doc = XDocument.Load(profilesFile); foreach (XElement el in doc.Root.Elements()) { string title = el.Element("title").Value; string description = el.Element("description").Value; string profilePath = el.Element("profile_path").Value; string userAgent = el.Element("user_agent").Value; string hex = (el.Element("hex") != null) ? el.Element("hex").Value:null; Persona pers = new Persona() { Title = title, Description = description, ProfilePath = profilePath, UserAgent = userAgent, HashString = hex }; if (el.Element("proxy") != null) { XElement proxyEl = el.Element("proxy"); string ip = proxyEl.Element("ip").Value; string port = proxyEl.Element("port").Value; string login = proxyEl.Element("login").Value; string pwd = proxyEl.Element("pwd").Value; string protocol_ = proxyEl.Element("protocol_type").Value; ProxyProtocol protocol = (protocol_ == "HTTP") ? ProxyProtocol.HTTP : ProxyProtocol.SOCKS5; Proxy pr = new Proxy(ip, port, login, pwd, protocol); pers.Proxy = pr; } Persons.Add(pers); } } catch (Exception ex) { if (SendMessage != null) { SendMessage("Не удалось загрузить профили, возможно файл profiles.xml повреждён"); } L.LW(ex); } }
/// <summary> /// Converts a protocol to a literal. /// </summary> /// <param name="proxyProtocol">The proxy protocol.</param> /// <returns></returns> /// <exception cref="System.ArgumentOutOfRangeException">proxyProtocol</exception> public static string ToLiteral(this ProxyProtocol proxyProtocol) { switch (proxyProtocol) { case ProxyProtocol.HttpConnect: return("http"); case ProxyProtocol.Socks4A: return("socks"); default: throw new ArgumentOutOfRangeException("proxyProtocol"); } }
private string ToScheme(ProxyProtocol protocol) { switch (protocol) { case ProxyProtocol.Ftp: return(Uri.UriSchemeFtp); case ProxyProtocol.Http: return(Uri.UriSchemeHttp); case ProxyProtocol.Https: return(Uri.UriSchemeHttps); case ProxyProtocol.Socks: return("socks"); } throw new NotImplementedException($"Mapping for proxy protocol '{protocol}' is not yet implemented!"); }
/// <summary> /// Gets the literal protocol. /// </summary> /// <param name="proxyProtocol">The proxy protocol.</param> /// <returns></returns> private static string GetLiteralProtocol(ProxyProtocol proxyProtocol) { switch (proxyProtocol) { case ProxyProtocol.HttpConnect: return "http"; case ProxyProtocol.Socks4A: return "socks"; default: throw new ArgumentOutOfRangeException("proxyProtocol"); } }
public bool Connect(ILife iLife, string host1, int port1, string requestStr, ProxyProtocol proxyProtocol) { ProxyProtocol = proxyProtocol; if (Sock(CS.Server) != null) { //Ver5.0.1 //if(_host == HostName) { if (host1 == HostName && port1 == Port) { return(true); } //Ver5.0.0-b21 Sock(CS.Server).Close(); } if (UpperProxy.Use) //上位プロキシのチェック // 上位プロキシを経由しないサーバの確認 { foreach (string address in UpperProxy.DisableAdderssList) { if (ProxyProtocol == ProxyProtocol.Ssl) { if (host1.IndexOf(address) == 0) { UpperProxy.Use = false; break; } } else { string str = requestStr.Substring(11); if (str.IndexOf(address) == 0) { UpperProxy.Use = false; break; } } } } string host = host1; int port = port1; if (UpperProxy.Use) { host = UpperProxy.Server; port = UpperProxy.Port; } List <Ip> ipList = null; try{ ipList = new List <Ip>(); ipList.Add(new Ip(host)); }catch (ValidObjException) { ipList = _kernel.DnsCache.GetAddress(host).ToList(); if (ipList == null || ipList.Count == 0) { Logger.Set(LogKind.Error, null, 11, host); return(false); } } Ssl ssl = null; foreach (Ip ip in ipList) { int timeout = 3; _sock[CS.Server] = Inet.Connect(_kernel, ip, port, timeout, ssl); if (_sock[CS.Server] != null) { break; } } if (_sock[CS.Server] == null) { Logger.Set(LogKind.Detail, _sock[CS.Client], 26, string.Format("{0}:{1}", ipList[0], port)); return(false); } //sock[CS.SERVER].SendTimeout = OptionTimeout;//Ver5.0.2 送信タイムアウトは設定しない HostName = host1;//Request.HostNameを保存して、現在接続中のホストを記憶する //Ver5.6.1 Port = port1; return(true); }
public bool Connect(ILife iLife, string host1, int port1, string requestStr, ProxyProtocol proxyProtocol) { ProxyProtocol = proxyProtocol; if(Sock(CS.Server) != null) { //Ver5.0.1 //if(_host == HostName) { if(host1 == HostName && port1==Port) { return true; } //Ver5.0.0-b21 Sock(CS.Server).Close(); } if(UpperProxy.Use) {//上位プロキシのチェック // 上位プロキシを経由しないサーバの確認 foreach(string address in UpperProxy.DisableAdderssList) { if (ProxyProtocol == ProxyProtocol.Ssl) { if(host1.IndexOf(address) == 0) { UpperProxy.Use = false; break; } } else { string str = requestStr.Substring(11); if(str.IndexOf(address) == 0) { UpperProxy.Use = false; break; } } } } string host = host1; int port = port1; if(UpperProxy.Use) { host = UpperProxy.Server; port = UpperProxy.Port; } List<Ip> ipList = null; try{ ipList = new List<Ip>(); ipList.Add(new Ip(host)); }catch (ValidObjException){ ipList = _kernel.DnsCache.GetAddress(host).ToList(); if(ipList == null || ipList.Count == 0) { Logger.Set(LogKind.Error,null,11,host); return false; } } Ssl ssl = null; foreach(Ip ip in ipList){ int timeout = 3; _sock[CS.Server] = Inet.Connect(_kernel,ip,port,timeout,ssl); if(_sock[CS.Server] != null) break; } if(_sock[CS.Server] == null) { Logger.Set(LogKind.Detail,_sock[CS.Client],26,string.Format("{0}:{1}",ipList[0],port)); return false; } //sock[CS.SERVER].SendTimeout = OptionTimeout;//Ver5.0.2 送信タイムアウトは設定しない HostName = host1;//Request.HostNameを保存して、現在接続中のホストを記憶する //Ver5.6.1 Port = port1; return true; }
/// <summary> /// Initializes a new instance of the <see cref="ProxyServer"/> class. /// </summary> /// <param name="protocol">The protocol.</param> /// <param name="host">The host.</param> /// <param name="port">The port.</param> public ProxyServer(ProxyProtocol protocol, string host, int port) : base(host, port) { Protocol = protocol; }
internal ProxyInfo(string server, string port, ProxyProtocol protocol) { Host = server; Port = port.Int(); Protocol = protocol; }
public PulsarClientConfigBuilder ProxyServiceUrl(string proxyAddress, ProxyProtocol protocol) { _conf.ProxyServiceUrl = proxyAddress; _conf.ProxyProtocol = protocol; return(this); }
/// <summary> /// Initializes a new instance of the <see cref="ProxyServer"/> class. /// </summary> /// <param name="protocol">The protocol.</param> /// <param name="address">The address.</param> /// <param name="port">The port.</param> public ProxyServer(ProxyProtocol protocol, IPAddress address, int port) : base(address, port) { Protocol = protocol; }