コード例 #1
0
 protected override async Task OnConnectionResult(ConnectResultBase result)
 {
     if (socks5svr != null)
     {
         var tmp = socks5svr;
         socks5svr = null;
         await tmp.WriteConnectionResult(new IPEndPoint(0, Dest.Port), (result.Ok)?Socks5Server.Rep.succeeded : Socks5Server.Rep.Connection_refused);
     }
     await base.OnConnectionResult(result);
 }
コード例 #2
0
 private bool Auth(Socks5Server s)
 {
     if (s.Username.IsNullOrEmpty() && s.Password.IsNullOrEmpty() && _adapter._allowNoAuth)
     {
         return(true);
     }
     foreach (var x in _adapter.users)
     {
         if ((x.name ?? "") == s.Username && (x.passwd ?? "") == s.Password)
         {
             outRef = x.@out ?? _adapter.@out;
             return(true);
         }
     }
     _adapter.Logger.warning("Auth failed: " + _eppair.RemoteEP);
     return(false);
 }
コード例 #3
0
            public SocksInConnection(TcpClient tcp, SocksInAdapter adapter) : base(adapter)
            {
                _eppair   = EPPair.FromSocket(tcp.Client);
                _adapter  = adapter;
                _stream   = adapter.GetMyStreamFromSocket(tcp.Client);
                socks5svr = new Socks5Server(_stream);

                Socks5Server.Methods methods = Socks5Server.Methods.None;
                if (adapter._allowNoAuth)
                {
                    methods |= Socks5Server.Methods.NoAuth;
                }
                if (adapter.users != null)
                {
                    methods |= Socks5Server.Methods.UsernamePassword;
                }
                socks5svr.AcceptMethods = methods;

                outRef = adapter._noAuthOut;

                socks5svr.Auth = Auth;
            }