Exemple #1
0
 private void InitServer(string logHeader)
 {
     if (_config == null)
     {
         _config = new FtpConfig();
     }
     if (File.Exists("UniFTP.Server.log4net"))
     {
         log4net.Config.XmlConfigurator.ConfigureAndWatch(log4net.LogManager.GetRepository(typeof(FtpServer).Assembly), new FileInfo("UniFTP.Server.log4net"));
     }
     UserGroups.Clear();
     UserGroups.Add("anonymous", FtpUserGroup.Anonymous);
     Users.Clear();
     if (Config.AllowAnonymous)
     {
         Users.Add("anonymous", FtpUser.Anonymous);
     }
     if (OnLog == null)
     {
         OnLog += sender => { };
     }
     ConnectionInfos = new List <FtpConnectionInfo>();
     //foreach (var endPoint in localEndPoints)
     //{
     //    //_performanceCounter.Initialize(endPoint.Port);
     //}
     SetCounter(logHeader);
 }
Exemple #2
0
 /// <summary>
 /// FTP服务器
 /// </summary>
 /// <param name="port">监听端口号</param>
 /// <param name="config">FTP配置(可为空)</param>
 /// <param name="enableIPv6">启用IPv6</param>
 /// <param name="ipv6Port">IPv6端口</param>   //MARK:Linux中无法将一个Socket绑定到IPv4和IPv6的同一个端口
 /// <param name="logHeader">日志头,也用作性能计数器的实例划分,请传入服务器名</param>
 public FtpServer(int port, FtpConfig config = null, bool enableIPv6 = false, int ipv6Port = -1, string logHeader = null)
 //: this(IPAddress.Any, port, enableIPv6, ipv6Port, logHeader)
     : base(new[] { new IPEndPoint(IPAddress.Any, port), enableIPv6 ? new IPEndPoint(IPAddress.IPv6Any, (ipv6Port > 0 ? ipv6Port : port)) : null }, logHeader)
 {
     Config = config;
     if (logHeader == null && config != null)
     {
         logHeader = config.ServerName;
     }
     Active = false;
     InitServer(logHeader);
 }