Esempio n. 1
0
        void disposeInternal(bool disposeBrother)
        {
            if (!mDisposed)
            {
                try
                {
                    mInnerChannel.Close();
                }
                catch (Exception ex)
                {
                    Debug.Fail($"InnerChannel close catch an exception: {ex.ToString()}");
                }

                if (mBrotherTunnel != null && disposeBrother)
                {
                    mBrotherTunnel.disposeInternal(false);
                }

                mInnerChannel  = null;
                mSelector      = null;
                mBrotherTunnel = null;
                mDisposed      = true;
                sessionCount--;

                onDispose();
                NatSessionManager.removeSession(portKey);
            }
        }
Esempio n. 2
0
        public List <NatSession> getAndRefreshSessionInfo()
        {
            List <NatSession> allSession = NatSessionManager.getAllSession();

            refreshSessionInfo(allSession);

            return(allSession);
        }
Esempio n. 3
0
        public static TcpTunnel wrap(SocketChannel channel, Selector selector)
        {
            TcpTunnel tunnel  = new RawTcpTunnel(channel, selector);
            var       session = NatSessionManager.getSession((short)channel.Socket().Port);

            if (session != null)
            {
                tunnel.isHttpsRequest = session.isHttpsSession;
            }

            return(tunnel);
        }
Esempio n. 4
0
        InetSocketAddress getDestAddress(SocketChannel localChannel)
        {
            short portKey = (short)localChannel.Socket().Port;
            var   session = NatSessionManager.getSession(portKey);

            if (session != null)
            {
                return(new InetSocketAddress(localChannel.Socket().InetAddress, session.remotePort & 0xFFFF));
            }

            return(null);
        }
Esempio n. 5
0
        public RemoteTcpTunnel(InetSocketAddress serverAddress, Selector selector, short portKey, Context context) : base(serverAddress, selector, portKey)
        {
            this.context = context;
            session      = NatSessionManager.getSession(portKey);
            string helperDir = new StringBuilder()
                               .Append(VPNConstants.DATA_DIR)
                               .Append(TimeFormatUtil.formatYYMMDDHHMMSS(session.vpnStartTime))
                               .Append("/")
                               .Append(session.getUniqueName())
                               .ToString();

            helper  = new TcpDataSaveHelper(helperDir, context);
            handler = new Handler(Looper.MainLooper);
        }
Esempio n. 6
0
        public void refreshSessionInfo()
        {
            List <NatSession> allSession = NatSessionManager.getAllSession();

            refreshSessionInfo(allSession);
        }