Example #1
0
        internal static PortWatcher getPort(Session session, String address, int lport)
        {
            IPAddress addr;

            try
            {
                addr = Dns.GetHostEntry(address).AddressList[0];
            }
            catch (Exception)
            {
                throw new JSchException("PortForwardingL: invalid address " + address + " specified.");
            }
            lock (pool)
            {
                for (int i = 0; i < pool.Count; i++)
                {
                    PortWatcher p = (PortWatcher)(pool[i]);
                    if (p.session == session && p.lport == lport)
                    {
                        if (
                            IPAddress.IsLoopback(p.boundaddress) ||
                            p.boundaddress == addr
                            )
                        {
                            return(p);
                        }
                    }
                }
                return(null);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        public static String[] getPortForwarding(Session session)
        {
            ArrayList foo = new ArrayList();

            lock (pool)
            {
                for (int i = 0; i < pool.Count; i++)
                {
                    PortWatcher p = (PortWatcher)(pool[i]);
                    if (p.session == session)
                    {
                        foo.Add(p.lport + ":" + p.host + ":" + p.rport);
                    }
                }
            }

            String[] bar = new String[foo.Count];

            for (int i = 0; i < foo.Count; i++)
            {
                bar[i] = (String)(foo[i]);
            }

            return(bar);
        }
Example #4
0
        public static void delPort(Session session)
        {
            lock (pool)
            {
                PortWatcher[] foo = new PortWatcher[pool.Count];

                int count = 0;

                for (int i = 0; i < pool.Count; i++)
                {
                    PortWatcher p = (PortWatcher)(pool[i]);

                    if (p.session == session)
                    {
                        p.Delete();
                        foo[count++] = p;
                    }
                }

                for (int i = 0; i < count; i++)
                {
                    PortWatcher p = foo[i];

                    pool.Remove(p);
                }
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        internal static void delPort(Session session, String address, int lport)
        {
            PortWatcher pw = getPort(session, address, lport);

            if (pw == null)
            {
                throw new JSchException("PortForwardingL: local port " + address + ":" + lport + " is not registered.");
            }
            pw.delete();
            pool.Remove(pw);
        }
Example #7
0
        internal static PortWatcher addPort(Session session, String address, int lport, String host, int rport, ServerSocketFactory ssf)
        {
            if (getPort(session, address, lport) != null)
            {
                throw new JSchException("PortForwardingL: local port " + address + ":" + lport + " is already registered.");
            }
            PortWatcher pw = new PortWatcher(session, address, lport, host, rport, ssf);

            pool.Add(pw);
            return(pw);
        }
Example #8
0
 internal static String[] getPortForwarding(Session session)
 {
     java.util.Vector foo = new java.util.Vector();
     lock (pool)
     {
         for (int i = 0; i < pool.size(); i++)
         {
             PortWatcher p = (PortWatcher)(pool.elementAt(i));
             if (p.session == session)
             {
                 foo.addElement(p.lport + ":" + p.host + ":" + p.rport);
             }
         }
     }
     String[] bar = new String[foo.size()];
     for (int i = 0; i < foo.size(); i++)
     {
         bar[i] = (String)(foo.elementAt(i));
     }
     return(bar);
 }
Example #9
0
 internal static void delPort(Session session)
 {
     lock (pool)
     {
         PortWatcher[] foo   = new PortWatcher[pool.size()];
         int           count = 0;
         for (int i = 0; i < pool.size(); i++)
         {
             PortWatcher p = (PortWatcher)(pool.elementAt(i));
             if (p.session == session)
             {
                 p.delete();
                 foo[count++] = p;
             }
         }
         for (int i = 0; i < count; i++)
         {
             PortWatcher p = foo[i];
             pool.removeElement(p);
         }
     }
 }
		internal static PortWatcher addPort(Session session, String address, int lport, String host, int rport, ServerSocketFactory ssf) 
		{
			if(getPort(session, address, lport)!=null)
			{
				throw new JSchException("PortForwardingL: local port "+ address+":"+lport+" is already registered.");
			}
			PortWatcher pw=new PortWatcher(session, address, lport, host, rport, ssf);
			pool.addElement(pw);
			return pw;
		}
		internal static void delPort(Session session)
		{
			lock(pool)
			{
				PortWatcher[] foo=new PortWatcher[pool.size()];
				int count=0;
				for(int i=0; i<pool.size(); i++)
				{
					PortWatcher p=(PortWatcher)(pool.elementAt(i));
					if(p.session==session) 
					{
						p.delete();
						foo[count++]=p;
					}
				}
				for(int i=0; i<count; i++)
				{
					PortWatcher p=foo[i];
					pool.removeElement(p);
				}
			}
		}
Example #12
0
		internal static void delPort(Session session)
		{
			lock(pool)
			{
				PortWatcher[] foo=new PortWatcher[pool.Count];
				int count=0;
				for (int i = 0; i < pool.Count; i++)
				{
					PortWatcher p=(PortWatcher)(pool[i]);
					if(p.session==session) 
					{
						p.delete();
						foo[count++]=p;
					}
				}
				for(int i=0; i<count; i++)
				{
					PortWatcher p=foo[i];
					pool.Remove(p);
				}
			}
		}
Example #13
0
 internal static PortWatcher addPort(Session session, String address, int lport, String host, int rport)
 {
     if(getPort(session, lport)!=null)
     {
         throw new JSchException("PortForwardingL: local port "+lport+" is already registered.");
     }
     PortWatcher pw=new PortWatcher(session, address, lport, host, rport);
     pool.Add(pw);
     return pw;
 }