Example #1
0
        public ServersManager(ServersManagerConfig config)
        {
            if (BufferManager.IsInitialized() == false)
            {
                BufferManager.Initialize(256);                 // Mb
            }
            if (EventArgsManager.IsInitialized() == false)
            {
                EventArgsManager.Initialize();
            }

            this.running = false;

            this.sync          = new object();
            this.protocolPorts = new List <ProtocolPort>();
            this.servers       = new ThreadSafeDictionary <ServerEndPoint, Server <C> >();
            this.fakeServers   = new ThreadSafeDictionary <ServerEndPoint, Server <C> >();

            this.AddressPredicate  = DefaultAddressPredicate;
            this.FakeAddressAction = DefaultFakeAddressAction;

            this.config = config;

            this.nextPort = config.MinPort;

            this.logger = new Logger();
        }
Example #2
0
        public UdpServer(ServersManagerConfig config)
            : base()
        {
            sync = new object();

            queueSize = (config.UdpQueueSize > 0) ? config.UdpQueueSize : 16;
        }
Example #3
0
 public BaseTcpServer(ServersManagerConfig config)
 {
     this.sync               = new object();
     this.receiveQueueSize   = config.TcpQueueSize;
     this.minAcceptBacklog   = config.TcpMinAcceptBacklog;
     this.maxAcceptBacklog   = config.TcpMaxAcceptBacklog;
     this.socketReuseEnabled = (this.minAcceptBacklog < this.maxAcceptBacklog);
 }
Example #4
0
        public BaseTcpServer(ServersManagerConfig config)
            : base()
        {
            sync = new object();

            receiveQueueSize = config.TcpQueueSize;
            //offsetOffset = config.TcpOffsetOffset;

            minAcceptBacklog   = config.TcpMinAcceptBacklog;
            maxAcceptBacklog   = config.TcpMaxAcceptBacklog;
            socketReuseEnabled = minAcceptBacklog < maxAcceptBacklog;
        }
Example #5
0
 public ServersManager(ServersManagerConfig config)
 {
     if (!BufferManager.IsInitialized())
     {
         BufferManager.Initialize(256);
     }
     if (!EventArgsManager.IsInitialized())
     {
         EventArgsManager.Initialize();
     }
     this.running           = false;
     this.sync              = new object();
     this.protocolPorts     = new List <ProtocolPort>();
     this.servers           = new ThreadSafeDictionary <ServerEndPoint, Server <C> >();
     this.fakeServers       = new ThreadSafeDictionary <ServerEndPoint, Server <C> >();
     this.AddressPredicate  = new Func <NetworkInterface, IPInterfaceProperties, UnicastIPAddressInformation, bool>(ServersManager <C> .DefaultAddressPredicate);
     this.FakeAddressAction = new Func <ServerEndPoint, IPEndPoint>(ServersManager <C> .DefaultFakeAddressAction);
     this.config            = config;
     this.nextPort          = config.MinPort;
     this.logger            = new Logger();
 }
Example #6
0
 public UdpServer(ServersManagerConfig config)
 {
     this.sync      = new object();
     this.queueSize = ((config.UdpQueueSize > 0) ? config.UdpQueueSize : 16);
 }
Example #7
0
        public static Server <C> Create(ServerEndPoint real, IPEndPoint ip4fake, IPAddress ip4mask, ServersManagerConfig config)
        {
            Server <C> server;

            if (real.Protocol == ServerProtocol.Tcp)
            {
                server = new TcpServer <C>(config);
            }
            else if (real.Protocol == ServerProtocol.Udp)
            {
                server = new UdpServer <C>(config);
            }
            else
            {
                if (real.Protocol != ServerProtocol.Tls)
                {
                    throw new InvalidOperationException("Protocol is not supported.");
                }
                server = new SspiTlsServer <C>(config);
            }
            server.realEndPoint = real.Clone();
            if (ip4fake != null)
            {
                if (ip4mask == null)
                {
                    throw new ArgumentNullException("ip4mask");
                }
                server.fakeEndPoint = new ServerEndPoint(server.realEndPoint.Protocol, ip4fake);
                server.ip4Mask      = Server <C> .GetIPv4Long(ip4mask);

                server.ip4Subnet = (Server <C> .GetIPv4Long(real.Address) & server.ip4Mask);
            }
            return(server);
        }
Example #8
0
 public TcpServer(ServersManagerConfig config) : base(config)
 {
 }
Example #9
0
 public SspiTlsServer(ServersManagerConfig config) : base(config)
 {
     this.certificate = config.TlsCertificate;
 }