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); } }
public List <NatSession> getAndRefreshSessionInfo() { List <NatSession> allSession = NatSessionManager.getAllSession(); refreshSessionInfo(allSession); return(allSession); }
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); }
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); }
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); }
public void refreshSessionInfo() { List <NatSession> allSession = NatSessionManager.getAllSession(); refreshSessionInfo(allSession); }