Пример #1
0
        /// <exception cref="NSch.JSchException"></exception>
        internal static NSch.PortWatcher GetPort(Session session, string address, int lport
                                                 )
        {
            IPAddress addr;

            try
            {
                addr = Sharpen.Extensions.GetAddressByName(address);
            }
            catch (UnknownHostException uhe)
            {
                throw new JSchException("PortForwardingL: invalid address " + address + " specified."
                                        , uhe);
            }
            lock (pool)
            {
                for (int i = 0; i < pool.Count; i++)
                {
                    NSch.PortWatcher p = (NSch.PortWatcher)(pool[i]);
                    if (p.session == session && p.lport == lport)
                    {
                        if ((anyLocalAddress != null && p.boundaddress.Equals(anyLocalAddress)) || p.boundaddress
                            .Equals(addr))
                        {
                            return(p);
                        }
                    }
                }
                return(null);
            }
        }
Пример #2
0
 /// <exception cref="NSch.JSchException"></exception>
 internal static void DelPort(Session session, string address, int lport)
 {
     NSch.PortWatcher pw = GetPort(session, address, lport);
     if (pw == null)
     {
         throw new JSchException("PortForwardingL: local port " + address + ":" + lport +
                                 " is not registered.");
     }
     pw.Delete();
     pool.RemoveElement(pw);
 }
Пример #3
0
 /// <exception cref="NSch.JSchException"></exception>
 internal static NSch.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.");
     }
     NSch.PortWatcher pw = new NSch.PortWatcher(session, address, lport, host, rport,
                                                ssf);
     pool.Add(pw);
     return(pw);
 }
Пример #4
0
        internal static string[] GetPortForwarding(Session session)
        {
            ArrayList foo = new ArrayList();

            lock (pool)
            {
                for (int i = 0; i < pool.Count; i++)
                {
                    NSch.PortWatcher p = (NSch.PortWatcher)(pool[i]);
                    if (p.session == session)
                    {
                        foo.Add(p.lport + ":" + p.host + ":" + p.rport);
                    }
                }
            }
            string[] bar = new string[foo.Count];
            for (int i_1 = 0; i_1 < foo.Count; i_1++)
            {
                bar[i_1] = (string)(foo[i_1]);
            }
            return(bar);
        }
Пример #5
0
 internal static void DelPort(Session session)
 {
     lock (pool)
     {
         NSch.PortWatcher[] foo = new NSch.PortWatcher[pool.Count];
         int count = 0;
         for (int i = 0; i < pool.Count; i++)
         {
             NSch.PortWatcher p = (NSch.PortWatcher)(pool[i]);
             if (p.session == session)
             {
                 p.Delete();
                 foo[count++] = p;
             }
         }
         for (int i_1 = 0; i_1 < count; i_1++)
         {
             NSch.PortWatcher p = foo[i_1];
             pool.RemoveElement(p);
         }
     }
 }
Пример #6
0
		internal static void DelPort(Session session)
		{
			lock (pool)
			{
				NSch.PortWatcher[] foo = new NSch.PortWatcher[pool.Count];
				int count = 0;
				for (int i = 0; i < pool.Count; i++)
				{
					NSch.PortWatcher p = (NSch.PortWatcher)(pool[i]);
					if (p.session == session)
					{
						p.Delete();
						foo[count++] = p;
					}
				}
				for (int i_1 = 0; i_1 < count; i_1++)
				{
					NSch.PortWatcher p = foo[i_1];
					pool.RemoveElement(p);
				}
			}
		}
Пример #7
0
		/// <exception cref="NSch.JSchException"></exception>
		internal static NSch.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.");
			}
			NSch.PortWatcher pw = new NSch.PortWatcher(session, address, lport, host, rport, 
				ssf);
			pool.Add(pw);
			return pw;
		}