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() + "已连接"); } }
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); } }
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); }