Ejemplo n.º 1
0
        internal TunSocketAdapter(TcpSocket socket, TunInterface tun)
        {
            _socket = socket;
            _tun    = tun;

            socket.DataReceived += Socket_DataReceived;
            socket.DataSent     += Socket_DataSent;
            socket.SocketError  += Socket_SocketError;

            sendBufferTask = Task.Run(() =>
            {
                while (true)
                {
                    _tun.executeLwipTask(() =>
                    {
                        while (sendBuffers.TryPeek(out IBuffer buf))
                        {
                            if (_socket.Send(buf.ToArray()) == 0)
                            {
                                sendBuffers.TryDequeue(out buf);
                            }
                            else
                            {
                                break;
                            }
                        }
                    });
                    checkSendBufferHandle.Reset();
                    checkSendBufferHandle.WaitOne();
                }
            });
        }
Ejemplo n.º 2
0
        public RawShadowsocksAdapter(string srv, int port, TcpSocket socket, TunInterface tun) : base(socket, tun)
        {
            server    = srv;
            this.port = port;

            Task.Run(() => Init());
        }
Ejemplo n.º 3
0
 public ProxyAdapter(TcpSocket socket, TunInterface tun) : base(socket, tun)
 {
     ReadData += ProxyAdapter_ReadData;
     OnError  += ProxyAdapter_OnError;
 }