internal static PortWatcher getPort(Session session, String address, int lport) { InetAddress addr; try { addr = InetAddress.getByName(address); } catch (Exception uhe) { throw new JSchException("PortForwardingL: invalid address " + address + " specified."); } lock (pool) { for (int i = 0; i < pool.size(); i++) { PortWatcher p = (PortWatcher)(pool.elementAt(i)); if (p.session == session && p.lport == lport) { if (p.boundaddress.isAnyLocalAddress() || p.boundaddress.equals(addr)) { return(p); } } } return(null); } }
internal PortWatcher(Session session, String address, int lport, String host, int rport, ServerSocketFactory factory) { this.session = session; this.lport = lport; this.host = host; this.rport = rport; try { boundaddress = InetAddress.getByName(address); ss = (factory == null) ? new ServerSocket(lport, 0, boundaddress) : factory.createServerSocket(lport, 0, boundaddress); } catch (Exception e) { Console.WriteLine(e); throw new JSchException("PortForwardingL: local port " + address + ":" + lport + " cannot be bound."); } }
public PortWatcher(Session session, String address, int lport, String host, int rport, ServerSocketFactory factory) { this.session = session; this.lport = lport; this.host = host; this.rport = rport; try { //Ignore microsoft's warning regarding "GetHostByName" being obsoleted. // //The proposed alternative, "GetHostEntry", is intended to be more generally correct (also handles IPV6), but // it actually does completely the WRONG thing when provided with a raw IPV4 address like "127.0.0.1": it should // use it as-is (at least that was the intention in this code), and instead it identifies the host and gets ALL // the most-specific IP addresses of the host ("localhost"), including IPV6 link-local addresses etc. So you say // "Bind to 127.0.0.1", and you get a listener that is actually bound to some link-local IPV6 address like // "fe80::84a:eaa6:244a:bde1%12" OR (if you filter out IPV6) "192.168.1.111", either way NOT binding to localhost! // // In other words, only change this if you really know what you're doing. // boundaddress = new InetAddress( Dns.GetHostEntry(address).AddressList[0]); // Dns.GetHostByName(address).AddressList[0]); ss = (factory == null) ? new TcpListener(boundaddress.addr, lport) : factory.createServerSocket(lport, 0, boundaddress); //In the move from custom "ServerSocket" class to standard "TcpListener", we lost the auto-start. ss.Start(); } catch (Exception e) { throw new JSchException("PortForwardingL: local port " + address + ":" + lport + " cannot be bound.", e); } }
internal PortWatcher(Session session, String address, int lport, String host, int rport, ServerSocketFactory factory) { this.session=session; this.lport=lport; this.host=host; this.rport=rport; try { boundaddress=InetAddress.getByName(address); ss=(factory==null) ? new ServerSocket(lport, 0, boundaddress) : factory.createServerSocket(lport, 0, boundaddress); } catch(Exception e) { Console.WriteLine(e); throw new JSchException("PortForwardingL: local port "+address+":"+lport+" cannot be bound."); } }
public ServerSocket(int port, int arg, InetAddress addr) : base(addr.addr, port) { this.Start(); }
public bool equals(InetAddress addr) { return(addr.ToString().Equals(addr.ToString())); }
public bool equals(InetAddress addr) { return addr.ToString().Equals( addr.ToString()); }
public static PortWatcher getPort(Session session, String address, int lport) { InetAddress addr; try { addr = new InetAddress(Dns.GetHostEntry(address).AddressList[0]); } catch (Exception uhe) { throw new JSchException("PortForwardingL: invalid address " + address + " specified.", inner: uhe); } lock (pool) { for (int i = 0; i < pool.Count; i++) { PortWatcher p = (PortWatcher) (pool[i]); if (p.session == session && p.lport == lport) { if (p.boundaddress.isAnyLocalAddress() || p.boundaddress.equals(addr)) { return p; } } } return null; } }