Browse Source

auto update script executed

TC pushbot 5 3 years ago
parent
commit
392e3a81a2
3 changed files with 74 additions and 8 deletions
  1. 5 1
      mod/dynamicproxy/dynamicproxy.go
  2. 4 2
      reverseproxy.go
  3. 65 5
      web/index.html

+ 5 - 1
mod/dynamicproxy/dynamicproxy.go

@@ -112,11 +112,15 @@ func (router *Router) StopProxyService() error {
 /*
 /*
 	Add an URL into a custom proxy services
 	Add an URL into a custom proxy services
 */
 */
-func (router *Router) AddProxyService(rootname string, domain string, requireTLS bool) error {
+func (router *Router) AddVirtualDirectoryProxyService(rootname string, domain string, requireTLS bool) error {
 	if domain[len(domain)-1:] == "/" {
 	if domain[len(domain)-1:] == "/" {
 		domain = domain[:len(domain)-1]
 		domain = domain[:len(domain)-1]
 	}
 	}
 
 
+	if rootname[len(rootname)-1:] == "/" {
+		rootname = rootname[:len(rootname)-1]
+	}
+
 	webProxyEndpoint := domain
 	webProxyEndpoint := domain
 	if requireTLS {
 	if requireTLS {
 		webProxyEndpoint = "https://" + webProxyEndpoint
 		webProxyEndpoint = "https://" + webProxyEndpoint

+ 4 - 2
reverseproxy.go

@@ -28,8 +28,10 @@ func ReverseProxtInit() {
 	http.HandleFunc("/list", ReverseProxyList)
 	http.HandleFunc("/list", ReverseProxyList)
 
 
 	dynamicProxyRouter.SetRootProxy("192.168.0.107:8080", false)
 	dynamicProxyRouter.SetRootProxy("192.168.0.107:8080", false)
-	dynamicProxyRouter.AddSubdomainRoutingService("ixtw.localhost", "192.168.0.71:8082", false)
+	dynamicProxyRouter.AddSubdomainRoutingService("aroz.localhost", "192.168.0.107:8080/private/AOB/", false)
 	dynamicProxyRouter.AddSubdomainRoutingService("loopback.localhost", "localhost:8080", false)
 	dynamicProxyRouter.AddSubdomainRoutingService("loopback.localhost", "localhost:8080", false)
+	dynamicProxyRouter.AddSubdomainRoutingService("git.localhost", "mc.alanyeung.co:3000", false)
+	dynamicProxyRouter.AddVirtualDirectoryProxyService("/git/server/", "mc.alanyeung.co:3000", false)
 	dynamicProxyRouter.StartProxyService()
 	dynamicProxyRouter.StartProxyService()
 	/*
 	/*
 		go func() {
 		go func() {
@@ -87,7 +89,7 @@ func ReverseProxyHandleAddEndpoint(w http.ResponseWriter, r *http.Request) {
 			sendErrorResponse(w, "vdir not defined")
 			sendErrorResponse(w, "vdir not defined")
 			return
 			return
 		}
 		}
-		dynamicProxyRouter.AddProxyService(vdir, endpoint, useTLS)
+		dynamicProxyRouter.AddVirtualDirectoryProxyService(vdir, endpoint, useTLS)
 
 
 	} else if eptype == "subd" {
 	} else if eptype == "subd" {
 		subdomain, err := mv(r, "subdomain", true)
 		subdomain, err := mv(r, "subdomain", true)

+ 65 - 5
web/index.html

@@ -76,7 +76,7 @@
                                     <th>Remove</th>
                                     <th>Remove</th>
                                 </tr>
                                 </tr>
                             </thead>
                             </thead>
-                            <tbody>
+                            <tbody id="vdirList">
                                 <tr>
                                 <tr>
                                     <td data-label="">test</td>
                                     <td data-label="">test</td>
                                     <td data-label="">test</td>
                                     <td data-label="">test</td>
@@ -96,7 +96,7 @@
                                     <th>Remove</th>
                                     <th>Remove</th>
                                 </tr>
                                 </tr>
                             </thead>
                             </thead>
-                            <tbody>
+                            <tbody id="subdList">
                                
                                
                             </tbody>
                             </tbody>
                         </table>
                         </table>
@@ -125,14 +125,15 @@
                                     <input type="text" name="first-name" placeholder="First Name">
                                     <input type="text" name="first-name" placeholder="First Name">
                                     <div class="ui message">
                                     <div class="ui message">
                                         Example of subdomain matching keyword:<br>
                                         Example of subdomain matching keyword:<br>
-                                        <code>s1.arozos.com</code> (Any access starting with s1.arozos.com will be proxy to the IP address below)<br>
+                                        <code>s1.arozos.com</code> <br>(Any access starting with s1.arozos.com will be proxy to the IP address below)<br>
                                         Example of virtual directory name: <br>
                                         Example of virtual directory name: <br>
-                                        <code>s1</code> (Any access to {this_server}/s1/ will be proxy to the IP address below)
+                                        <code>/s1/home</code> <br>(Any access to {this_server}/s1/ will be proxy to the IP address below)
                                     </div>
                                     </div>
                                 </div>
                                 </div>
                                 <div class="field">
                                 <div class="field">
-                                    <label>Last Name</label>
+                                    <label>IP Address or Domain Name with port</label>
                                     <input type="text" name="last-name" placeholder="Last Name">
                                     <input type="text" name="last-name" placeholder="Last Name">
+                                    <small>E.g. 192.168.0.101:8000 or example.com</small>
                                 </div>
                                 </div>
                                 
                                 
                                 <button class="ui teal button" type="submit">Create Proxy Endpoint</button>
                                 <button class="ui teal button" type="submit">Create Proxy Endpoint</button>
@@ -208,6 +209,65 @@
                 });
                 });
             }
             }
 
 
+            //Virtual directories functions
+            listVdirs();
+            function listVdirs(){
+                $("#vdirList").html(``);
+                $.get("list?type=vdir", function(data){
+                    if (data.error !== undefined){
+                         $("#vdirList").append(`<tr>
+                            <td data-label="" colspan="3"><i class="remove icon"></i> ${data.error}</td>
+                        </tr>`);
+                    }else if (data.length == 0){
+                        $("#vdirList").append(`<tr>
+                            <td data-label="" colspan="3"><i class="question icon"></i> No Virtual Directory Record</td>
+                        </tr>`);
+                    }else{
+                        data.forEach(vdir => {
+                            let tlsIcon = "";
+                            if (vdir.RequireTLS){
+                                tlsIcon = `<i class="lock icon"></i>`;
+                            }
+                            $("#vdirList").append(`<tr>
+                                <td data-label="">${vdir.Root}</td>
+                                <td data-label="">${vdir.Domain} ${tlsIcon}</td>
+                                <td data-label=""><button class="ui circular mini red basic button"><i class="remove icon"></i> Remove Vdir</button></td>
+                            </tr>`);
+                        });
+                    }
+                });
+            }
+
+            initSubdomainProxy();
+            function initSubdomainProxy(){
+                $("#subdList").html(``);
+                $.get("list?type=subd", function(data){
+                    if (data.error !== undefined){
+                         $("#subdList").append(`<tr>
+                            <td data-label="" colspan="3"><i class="remove icon"></i> ${data.error}</td>
+                        </tr>`);
+                    }else if (data.length == 0){
+                        $("#subdList").append(`<tr>
+                            <td data-label="" colspan="3"><i class="question icon"></i> No Subdomain Proxy Record</td>
+                        </tr>`);
+                    }else{
+                        data.forEach(subd => {
+                            let tlsIcon = "";
+                            if (subd.RequireTLS){
+                                tlsIcon = `<i class="lock icon"></i>`;
+                            }
+                            $("#subdList").append(`<tr>
+                                <td data-label="">${subd.MatchingDomain}</td>
+                                <td data-label="">${subd.Domain} ${tlsIcon}</td>
+                                <td data-label=""><button class="ui circular mini red basic button"><i class="remove icon"></i> Remove Subd</button></td>
+                            </tr>`);
+                        });
+                    }
+                });
+            }
+
+
+
             function errmsg(message){
             function errmsg(message){
                 $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
                 $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
                 $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
                 $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');