Exemplo n.º 1
0
        protected virtual void MakeConnection()
        {
            //まずSOCKSを使うべきかどうかを判定する
            IProtocolOptions opt = ProtocolsPlugin.Instance.ProtocolOptions;

            if (opt.UseSocks && SocksApplicapable(opt.SocksNANetworks, IPAddressList.SilentGetAddress(_host)))
            {
                _socks            = new Socks();
                _socks.Account    = opt.SocksAccount;
                _socks.Password   = opt.SocksPassword;
                _socks.DestName   = _host;
                _socks.DestPort   = (short)_port;
                _socks.ServerName = opt.SocksServer;
                _socks.ServerPort = (short)opt.SocksPort;
            }

            string dest = _socks == null ? _host : _socks.ServerName;
            int    port = _socks == null ? _port : _socks.ServerPort;

            IPAddress address = null;

            if (IPAddress.TryParse(dest, out address))
            {
                _addressSet = new IPAddressList(address); //最初からIPアドレス形式のときは手で変換。そうでないとDNSの逆引きをしてタイムアウト、とかややこしいことが起こる
            }
            else                                          //ホスト名形式
            {
                StartOverridingErrorMessage(String.Format(PEnv.Strings.GetString("Message.AddressNotResolved"), dest));
                _addressSet = new IPAddressList(dest);
                EndOverridingErrorMessage();
            }

            StartOverridingErrorMessage(String.Format(PEnv.Strings.GetString("Message.FailedToConnectPort"), dest, port));
            _socket = NetUtil.ConnectTCPSocket(_addressSet, port);
            EndOverridingErrorMessage();
            _connectedAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;

            if (_socks != null)
            {
                _errorMessage = "An error occurred in SOCKS negotiation.";
                _socks.Connect(_socket);
                //接続成功したら_host,_portを元に戻す
                _host = _socks.DestName;
                _port = _socks.DestPort;
            }

            _tcpConnected = true;
        }
Exemplo n.º 2
0
        protected virtual void MakeConnection()
        {
            //まずSOCKSを使うべきかどうかを判定する
            IProtocolOptions opt = ProtocolsPlugin.Instance.ProtocolOptions;
            if (opt.UseSocks && SocksApplicapable(opt.SocksNANetworks, IPAddressList.SilentGetAddress(_host))) {
                _socks = new Socks();
                _socks.Account = opt.SocksAccount;
                _socks.Password = opt.SocksPassword;
                _socks.DestName = _host;
                _socks.DestPort = (short)_port;
                _socks.ServerName = opt.SocksServer;
                _socks.ServerPort = (short)opt.SocksPort;
            }

            string dest = _socks == null ? _host : _socks.ServerName;
            int port = _socks == null ? _port : _socks.ServerPort;

            IPAddress address = null;
            if (IPAddress.TryParse(dest, out address)) {
                _addressSet = new IPAddressList(address); //最初からIPアドレス形式のときは手で変換。そうでないとDNSの逆引きをしてタイムアウト、とかややこしいことが起こる
            }
            else { //ホスト名形式
                StartOverridingErrorMessage(String.Format(PEnv.Strings.GetString("Message.AddressNotResolved"), dest));
                _addressSet = new IPAddressList(dest);
                EndOverridingErrorMessage();
            }

            StartOverridingErrorMessage(String.Format(PEnv.Strings.GetString("Message.FailedToConnectPort"), dest, port));
            _socket = NetUtil.ConnectTCPSocket(_addressSet, port);
            EndOverridingErrorMessage();
            _connectedAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;

            if (_socks != null) {
                _errorMessage = "An error occurred in SOCKS negotiation.";
                _socks.Connect(_socket);
                //接続成功したら_host,_portを元に戻す
                _host = _socks.DestName;
                _port = _socks.DestPort;
            }

            _tcpConnected = true;
        }
Exemplo n.º 3
0
        protected virtual void MakeConnection()
        {
            //�܂�SOCKS��g���ׂ����ǂ����𔻒肷��
            IProtocolOptions opt = ProtocolsPlugin.Instance.ProtocolOptions;
            if (opt.UseSocks && SocksApplicapable(opt.SocksNANetworks, IPAddressList.SilentGetAddress(_host))) {
                _socks = new Socks();
                _socks.Account = opt.SocksAccount;
                _socks.Password = opt.SocksPassword;
                _socks.DestName = _host;
                _socks.DestPort = (short)_port;
                _socks.ServerName = opt.SocksServer;
                _socks.ServerPort = (short)opt.SocksPort;
            }

            string dest = _socks == null ? _host : _socks.ServerName;
            int port = _socks == null ? _port : _socks.ServerPort;

            IPAddress address = null;
            if (IPAddress.TryParse(dest, out address)) {
                _addressSet = new IPAddressList(address); //�ŏ�����IP�A�h���X�`���̂Ƃ��͎�ŕϊ��B�����łȂ���DNS�̋t��������ă^�C���A�E�g�A�Ƃ���₱�������Ƃ��N����
            }
            else { //�z�X�g���`��
                StartOverridingErrorMessage(String.Format(PEnv.Strings.GetString("Message.AddressNotResolved"), dest));
                _addressSet = new IPAddressList(dest);
                EndOverridingErrorMessage();
            }

            StartOverridingErrorMessage(String.Format(PEnv.Strings.GetString("Message.FailedToConnectPort"), dest, port));
            _socket = NetUtil.ConnectTCPSocket(_addressSet, port);
            EndOverridingErrorMessage();
            _connectedAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;

            if (_socks != null) {
                _errorMessage = "An error occurred in SOCKS negotiation.";
                _socks.Connect(_socket);
                //�ڑ�����������_host,_port����ɖ߂�
                _host = _socks.DestName;
                _port = _socks.DestPort;
            }

            _tcpConnected = true;
        }