/// <summary> /// Initialise the server, use this method when loading from the configuration file. /// </summary> private void Initialise() { // Create the configuration readers. _securityReader = new Nequeo.Security.Configuration.Reader(); _serverReader = new Net.Configuration.Reader(); _appSettingsReader = new System.Configuration.AppSettingsReader(); // Get the non-secure IPv4 and IPv6 host details. _serverHostElementV4 = _serverReader.GetServerHost(_socketProviderHostPrefix + _hostV4); _serverHostElementV6 = _serverReader.GetServerHost(_socketProviderHostPrefix + _hostV6); // Get the secure IPv4 and IPv6 host details. _sslServerHostElementV4 = _serverReader.GetServerHost(_socketProviderHostPrefix + _sslHostV4); _sslServerHostElementV6 = _serverReader.GetServerHost(_socketProviderHostPrefix + _sslHostV6); // Get the collective maximum number // of clients for all servers. _collectiveMaxNumberOfClientsValue = Int32.MaxValue; // Create the non-secure IPv4 endpoint. _addressesV4 = new IPAddress[1]; _addressesV4[0] = IPAddress.Any; // Create the non-secure IPv6 endpoint. _addressesV6 = new IPAddress[1]; _addressesV6[0] = IPAddress.IPv6Any; // Create the secure IPv4 endpoint. _sslAddressesV4 = new IPAddress[1]; _sslAddressesV4[0] = IPAddress.Any; // Create the secure IPv6 endpoint. _sslAddressesV6 = new IPAddress[1]; _sslAddressesV6[0] = IPAddress.IPv6Any; // Create the milti-endpoint model. _multiEndpointModels = new Net.Sockets.MultiEndpointModel[4]; // Assign the non-secure IPv4 model details. AssignServerMultiModelDetails(0, _addressesV4, _serverHostElementV4); // Assign the non-secure IPv6 model details. AssignServerMultiModelDetails(1, _addressesV6, _serverHostElementV6); // Assign the secure IPv4 model details. AssignServerMultiModelDetails(2, _sslAddressesV4, _sslServerHostElementV4); // Assign the secure IPv6 model details. AssignServerMultiModelDetails(3, _sslAddressesV6, _sslServerHostElementV6); // Assign from max collective clients. _maxNumClients = _collectiveMaxNumberOfClientsValue; }
/// <summary> /// Open the new service connection. /// </summary> private void OpenConnection() { X509Certificate2 certificate = null; try { // Load the server certificate. certificate = new Nequeo.Security.Configuration.Reader().GetServerCredentials(); } catch { } if (certificate != null) { base.Open(certificate); } else { base.Open(); } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { string socketProviderHostPrefix = "SyslogServerSingle_"; string hostProviderFullName = socketProviderHostPrefix + "SocketProviderV6"; // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); Nequeo.Net.Configuration.Reader hostReader = new Nequeo.Net.Configuration.Reader(); // Create the syslog context list. _syslogList = new ConcurrentDictionary <string, SyslogContext>(); _syslogFiles = new ConcurrentDictionary <short, Stream>(); // Open or create the log files. OpenFiles(Message.SyslogUtility.GetPriorities()); // Create the server endpoint. Nequeo.Net.Sockets.MultiEndpointModel[] model = new Nequeo.Net.Sockets.MultiEndpointModel[] { // None secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullName).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } }, }; // Start the server. _server = new Nequeo.Net.ServerSingle(model, _maxClient); _server.OnContext += Server_OnContext; _server.Servers.OnClientDisconnected = (Provider.ISingleContextBase context) => Server_OnDisconnected(context); // Start the server. _udpServer = new Nequeo.Net.UdpServer(model, _maxClient); _udpServer.OnContext += Server_OnContext; _udpServer.Servers.OnClientDisconnected = (Nequeo.Net.Sockets.IUdpServerContext context) => ServerUdp_OnDisconnected(context); } catch (Exception) { // Close all files. CloseFiles(); if (_server != null) { _server.Dispose(); } if (_udpServer != null) { _udpServer.Dispose(); } _server = null; _udpServer = null; throw; } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { // Create the http server context list. _serverList = new ConcurrentDictionary <string, HttpServerContext>(); // Create the server endpoint. Nequeo.Net.Sockets.MultiEndpointModel[] model = new Nequeo.Net.Sockets.MultiEndpointModel[] { // None secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = Nequeo.Net.Properties.Settings.Default.HttpStaticServerListeningPort, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } }, // Secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = Nequeo.Net.Properties.Settings.Default.HttpStaticServerListeningPortSecure, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } } }; // Start the server. _httpServer = new Nequeo.Net.Http2.HttpServer(model); _httpServer.Name = "Application Server"; _httpServer.OnHttpContext += HttpContext; _httpServer.Timeout = 30; _httpServer.ReadBufferSize = 32768; _httpServer.WriteBufferSize = 32768; _httpServer.OnClientConnected = (server, context) => Server_OnConnected(server, context); _httpServer.OnClientDisconnected = (context) => Server_OnDisconnected(context); // Set the header readtimeout. _headerTimeout = _httpServer.HeaderTimeout; // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); // Inititalise. _httpServer.Initialisation(); try { // Look for the certificate information in the configuration file. // Get the certificate if any. X509Certificate2 serverCertificate = certificateReader.GetServerCredentials(); // If a certificate exists. if (serverCertificate != null) { // Get the secure servers. _httpServer.Server[2].UseSslConnection = true; _httpServer.Server[2].X509Certificate = serverCertificate; _httpServer.Server[3].UseSslConnection = true; _httpServer.Server[3].X509Certificate = serverCertificate; } } catch { } } catch (Exception) { if (_httpServer != null) { _httpServer.Dispose(); } _httpServer = null; throw; } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); Nequeo.Net.Configuration.Reader hostReader = new Nequeo.Net.Configuration.Reader(); string remoteHostPrefix = "TlsServerSingle_"; string remoteHostProviderFullName = remoteHostPrefix + "RemoteHost"; string socketProviderHostPrefix = "ProxyTlsServerSingle_"; string hostProviderFullNameSecure = socketProviderHostPrefix + "SocketProviderV6Ssl"; // If the host has not been set then get the // remote host from the configuration file. if (String.IsNullOrEmpty(_remoteHost)) { _remoteHost = hostReader.GetRemoteHost(remoteHostProviderFullName).Host; } // If the port has not been set then get the // remote port from the configuration file. if (_remotePort < 1) { _remotePort = hostReader.GetRemoteHost(remoteHostProviderFullName).Port; } // Get the data, add the remote server. _remoteServers = new ConcurrentBag <RemoteServer>(); _remoteServers.Add( new RemoteServer() { Name = _remoteHost, Host = _remoteHost, Port = _remotePort } ); // Start the server. _serverSecureV6 = new Nequeo.Net.ProxyServer(System.Net.IPAddress.IPv6Any, hostReader.GetServerHost(hostProviderFullNameSecure).Port, _remoteServers, _algorithmType); _serverSecureV6.Name = "Proxy TLS Server"; _serverSecureV6.ServiceName = "ProxyTLSServer"; _serverSecureV6.InterceptItems = _interceptItems; _serverSecureV6.Timeout = hostReader.GetServerHost(hostProviderFullNameSecure).ClientTimeOut; _serverSecureV6.ReadBufferSize = 32768; _serverSecureV6.WriteBufferSize = 32768; _serverSecureV6.ResponseBufferCapacity = 10000000; _serverSecureV6.RequestBufferCapacity = 10000000; // Start the server. _serverSecureV4 = new Nequeo.Net.ProxyServer(System.Net.IPAddress.Any, hostReader.GetServerHost(hostProviderFullNameSecure).Port, _remoteServers, _algorithmType); _serverSecureV4.Name = "Proxy TLS Server"; _serverSecureV4.ServiceName = "ProxyTLSServer"; _serverSecureV4.InterceptItems = _interceptItems; _serverSecureV4.Timeout = hostReader.GetServerHost(hostProviderFullNameSecure).ClientTimeOut; _serverSecureV4.ReadBufferSize = 32768; _serverSecureV4.WriteBufferSize = 32768; _serverSecureV4.ResponseBufferCapacity = 10000000; _serverSecureV4.RequestBufferCapacity = 10000000; // Look for the certificate information in the configuration file. // Get the certificate if any. X509Certificate2 serverCertificate = certificateReader.GetServerCredentials(); // If a certificate exists. if (serverCertificate != null) { // Get the secure servers. _serverSecureV6.UseSslConnection = true; _serverSecureV6.WaitForTlsCommand = true; _serverSecureV6.X509Certificate = serverCertificate; _serverSecureV4.UseSslConnection = true; _serverSecureV4.WaitForTlsCommand = true; _serverSecureV4.X509Certificate = serverCertificate; } } catch (Exception) { if (_serverSecureV6 != null) { _serverSecureV6.Dispose(); } if (_serverSecureV4 != null) { _serverSecureV4.Dispose(); } _serverSecureV6 = null; _serverSecureV4 = null; throw; } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { // Get the data. _remoteServers = new ConcurrentBag <RemoteServer>(); _loadServers = Data.Helper.GetLoadBalanceServer(); // For each load balance server in the file // add to the remote server collection. foreach (Nequeo.Net.Data.contextServer item in _loadServers.servers) { // Add the remote server. _remoteServers.Add( new RemoteServer() { Name = item.name, Host = item.host, Port = item.port, Secure = item.secure } ); } // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); Nequeo.Net.Configuration.Reader hostReader = new Nequeo.Net.Configuration.Reader(); string socketProviderHostPrefix = "LoadBalance_"; string hostProviderFullName = socketProviderHostPrefix + "SocketProviderV6"; string hostProviderFullNameSecure = socketProviderHostPrefix + "SocketProviderV6Ssl"; // Start the server. _serverV6 = new Nequeo.Net.ProxyServer(System.Net.IPAddress.IPv6Any, hostReader.GetServerHost(hostProviderFullName).Port, _remoteServers, _algorithmType); _serverV6.Name = "Load Balance Server"; _serverV6.ServiceName = "LoadBalanceServer"; _serverV6.InterceptItems = _interceptItems; _serverV6.Timeout = hostReader.GetServerHost(hostProviderFullName).ClientTimeOut; _serverV6.ReadBufferSize = 32768; _serverV6.WriteBufferSize = 32768; _serverV6.ResponseBufferCapacity = 10000000; _serverV6.RequestBufferCapacity = 10000000; // Start the server. _serverV4 = new Nequeo.Net.ProxyServer(System.Net.IPAddress.Any, hostReader.GetServerHost(hostProviderFullName).Port, _remoteServers, _algorithmType); _serverV4.Name = "Load Balance Server"; _serverV4.ServiceName = "LoadBalanceServer"; _serverV4.InterceptItems = _interceptItems; _serverV4.Timeout = hostReader.GetServerHost(hostProviderFullName).ClientTimeOut; _serverV4.ReadBufferSize = 32768; _serverV4.WriteBufferSize = 32768; _serverV4.ResponseBufferCapacity = 10000000; _serverV4.RequestBufferCapacity = 10000000; // Start the server. _serverSecureV6 = new Nequeo.Net.ProxyServer(System.Net.IPAddress.IPv6Any, hostReader.GetServerHost(hostProviderFullNameSecure).Port, _remoteServers, _algorithmType); _serverSecureV6.Name = "Load Balance Server"; _serverSecureV6.ServiceName = "LoadBalanceServer"; _serverSecureV6.InterceptItems = _interceptItems; _serverSecureV6.Timeout = hostReader.GetServerHost(hostProviderFullNameSecure).ClientTimeOut; _serverSecureV6.ReadBufferSize = 32768; _serverSecureV6.WriteBufferSize = 32768; _serverSecureV6.ResponseBufferCapacity = 10000000; _serverSecureV6.RequestBufferCapacity = 10000000; // Start the server. _serverSecureV4 = new Nequeo.Net.ProxyServer(System.Net.IPAddress.Any, hostReader.GetServerHost(hostProviderFullNameSecure).Port, _remoteServers, _algorithmType); _serverSecureV4.Name = "Load Balance Server"; _serverSecureV4.ServiceName = "LoadBalanceServer"; _serverSecureV4.InterceptItems = _interceptItems; _serverSecureV4.Timeout = hostReader.GetServerHost(hostProviderFullNameSecure).ClientTimeOut; _serverSecureV4.ReadBufferSize = 32768; _serverSecureV4.WriteBufferSize = 32768; _serverSecureV4.ResponseBufferCapacity = 10000000; _serverSecureV4.RequestBufferCapacity = 10000000; try { // Look for the certificate information in the configuration file. // Get the certificate if any. X509Certificate2 serverCertificate = certificateReader.GetServerCredentials(); // If a certificate exists. if (serverCertificate != null) { // Get the secure servers. _serverSecureV6.UseSslConnection = true; _serverSecureV6.X509Certificate = serverCertificate; _serverSecureV4.UseSslConnection = true; _serverSecureV4.X509Certificate = serverCertificate; } } catch { } } catch (Exception) { if (_serverV6 != null) { _serverV6.Dispose(); } if (_serverSecureV6 != null) { _serverSecureV6.Dispose(); } if (_serverV4 != null) { _serverV4.Dispose(); } if (_serverSecureV4 != null) { _serverSecureV4.Dispose(); } _serverV6 = null; _serverSecureV6 = null; _serverV4 = null; _serverSecureV4 = null; throw; } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { string socketProviderHostPrefix = "DownloadManagerServer_"; string hostProviderFullName = socketProviderHostPrefix + "SocketProviderV6"; string hostProviderFullNameSecure = socketProviderHostPrefix + "SocketProviderV6Ssl"; // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); Nequeo.Net.Configuration.Reader hostReader = new Nequeo.Net.Configuration.Reader(); // Create the server endpoint. Nequeo.Net.Sockets.MultiEndpointModel[] model = new Nequeo.Net.Sockets.MultiEndpointModel[] { // None secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullName).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } }, // Secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullNameSecure).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } } }; // Start the server. _server = new Nequeo.Net.Download.ManagerServer(_basePath, model, hostReader.GetServerHost(hostProviderFullName).MaxNumClients); _server.Timeout = hostReader.GetServerHost(hostProviderFullName).ClientTimeOut; // Set the token provider. TokenProvider tokenProvider = new TokenProvider(); tokenProvider.ServiceName = _server.ServiceName; _server.TokenProvider = tokenProvider; // Inititalise. _server.Initialisation(); try { // Look for the certificate information in the configuration file. // Get the certificate if any. X509Certificate2 serverCertificate = certificateReader.GetServerCredentials(); // If a certificate exists. if (serverCertificate != null) { // Get the secure servers. _server.Server[2].UseSslConnection = true; _server.Server[2].X509Certificate = serverCertificate; _server.Server[3].UseSslConnection = true; _server.Server[3].X509Certificate = serverCertificate; } } catch { } } catch (Exception) { if (_server != null) { _server.Dispose(); } _server = null; throw; } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { // Create the client list. _clients = new SortedDictionary <string, Nequeo.Net.Data.ConnectionContext>(); _loadServers = Data.Helper.GetLoadBalanceServer(); _contextManager = new Nequeo.Server.SingleContextManager(); string socketProviderHostPrefix = "LoadBalance_"; string hostProviderFullName = socketProviderHostPrefix + "SocketProviderV6"; string hostProviderFullNameSecure = socketProviderHostPrefix + "SocketProviderV6Ssl"; // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); Nequeo.Net.Configuration.Reader hostReader = new Nequeo.Net.Configuration.Reader(); // Create the server endpoint. Nequeo.Net.Sockets.MultiEndpointModel[] model = new Nequeo.Net.Sockets.MultiEndpointModel[] { // None secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullName).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } }, // Secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullNameSecure).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } } }; // Start the server. _server = new Nequeo.Net.WebServerSingle(model, _maxClient); _server.ServerContextManager = _contextManager; _server.Name = "Load Balance Server"; _server.ServiceName = "LoadBalanceServer"; _server.SocketProviderHostPrefix = socketProviderHostPrefix; _server.OnClientConnected = (context) => ClientConnected(context); _server.OnClientDisconnected = (context) => ClientDisconnected(context); _server.OnWebContext += Server_OnWebContext; _server.Timeout = hostReader.GetServerHost(hostProviderFullName).ClientTimeOut; _server.ReadBufferSize = 32768; _server.WriteBufferSize = 32768; _server.HeaderTimeout = 30000; _server.RequestTimeout = 30000; _server.ResponseTimeout = 30000; _server.ResponseBufferCapacity = 10000000; _server.RequestBufferCapacity = 10000000; _server.MaximumReadLength = 1000000; // Inititalise. _server.Initialisation(); try { // Look for the certificate information in the configuration file. // Get the certificate if any. X509Certificate2 serverCertificate = certificateReader.GetServerCredentials(); // If a certificate exists. if (serverCertificate != null) { // Get the secure servers. _server.Server[2].UseSslConnection = true; _server.Server[2].X509Certificate = serverCertificate; _server.Server[3].UseSslConnection = true; _server.Server[3].X509Certificate = serverCertificate; } } catch { } // For each server in the collection. for (int i = 0; i < _server.Server.NumberOfServers; i++) { // Set what needs to be polled. _server.Server[i].PollReader(true); _server.Server[i].PollWriter(false); _server.Server[i].PollError(false); } } catch (Exception) { if (_server != null) { _server.Dispose(); } _server = null; _clients = null; throw; } }
/// <summary> /// Initialise the server. /// </summary> private void Init() { try { // Create application host domain. _appHostDomain = new AppHostDomain(_basePath, _virtualDir, _configurationFile); string socketProviderHostPrefix = "HttpDynamicServerSingle_"; string hostProviderFullName = socketProviderHostPrefix + "SocketProviderV6"; string hostProviderFullNameSecure = socketProviderHostPrefix + "SocketProviderV6Ssl"; // Get the certificate reader. Nequeo.Security.Configuration.Reader certificateReader = new Nequeo.Security.Configuration.Reader(); Nequeo.Net.Configuration.Reader hostReader = new Nequeo.Net.Configuration.Reader(); // Create the server endpoint. Nequeo.Net.Sockets.MultiEndpointModel[] model = new Nequeo.Net.Sockets.MultiEndpointModel[] { // None secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullName).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } }, // Secure. new Nequeo.Net.Sockets.MultiEndpointModel() { Port = hostReader.GetServerHost(hostProviderFullNameSecure).Port, Addresses = new System.Net.IPAddress[] { System.Net.IPAddress.IPv6Any, System.Net.IPAddress.Any } } }; // Start the server. _server = new Nequeo.Net.Http.HttpServerSingle(model, hostReader.GetServerHost(hostProviderFullName).MaxNumClients); _server.Name = "Application Server"; _server.OnHttpContext += HttpContext; _server.OnClientConnected = (context) => ClientConnected(context); _server.Timeout = hostReader.GetServerHost(hostProviderFullName).ClientTimeOut; _server.ReadBufferSize = 32768; _server.WriteBufferSize = 32768; // Inititalise. _server.Initialisation(); try { // Look for the certificate information in the configuration file. // Get the certificate if any. X509Certificate2 serverCertificate = certificateReader.GetServerCredentials(); // If a certificate exists. if (serverCertificate != null) { // Get the secure servers. _server.Server[2].UseSslConnection = true; _server.Server[2].X509Certificate = serverCertificate; _server.Server[3].UseSslConnection = true; _server.Server[3].X509Certificate = serverCertificate; } } catch { } // Create the application host. _appHostDomain.CreateApplicationHost(); } catch (Exception) { if (_server != null) { _server.Dispose(); } if (_appHostDomain != null) { _appHostDomain.Dispose(); } _server = null; _appHostDomain = null; throw; } }