public static void GenerateSettings() { //web server settings Settings.Get()["General"] = new Settings.Header { { "Version", Assembly.GetExecutingAssembly().GetName().Version }, { "RunStartup", true }, { "UploadLogs", true }, { "Github", "https://github.com/Ulterius" }, { "ServerIssues", "https://github.com/Ulterius/server/issues" }, { "ClientIssues", "https://github.com/Ulterius/client/issues" }, { //this is kind of nasty "Maintainers", new[] { new { Name = "Andrew Sampson", Twitter = "https://twitter.com/Andrewmd5", Github = "https://github.com/codeusa", Website = "https://andrew.im/" }, new { Name = "Evan Banyash", Twitter = "https://twitter.com/frobthebuilder", Github = "https://github.com/FrobtheBuilder", Website = "http://banyash.com/" } } } }; Settings.Get()["WebServer"] = new Settings.Header { { "WebFilePath", HttpServer.DefaultPath }, { "WebServerPort", 22006 }, { "ToggleWebServer", true } }; Settings.Get()["TaskServer"] = new Settings.Header { { "TaskServerPort", 22007 }, { "Encryption", true } }; Settings.Get()["Network"] = new Settings.Header { { "SkipHostNameResolve", false }, { "UpnpEnabled", true }, { "BindLocal", false } }; Settings.Get()["Plugins"] = new Settings.Header { { "LoadPlugins", true } }; Settings.Get()["ScreenShareService"] = new Settings.Header { { "ScreenSharePort", 22009 } }; Settings.Get()["Terminal"] = new Settings.Header { { "AllowTerminal", true }, { "TerminalPort", 22008 } }; Settings.Get()["Webcams"] = new Settings.Header { { "UseWebcams", true }, { "WebcamPort", 22010 } }; Settings.Get()["Debug"] = new Settings.Header { { "TraceDebug", true } }; Settings.Save(); }
public static void ForwardPorts(PortMapper type = PortMapper.Upnp, bool retry = false) { var webServerPort = (int)Settings.Get("WebServer").WebServerPort; var apiPort = (int)Settings.Get("TaskServer").TaskServerPort; var webCamPort = (int)Settings.Get("Webcams").WebcamPort; var terminalPort = (int)Settings.Get("Terminal").TerminalPort; var screenSharePort = (int)Settings.Get("ScreenShareService").ScreenSharePort; var nat = new NatDiscoverer(); var cts = new CancellationTokenSource(); cts.CancelAfter(5000); NatDevice device; var t = nat.DiscoverDeviceAsync(type, cts); t.ContinueWith(tt => { device = tt.Result; device.GetExternalIPAsync() .ContinueWith(task => { ; return(device.CreatePortMapAsync( new Mapping(Protocol.Tcp, webServerPort, webServerPort, 0, "Ulterius Web Server"))); }) .Unwrap() .ContinueWith(task => { return(device.CreatePortMapAsync( new Mapping(Protocol.Tcp, screenSharePort, screenSharePort, 0, "Ulterius Screen Share"))); }) .Unwrap() .ContinueWith(task => { return(device.CreatePortMapAsync( new Mapping(Protocol.Tcp, apiPort, apiPort, 0, "Ulterius Api"))); }) .Unwrap() .ContinueWith(task => { return(device.CreatePortMapAsync( new Mapping(Protocol.Tcp, webCamPort, webCamPort, 0, "Ulterius Webcams"))); }) .Unwrap() .ContinueWith(task => { return(device.CreatePortMapAsync( new Mapping(Protocol.Tcp, terminalPort, terminalPort, 0, "Ulterius Terminal"))); }) .Unwrap() .ContinueWith(task => { Console.WriteLine("Ports forwarded!"); }); }, TaskContinuationOptions.OnlyOnRanToCompletion); try { t.Wait(); } catch (AggregateException e) { if (e.InnerException is NatDeviceNotFoundException) { if (retry) { return; } ForwardPorts(PortMapper.Pmp, true); Console.WriteLine("No NAT Device Found"); } } }
public static void ConfigureServer() { if (Settings.Empty) { //setup listen sh var prefix = "http://*:22006/"; var username = Environment.GetEnvironmentVariable("USERNAME"); var userdomain = Environment.GetEnvironmentVariable("USERDOMAIN"); var command = $@"/C netsh http add urlacl url={prefix} user={userdomain}\{username} listen=yes"; Process.Start("CMD.exe", command); OpenPort(22006, "Ulterius Web Server"); OpenPort(22007, "Ulterius Task Server"); OpenPort(22008, "Ulterius Terminal Server"); OpenPort(22009, "Ulterius ScreenShare"); //web server settings Settings.Get()["General"] = new Settings.Header { { "Version", Assembly.GetExecutingAssembly().GetName().Version }, { "UploadLogs", false }, { "Github", "https://github.com/Ulterius" }, { "ServerIssues", "https://github.com/Ulterius/server/issues" }, { "ClientIssues", "https://github.com/Ulterius/client/issues" }, { //this is kind of nasty "Maintainers", new[] { new { Name = "Andrew Sampson", Twitter = "https://twitter.com/Andrewmd5", Github = "https://github.com/codeusa", Website = "https://andrew.im/" }, new { Name = "Evan Banyash", Twitter = "https://twitter.com/frobthebuilder", Github = "https://github.com/FrobtheBuilder", Website = "http://banyash.com/" } } } }; Settings.Get()["WebServer"] = new Settings.Header { { "WebFilePath", HttpServer.DefaultPath }, { "WebServerPort", 22006 }, { "UseWebServer", true } }; Settings.Get()["TaskServer"] = new Settings.Header { { "TaskServerPort", 22007 }, { "Encryption", true } }; Settings.Get()["Network"] = new Settings.Header { { "SkipHostNameResolve", false } }; Settings.Get()["Plugins"] = new Settings.Header { { "LoadPlugins", true } }; Settings.Get()["ScreenShare"] = new Settings.Header { { "ScreenSharePass", string.Empty }, { "ScreenSharePort", 22009 } }; Settings.Get()["Terminal"] = new Settings.Header { { "AllowTerminal", true } }; Settings.Get()["Debug"] = new Settings.Header { { "TraceDebug", true } }; Settings.Save(); } }