protected virtual void MakeConnection() { if (_socks != null) { IPAddressSet a = null; try { a = new IPAddressSet(IPAddress.Parse(_socks.DestName)); } catch (FormatException) { try { a = new IPAddressSet(_socks.DestName); } catch (Exception) { } } if (a != null && !SocksApplicapable(_socks.ExcludingNetworks, a)) { _addressSet = a; _host = _socks.DestName; _port = _socks.DestPort; _socks = null; } } string dest = _socks == null ? _host : _socks.ServerName; int port = _socks == null ? _port : _socks.ServerPort; string msg = _socks == null?GetHostDescription() : "SOCKS Server"; if (_addressSet == null) { try { _addressSet = new IPAddressSet(IPAddress.Parse(dest)); } catch (FormatException) { _errorMessage = String.Format("The {0} {1} was not found.", msg, dest); _addressSet = new IPAddressSet(dest); } } _errorMessage = String.Format("Failed to connect {0} {1}. Please check the address and the port.", msg, dest); _socket = NetUtil.ConnectTCPSocket(_addressSet, port); _connectedAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address; if (_socks != null) { _errorMessage = "An error occurred while SOCKS negotiation."; _socks.Connect(_socket); _host = _socks.DestName; _port = _socks.DestPort; } _tcpConnected = true; }
public void AsyncConnect(ISocketWithTimeoutClient client, Socks socks) { _async = true; _client = client; _event = null; _socks = socks; UI.UILibUtil.CreateThread(new ThreadStart(this.Run)).Start(); }
protected virtual void MakeConnection() { //まずSOCKSを使うべきかどうかを判定する if (_socks != null) { IPAddressSet a = null; try { a = new IPAddressSet(IPAddress.Parse(_socks.DestName)); } catch (FormatException) { try { a = new IPAddressSet(_socks.DestName); } catch (Exception) { //ここで名前解決できずとも、SOCKSサーバが解決できるかもしれないのでエラーにはしない } } if (a != null && !SocksApplicapable(_socks.ExcludingNetworks, a)) //SOCKSを使わないことが確定 { _addressSet = a; _host = _socks.DestName; _port = _socks.DestPort; _socks = null; } } string dest = _socks == null? _host : _socks.ServerName; int port = _socks == null? _port : _socks.ServerPort; string msg = _socks == null?GetHostDescription() : "SOCKS Server"; if (_addressSet == null) { try { _addressSet = new IPAddressSet(IPAddress.Parse(dest)); //最初からIPアドレス形式のときは手で変換。そうでないとDNSの逆引きをしてタイムアウト、とかややこしいことが起こる } catch (FormatException) { _errorMessage = String.Format("The {0} {1} was not found.", msg, dest); _addressSet = new IPAddressSet(dest); } } _errorMessage = String.Format("Failed to connect {0} {1}. Please check the address and the port.", msg, dest); _socket = NetUtil.ConnectTCPSocket(_addressSet, port); _connectedAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address; if (_socks != null) { _errorMessage = "An error occurred while SOCKS negotiation."; _socks.Connect(_socket); _host = _socks.DestName; _port = _socks.DestPort; } _tcpConnected = true; }
private static Socks CreateSocksParam(string dest_host, int dest_port) { Socks s = new Socks(); s.DestName = dest_host; s.DestPort = (short)dest_port; s.Account = GEnv.Options.SocksAccount; s.Password = GEnv.Options.SocksPassword; s.ServerName = GEnv.Options.SocksServer; s.ServerPort = (short)GEnv.Options.SocksPort; s.ExcludingNetworks = GEnv.Options.SocksNANetworks; return(s); }
private static Socks CreateSocksParam(string dest_host, int dest_port) { Socks s = new Socks(); s.DestName = dest_host; s.DestPort = (short)dest_port; s.Account = GEnv.Options.SocksAccount; s.Password = GEnv.Options.SocksPassword; s.ServerName = GEnv.Options.SocksServer; s.ServerPort = (short)GEnv.Options.SocksPort; s.ExcludingNetworks = GEnv.Options.SocksNANetworks; return s; }
protected virtual void MakeConnection() { //�܂�SOCKS��g���ׂ����ǂ����肷�� if(_socks!=null) { IPAddressSet a = null; try { a = new IPAddressSet(IPAddress.Parse(_socks.DestName)); } catch(FormatException ) { try { a = new IPAddressSet(_socks.DestName); } catch(Exception) { //�����Ŗ��O����ł����Ƃ�ASOCKS�T�[�o������ł��邩�����Ȃ��̂ŃG���[�ɂ͂��Ȃ� } } if(a!=null && !SocksApplicapable(_socks.ExcludingNetworks, a)) { //SOCKS��g��Ȃ����Ƃ��m�� _addressSet = a; _host = _socks.DestName; _port = _socks.DestPort; _socks = null; } } string dest = _socks==null? _host : _socks.ServerName; int port = _socks==null? _port : _socks.ServerPort; string msg = _socks==null? GetHostDescription() : "SOCKS Server"; if(_addressSet==null) { try { _addressSet = new IPAddressSet(IPAddress.Parse(dest)); //�ŏ�����IP�A�h���X�`���̂Ƃ��͎�ŕϊ��B�����łȂ���DNS�̋t��������ă^�C���A�E�g�A�Ƃ���₱�������Ƃ��N���� } catch(FormatException ) { _errorMessage = String.Format("The {0} {1} was not found.", msg, dest); _addressSet = new IPAddressSet(dest); } } _errorMessage = String.Format("Failed to connect {0} {1}. Please check the address and the port.", msg, dest); _socket = NetUtil.ConnectTCPSocket(_addressSet, port); _connectedAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address; if(_socks!=null) { _errorMessage = "An error occurred while SOCKS negotiation."; _socks.Connect(_socket); _host = _socks.DestName; _port = _socks.DestPort; } _tcpConnected = true; }
public void AsyncConnect(ISocketWithTimeoutClient client, Socks socks) { _async = true; _client = client; _event = null; _socks = socks; UI.UILibUtil.CreateThread(new ThreadStart(this.Run)).Start(); }
public void AsyncConnect(ISocketWithTimeoutClient client, string host, int port) { _async = true; _client = client; _event = null; _host = host; _port = port; _socks = null; UI.UILibUtil.CreateThread(new ThreadStart(this.Run)).Start(); }