Changeset 398
- Timestamp:
- Aug 14, 2022, 8:12:46 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/Web.cs
r394 r398 28 28 int webPort = GamePrefs.GetInt (EnumUtils.Parse<EnumGamePrefs> ("ControlPanelPort")); 29 29 if (webPort < 1 || webPort > 65533) { 30 Log.Out (" Webserver not started (ControlPanelPort not within 1-65533)");30 Log.Out ("[Web] Webserver not started (ControlPanelPort not within 1-65533)"); 31 31 return; 32 32 } … … 36 36 37 37 if (!HttpListener.IsSupported) { 38 Log.Out (" Webserver not started (needs Windows XP SP2, Server 2003 or later or Mono)");38 Log.Out ("[Web] Webserver not started (HttpListener.IsSupported returned false)"); 39 39 return; 40 40 } … … 43 43 bool useStaticCache = false; 44 44 45 string webfilesFolder = _modInstancePath + "/webserver";45 string webfilesFolder = DetectWebserverFolder (_modInstancePath); 46 46 string webfilesFolderLegacy = _modInstancePath + "/weblegacy"; 47 47 … … 87 87 SdtdConsole.Instance.RegisterServer (this); 88 88 89 Log.Out (" Started Webserver on" + webPort);89 Log.Out ("[Web] Started Webserver on port " + webPort); 90 90 } catch (Exception e) { 91 Log.Error (" Error in Web.ctor: ");91 Log.Error ("[Web] Error in Web.ctor: "); 92 92 Log.Exception (e); 93 93 } 94 } 95 96 private static string DetectWebserverFolder (string _modInstancePath) { 97 string webserverFolder = _modInstancePath + "/webserver"; 98 99 foreach (Mod mod in ModManager.GetLoadedMods ()) { 100 string modServerFolder = mod.Path + "/webserver"; 101 102 if (Directory.Exists (modServerFolder)) { 103 webserverFolder = modServerFolder; 104 } 105 } 106 107 Log.Out ($"[Web] Serving basic webserver files from {webserverFolder}"); 108 109 return webserverFolder; 94 110 } 95 111 … … 100 116 } 101 117 102 Log.Error ($" Web:Handler for relative path {_urlBasePath} already registerd.");118 Log.Error ($"[Web] Handler for relative path {_urlBasePath} already registerd."); 103 119 return; 104 120 } … … 120 136 webMods.Add (webMod); 121 137 } catch (InvalidDataException e) { 122 Log.Error ($" Could not load webmod from mod {mod.ModInfo.Name.Value}: {e.Message}");138 Log.Error ($"[Web] Could not load webmod from mod {mod.ModInfo.Name.Value}: {e.Message}"); 123 139 } 124 140 } catch (Exception e) { 125 Log.Error (" Failed loading web mods from mod " + mod.ModInfo.Name.Value);141 Log.Error ("[Web] Failed loading web mods from mod " + mod.ModInfo.Name.Value); 126 142 Log.Exception (e); 127 143 } … … 134 150 listener.Close (); 135 151 } catch (Exception e) { 136 Log.Out (" Error in Web.Disconnect: " + e);152 Log.Out ("[Web] Error in Web.Disconnect: " + e); 137 153 } 138 154 } … … 222 238 } catch (IOException e) { 223 239 if (e.InnerException is SocketException) { 224 Log.Out (" Error in Web.HandleRequest(): Remote host closed connection: " + e.InnerException.Message);240 Log.Out ("[Web] Error in Web.HandleRequest(): Remote host closed connection: " + e.InnerException.Message); 225 241 } else { 226 Log.Out (" Error (IO) in Web.HandleRequest(): " + e);242 Log.Out ("[Web] Error (IO) in Web.HandleRequest(): " + e); 227 243 } 228 244 } catch (Exception e) { 229 Log.Error (" Error in Web.HandleRequest(): ");245 Log.Error ("[Web] Error in Web.HandleRequest(): "); 230 246 Log.Exception (e); 231 247 } finally { … … 276 292 IPEndPoint reqRemoteEndPoint = _req.RemoteEndPoint; 277 293 if (reqRemoteEndPoint == null) { 278 Log.Warning (" No RemoteEndPoint on web request");294 Log.Warning ("[Web] No RemoteEndPoint on web request"); 279 295 return guestPermissionLevel; 280 296 } … … 297 313 } 298 314 299 Log.Warning (" Invalid Admintoken used from " + reqRemoteEndPoint);315 Log.Warning ("[Web] Invalid Admintoken used from " + reqRemoteEndPoint); 300 316 301 317 return guestPermissionLevel;
Note:
See TracChangeset
for help on using the changeset viewer.