Exemple #1
0
        public void Start()
        {
            Stop();

            _cancellationStop ??= new CancellationTokenSource();
            _socks5Handler ??= new StandardRemoteSocks5Handler(this._remoteServerConfig, _dnsCache, _logger);

            _tcpServer.Listen();
            _udpServer.Listen();

            if (_tcpServer.IsRunning)
            {
                _ = Task.Run(async() =>
                {
                    await ProcessTcp(_cancellationStop.Token);
                }, this._cancellationStop.Token);
            }
            if (_tcpServer.IsRunning && _udpServer.IsRunning)
            {
                _ = Task.Run(async() =>
                {
                    await ProcessUdp(_cancellationStop.Token);
                }, this._cancellationStop.Token);
            }
        }
        public void Start()
        {
            Stop();

            _cancellationStop ??= new CancellationTokenSource();
            _socks5Handler ??= new StandardLocalSocks5Handler(_serverLoader, _logger);//TODO

            _tcpServer.Listen();
            _udpServer.Listen();

            if (_tcpServer.IsRunning)
            {
                _ = Task.Run(async() =>
                {
                    await ProcessTcp(_cancellationStop.Token);
                }, this._cancellationStop.Token);
            }
            if (_tcpServer.IsRunning && _udpServer.IsRunning)
            {
                _ = Task.Run(async() =>
                {
                    await ProcessUdp(_cancellationStop.Token);
                }, this._cancellationStop.Token);
            }
        }
Exemple #3
0
        public NetworkManager()
        {
            Server             = new Server();
            Server.ClientRecv += Server_ClientRecv;
            Server.Listen(8089);

            UdpServer = new UdpServer();
            UdpServer.Listen(8089);
            UdpServer.ClientRecv += UdpServer_ClientRecv;
        }
Exemple #4
0
        static void Main(string[] args)
        {
            ushort port      = 9015;
            var    server    = new Server();
            var    serverUdp = new UdpServer();

            server.Listen(port);
            serverUdp.Listen(port);

            if (server.Listening && serverUdp.Listening)
            {
                Console.WriteLine($"Listening on port: {port}");
            }

            Console.ReadLine();
        }
Exemple #5
0
 public void Listen(int port)
 {
     udp.Listen(port);
     udp.DataReceived += Udp_DataReceived;
 }