private TcpClient TestTcpHandler(string address, int port) { var proxy = testproxy.Split(';'); if (proxy[0] == "Socks5") { Socks5ProxyClient SocksProxyClient; if (proxy[3] == "") { SocksProxyClient = new Socks5ProxyClient(proxy[1], Int32.Parse(proxy[2])); } else { SocksProxyClient = new Socks5ProxyClient(proxy[1], Int32.Parse(proxy[2]), proxy[3], proxy[4]); } try { TcpClient client = SocksProxyClient.CreateConnection(address, port); return(client); } catch { return(null); } } else { HttpProxyClient webProxyClient; if (proxy[3] == "") { webProxyClient = new HttpProxyClient(proxy[1], Int32.Parse(proxy[2])); } else { webProxyClient = new HttpProxyClient(proxy[1], Int32.Parse(proxy[2]), proxy[3], proxy[4]); } try { TcpClient client = webProxyClient.CreateConnection(address, port); return(client); } catch { return(null); } } }
public TcpClient TcpHandler(string address, int port) { var proxy = Properties.Settings.Default.ProxyInUse.Split(';'); if (proxy[0] == "Socks5") { Socks5ProxyClient SocksProxyClient; if (proxy[3] == "") { SocksProxyClient = new Socks5ProxyClient(proxy[1], Int32.Parse(proxy[2])); } else { SocksProxyClient = new Socks5ProxyClient(proxy[1], Int32.Parse(proxy[2]), proxy[3], proxy[4]); } try { TcpClient client = SocksProxyClient.CreateConnection(address, port); return(client); } catch { return(null); } } else { HttpProxyClient webProxyClient; if (proxy[3] == "") { webProxyClient = new HttpProxyClient(proxy[1], Int32.Parse(proxy[2])); } else { webProxyClient = new HttpProxyClient(proxy[1], Int32.Parse(proxy[2]), proxy[3], proxy[4]); } try { TcpClient client = webProxyClient.CreateConnection(address, port); return(client); } catch { return(null); } } }