Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
07d5876cad
6 changed files with 46 additions and 29 deletions
  1. 5 0
      mod/webserv/webserv.go
  2. 10 0
      reverseproxy.go
  3. 12 15
      start.go
  4. 1 1
      web/components/rproot.html
  5. 13 13
      web/components/status.html
  6. 5 0
      web/main.css

+ 5 - 0
mod/webserv/webserv.go

@@ -124,6 +124,11 @@ func (ws *WebServer) ChangePort(port string) error {
 	return nil
 }
 
+// Get current using port in options
+func (ws *WebServer) GetListeningPort() string {
+	return ws.option.Port
+}
+
 // Start starts the web server.
 func (ws *WebServer) Start() error {
 	ws.mu.Lock()

+ 10 - 0
reverseproxy.go

@@ -85,6 +85,7 @@ func ReverseProxtInit() {
 
 	//Load all conf from files
 	confs, _ := filepath.Glob("./conf/proxy/*.config")
+	rootConfigExists := false
 	for _, conf := range confs {
 		record, err := LoadReverseProxyConfig(conf)
 		if err != nil {
@@ -97,6 +98,7 @@ func ReverseProxtInit() {
 				ProxyLocation: record.ProxyTarget,
 				RequireTLS:    record.UseTLS,
 			})
+			rootConfigExists = true
 		} else if record.ProxyType == "subd" {
 			dynamicProxyRouter.AddSubdomainRoutingService(&dynamicproxy.SubdOptions{
 				MatchingDomain:          record.Rootname,
@@ -124,6 +126,14 @@ func ReverseProxtInit() {
 		}
 	}
 
+	if !rootConfigExists {
+		//Root config not set (new deployment?), use internal static web server as root
+		dynamicProxyRouter.SetRootProxy(&dynamicproxy.RootOptions{
+			ProxyLocation: "127.0.0.1:" + staticWebServer.GetListeningPort(),
+			RequireTLS:    false,
+		})
+	}
+
 	//Start Service
 	//Not sure why but delay must be added if you have another
 	//reverse proxy server in front of this service

+ 12 - 15
start.go

@@ -101,6 +101,18 @@ func startupSequence() {
 	} else {
 		panic(err)
 	}
+
+	//Start the static web server
+	staticWebServer = webserv.NewWebServer(&webserv.WebServerOptions{
+		Sysdb:                  sysdb,
+		Port:                   "5487", //Default Port
+		WebRoot:                *staticWebServerRoot,
+		EnableDirectoryListing: true,
+		EnableWebDirManager:    *allowWebFileManager,
+	})
+	//Restore the web server to previous shutdown state
+	staticWebServer.RestorePreviousState()
+
 	//Create a netstat buffer
 	netstatBuffers, err = netstat.NewNetStatBuffer(300)
 	if err != nil {
@@ -220,21 +232,6 @@ func startupSequence() {
 		log.Fatal(err)
 	}
 
-	/*
-		Static Web Server
-
-		Start the static web server
-	*/
-
-	staticWebServer = webserv.NewWebServer(&webserv.WebServerOptions{
-		Sysdb:                  sysdb,
-		Port:                   "5487", //Default Port
-		WebRoot:                *staticWebServerRoot,
-		EnableDirectoryListing: true,
-		EnableWebDirManager:    *allowWebFileManager,
-	})
-	//Restore the web server to previous shutdown state
-	staticWebServer.RestorePreviousState()
 }
 
 // This sequence start after everything is initialized

+ 1 - 1
web/components/rproot.html

@@ -7,7 +7,7 @@
             <div class="field">
                 <div class="ui checkbox">
                     <input type="checkbox" id="useStaticWebServer" onchange="handleUseStaticWebServerAsRoot()">
-                    <label>Internal Static Web Server <br><small>Check this if you prefer a more Apache Web Server like experience</small></label>
+                    <label>Internal Static Web Server <br><small>Check this if you prefer a more Apache / Nginx like experience</small></label>
                 </div>
             </div>
             <div class="ui horizontal divider">OR</div>

+ 13 - 13
web/components/status.html

@@ -56,15 +56,16 @@
     <canvas id="networkActivity"></canvas>
 </div>
 <div id="networkActivityPlaceHolder">
-    <p style="opacity: 0.5;"><i class="ui pause icon"></i> Graph Render Paused</p>
+    <p style="opacity: 0.5;"> Graph Render Paused</p>
 </div>
+
 <br>
 <div class="standardContainer">
     <h4>Basic Settings</h4>
     <p>Inbound Port (Port to be proxied)</p>
     <div class="ui action fluid notloopbackOnly input">
         <input type="text" id="incomingPort" placeholder="Incoming Port" value="80">
-        <button class="ui basic green notloopbackOnly button" onclick="handlePortChange();">Apply</button>
+        <button class="ui basic notloopbackOnly button" onclick="handlePortChange();"><i class="ui green checkmark icon"></i> Apply</button>
     </div>
     <br>
     <div id="tls" class="ui toggle notloopbackOnly checkbox">
@@ -99,11 +100,9 @@
             </div>
         </div>
     </div>
-    
-    
-    <br><br>
-    <button id="startbtn" class="ui teal button" onclick="startService();">Start Service</button>
-    <button id="stopbtn" class="ui red notloopbackOnly disabled button" onclick="stopService();">Stop Service</button>
+    <br>
+    <button id="startbtn" class="ui basic button" onclick="startService();"><i class="ui green arrow alternate circle up icon"></i> Start Service</button>
+    <button id="stopbtn" class="ui basic notloopbackOnly disabled button" onclick="stopService();"><i class="ui red minus circle icon"></i> Stop Service</button>
     <div id="rploopbackWarning" class="ui segment" style="display:none;">
         <b><i class="yellow warning icon"></i> Loopback Routing Warning</b><br>
         <small>This management interface is a loopback proxied service. <br>If you want to shutdown the reverse proxy server, please remove the proxy rule for the management interface and refresh.</small>
@@ -565,6 +564,7 @@
                     options: {
                         animation: false,
                         maintainAspectRatio: false,
+                        bezierCurve: true,
                         tooltips: {enabled: false},
                         hover: {mode: null},
                         //stepped: 'middle',
@@ -606,18 +606,18 @@
                             {
                                 label: 'Inbound',
                                 data: rxValues,
-                                borderColor: "#4d9dd9",
-                                borderWidth: 2,
-                                backgroundColor: 'rgba(77, 157, 217, 0.2)',
+                                borderColor: "#484bb8",
+                                borderWidth: 1,
+                                backgroundColor: 'rgba(72, 75, 184, 0.2)',
                                 fill: true,
                                 pointStyle: false,
                             },
                             {
                                 label: 'Outbound',
                                 data: txValues,
-                                borderColor: '#ffe32b',
-                                borderWidth: 2,
-                                backgroundColor: 'rgba(255, 227, 43, 0.2)',
+                                borderColor: '#02a9c1',
+                                borderWidth: 1,
+                                backgroundColor: 'rgba(2, 169, 193, 0.2)',
                                 fill: true,
                                 pointStyle: false,
                             }

+ 5 - 0
web/main.css

@@ -7,6 +7,7 @@
     --theme_green: #3c9c63;
     --theme_fcolor: #979797;
     --theme_advance: #f8f8f9;
+    --theme_background: linear-gradient(60deg, rgb(84, 58, 183) 0%, rgb(0, 172, 193) 100%);
 }
 body{
     background-color:#f6f6f6;
@@ -96,6 +97,7 @@ body{
     margin-right: 1em;
 }
 
+
 /* Message Box */
 #messageBox{
     position: fixed;
@@ -316,6 +318,9 @@ body{
     color: #417ac1 !important;
 }
 
+.ui.inverted.table{
+    background: var(--theme_background);
+}
 
 @keyframes blinker {
     50% {