コード例 #1
0
        public HttpProxyServer(IPEndPoint localEP, IProxyServerConnectionManager connectionManager = null, IProxyServerAuthenticationManager authenticationManager = null, int backlog = 10)
        {
            _listener = new Socket(localEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            _listener.Bind(localEP);
            _listener.Listen(backlog);
            _listener.NoDelay = true;

            _localEP               = (IPEndPoint)_listener.LocalEndPoint;
            _connectionManager     = connectionManager;
            _authenticationManager = authenticationManager;

            if (_connectionManager == null)
            {
                _connectionManager = new DefaultProxyServerConnectionManager();
            }

            _ = Task.Factory.StartNew(AcceptRequestAsync, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Current);
        }
コード例 #2
0
        public SocksProxyServer(IPEndPoint localEP, IProxyServerConnectionManager connectionManager = null, IProxyServerAuthenticationManager authenticationManager = null, int backlog = 10)
        {
            _listener = new Socket(localEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            _listener.Bind(localEP);
            _listener.Listen(backlog);
            _listener.NoDelay = true;

            _localEP               = (IPEndPoint)_listener.LocalEndPoint;
            _connectionManager     = connectionManager;
            _authenticationManager = authenticationManager;

            if (_connectionManager == null)
            {
                _connectionManager = new DefaultProxyServerConnectionManager();
            }

            //accept requests async
            int tasks = Math.Max(1, Environment.ProcessorCount);

            for (int i = 0; i < tasks; i++)
            {
                _ = Task.Factory.StartNew(AcceptRequestAsync, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Current);
            }
        }
コード例 #3
0
 public SocksProxyServer(IProxyServerConnectionManager connectionManager = null, IProxyServerAuthenticationManager authenticationManager = null, int backlog = 10)
     : this(new IPEndPoint(IPAddress.Loopback, 0), connectionManager, authenticationManager, backlog)
 {
 }
コード例 #4
0
 public ProxyServerSession(Socket localSocket, IProxyServerConnectionManager connectionManager, IProxyServerAuthenticationManager authenticationManager)
 {
     _localSocket           = localSocket;
     _connectionManager     = connectionManager;
     _authenticationManager = authenticationManager;
 }