Пример #1
0
 void StartListen()
 {
     PostMessageToConsoleWithLock("开始监听");
     while (true)
     {
         TcpClient  client  = listener.AcceptTcpClient();
         FTPConnect connect = new FTPConnect(client, connectionDispatcher);
         FTPConnects.Add(connect);
         PostMessageToConsoleWithLock(((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString() + "已连接");
     }
 }
Пример #2
0
        public void PostMessageFromClient(string msg, FTPConnect connect)
        {
            IPAddress ip = ((IPEndPoint)connect.controlClient.Client.RemoteEndPoint).Address;

            if (connect.Logined)
            {
                server.PostMessageToConsoleWithLock(DateTime.Now + " " + connect.user.username + "@" + ip.MapToIPv4().ToString() + " " + msg);
            }
            else
            {
                server.PostMessageToConsoleWithLock(DateTime.Now + " " + ip.ToString() + "   " + msg);
            }
        }
Пример #3
0
        public bool CheckDataPortLegal(int port, FTPConnect connect)
        {
            bool res = true;

            server.FTPConnects.ForEach((c) =>
            {
                if (c != connect && (port == c.controlPort || port == c.controlPort + 1 || port == c.controlPort - 1))
                {
                    res = false;
                }
            });
            return(res);
        }