static void Main(string[] args) { //socks 4: //180.183.138.89:1080 //socks 5: //189.218.41.64:24732 //45.64.109.2:1080 Socks4Proxy proxy = new Socks4Proxy("182.253.44.117", 1080, "google.com", 80); proxy.OnStatusChanged += OnStatusChanged; proxy.OnRequestAccepted += Proxy_OnRequestAccepted; //proxy.BeginConnect(new AsyncCallback(OnConnected), proxy); proxy.AutoConnectAsync(); //proxy.AutoConnectAsync(Socks5Method.NoAuthentication); Console.ReadLine(); }
/// <summary> /// Connects to the XMPP server. /// </summary> public override void Connect() { m_elements = null; int port = (int)m_listener[Options.PORT]; Debug.Assert(port > 0); //m_sslOn = m_ssl; ProxySocket proxy = null; ProxyType pt = (ProxyType)m_listener[Options.PROXY_TYPE]; switch (pt) { case ProxyType.Socks4: proxy = new Socks4Proxy(this); break; case ProxyType.Socks5: proxy = new Socks5Proxy(this); break; case ProxyType.HTTP: proxy = new ShttpProxy(this); break; /* * case ProxyType.HTTP_Polling: * XEP25Socket j25s = new XEP25Socket(this); * if (m_ProxyHost != null) * { * System.Net.WebProxy wp = new System.Net.WebProxy(); * wp.Address = new Uri("http://" + m_ProxyHost + ":" + m_ProxyPort); * if (m_ProxyUsername != null) * { * wp.Credentials = new System.Net.NetworkCredential(m_ProxyUsername, m_ProxyPassword); * } * j25s.Proxy = wp; * } * j25s.URL = m_server; * m_sock = j25s; * break; */ case ProxyType.None: m_sock = new AsyncSocket(null, this, (bool)m_listener[Options.SSL], false); ((AsyncSocket)m_sock).LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as X509Certificate2; ((AsyncSocket)m_sock).CertificateGui = (bool)m_listener[Options.CERTIFICATE_GUI]; break; default: throw new ArgumentException("no handler for proxy type: " + pt, "ProxyType"); } if (proxy != null) { proxy.Socket = new AsyncSocket(null, proxy, (bool)m_listener[Options.SSL], false); ((AsyncSocket)proxy.Socket).LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as X509Certificate2; proxy.Host = m_listener[Options.PROXY_HOST] as string; proxy.Port = (int)m_listener[Options.PROXY_PORT]; proxy.Username = m_listener[Options.PROXY_USER] as string; proxy.Password = m_listener[Options.PROXY_PW] as string; m_sock = proxy; } string to = (string)m_listener[Options.TO]; Debug.Assert(to != null); string host = (string)m_listener[Options.NETWORK_HOST]; if (String.IsNullOrEmpty(host)) { #if __MonoCS__ host = to; #else try { Address.LookupSRV((string)m_listener[Options.SRV_PREFIX], to, ref host, ref port); } catch { Debug.WriteLine("WARNING: netlib.Dns.dll missing"); host = to; } #endif } Address addr = new Address(host, port); m_sock.Connect(addr, (string)m_listener[Options.SERVER_ID]); }