Example #1
0
        private Socks5ClientRequestReply AssocCore(IPAddress addr, int port)
        {
            Socks5ClientRequest request = new Socks5ClientRequest {
                Command            = Socks5Command.UDPMap,
                AddressType        = Socks5AddressType.IPv4,
                DestinationAddress = addr.ToString(),
                DestinationPort    = (ushort)port
            };

            _socks_control.Client.Send(request.GetBytes());

            byte[] connect_request_reply = new byte[Socks5Packet.MessageMaxLength]; // for everything
            _socks_control.Client.Receive(connect_request_reply);

            Socks5ClientRequestReply request_reply = new Socks5ClientRequestReply(connect_request_reply);

            if (request_reply.ResponseCode != Socks5ResponseCode.OK)
            {
                throw new Socks5Exception("SOCKS5 server reports: "
                                          + request_reply.ResponseCode);
            }

            this._established          = true;
            this._socks_endpoint       = new IPEndPoint(_socks_addr, request_reply.RemoteLocalPort);
            this.Client.ReceiveTimeout = 1000;
            return(request_reply);
        }
Example #2
0
        protected Socks5ClientRequestReply RemoteBindCore(Socks5ClientRequest request)
        {
            this.Client.Send(request.GetBytes());

            byte[] connect_request_reply = new byte[Socks5Packet.MessageMaxLength]; // for everything
            this.Client.Receive(connect_request_reply);

            Socks5ClientRequestReply request_reply = new Socks5ClientRequestReply(connect_request_reply);

            if (request_reply.ResponseCode != Socks5ResponseCode.OK)
            {
                throw new Socks5Exception("SOCKS5 server reports: "
                                          + request_reply.ResponseCode);
            }

            this._established = true;
            return(request_reply);
        }
Example #3
0
        protected Socks5ClientRequestReply RemoteConnectCore(Socks5ClientRequest request)
        {
            this.Client.Send(request.GetBytes());

            byte[] connect_request_reply = new byte[Socks5Packet.MessageMaxLength]; // for everything
            this.Client.Receive(connect_request_reply);

            Socks5ClientRequestReply request_reply = new Socks5ClientRequestReply(connect_request_reply);

            if (request_reply.ResponseCode != Socks5ResponseCode.OK)
            {
                throw new Socks5Exception("SOCKS5 server reports: "
                                          + request_reply.ResponseCode);
            }
            //if(request_reply.AddressType != request.AddressType)
            //    throw new ApplicationException("SOCKS5 reply address type does not match");
            this._established = true;
            return(request_reply);
        }