Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
38cfff7b66
5 changed files with 67 additions and 13 deletions
  1. 2 2
      main.go
  2. 22 0
      mod/forwardproxy/forwardproxy.go
  3. 9 3
      start.go
  4. 18 1
      web/components/networktools.html
  5. 16 7
      web/components/utils.html

+ 2 - 2
main.go

@@ -49,9 +49,9 @@ var logOutputToFile = flag.Bool("log", true, "Log terminal output to file")
 
 var (
 	name        = "Zoraxy"
-	version     = "3.0.0"
+	version     = "3.0.1"
 	nodeUUID    = "generic"
-	development = false //Set this to false to use embedded web fs
+	development = true //Set this to false to use embedded web fs
 	bootTime    = time.Now().Unix()
 
 	/*

+ 22 - 0
mod/forwardproxy/forwardproxy.go

@@ -0,0 +1,22 @@
+package forwardproxy
+
+import (
+	"fmt"
+	"net/http"
+
+	"imuslab.com/zoraxy/mod/auth"
+)
+
+type ZrFilter struct {
+	auth *auth.AuthAgent
+}
+
+type Handler struct {
+	Port int
+}
+
+func (it ZrFilter) IsAuthorized(w http.ResponseWriter, r *http.Request) bool {
+	u, p, ok := r.BasicAuth()
+	fmt.Println(u, p, ok)
+	return true
+}

+ 9 - 3
start.go

@@ -13,6 +13,7 @@ import (
 	"imuslab.com/zoraxy/mod/auth"
 	"imuslab.com/zoraxy/mod/database"
 	"imuslab.com/zoraxy/mod/dynamicproxy/redirection"
+	"imuslab.com/zoraxy/mod/forwardproxy"
 	"imuslab.com/zoraxy/mod/forwardproxy/cproxy"
 	"imuslab.com/zoraxy/mod/ganserv"
 	"imuslab.com/zoraxy/mod/geodb"
@@ -244,7 +245,12 @@ func finalSequence() {
 	//Inject routing rules
 	registerBuildInRoutingRules()
 
-	fmt.Println("Running debug forward web proxy")
-	handler := cproxy.New()
-	http.ListenAndServe(":8088", handler)
+	go func() {
+		fmt.Println("Running debug forward web proxy")
+		thisFilter := forwardproxy.ZrFilter{}
+		handler := cproxy.New(cproxy.Options.Filter(thisFilter))
+		http.ListenAndServe(":8088", handler)
+
+	}()
+
 }

+ 18 - 1
web/components/networktools.html

@@ -84,7 +84,24 @@
                 Paste to Terminal <code style="float: right;">Shift + Insert</code>
             </div>
         </div>
-       
+        <div class="ui divider"></div>
+        <h2>Forward Proxy</h2>
+        <p>Setup a basic HTTP forward proxy to access web server in another LAN<br>
+        To enable forward proxy in your domain, add a proxy rule to 127.0.0.1:{selected_port}</p>
+        <form class="ui form">
+            <div class="field">
+                <label>Listening Port</label>
+                <input type="number" placeholder="5587" value="5587">
+            </div>
+            <div class="field">
+                <div class="ui toggle checkbox">
+                    <input type="checkbox" tabindex="0" class="hidden">
+                    <label>Enable Forward Proxy<br>
+                    <small>Start HTTP Forward Proxy Listener</small></label>
+                </div>
+            </div>
+            <button class="ui basic circular button"><i class="ui green check icon"></i> Apply Change</button>
+        </form>
         <div class="ui divider"></div>
         <h2>Wake On LAN</h2>
         <p>Wake up a remote server by WOL Magic Packet or an IoT device</p>

+ 16 - 7
web/components/utils.html

@@ -4,12 +4,12 @@
         <p>You might find these tools or information helpful when setting up your gateway server</p>
     </div>
     <div class="ui top attached tabular menu">
-        <a class="nettools item active" data-tab="tab1"><i class="ui user circle blue icon"></i> Accounts</a>
-        <a class="nettools item" data-tab="tab2">Toolbox</a>
-        <a class="nettools item" data-tab="tab3">System</a>
+        <a class="utils item active" data-tab="utiltab1"><i class="ui user circle blue icon"></i> Accounts</a>
+        <a class="utils item" data-tab="utiltab2">Toolbox</a>
+        <a class="utils item" data-tab="utiltab3">System</a>
     </div>
 
-    <div class="ui bottom attached tab segment nettoolstab active" data-tab="tab1">
+    <div class="ui bottom attached tab segment utilitiesTabs active" data-tab="utiltab1">
         <div class="extAuthOnly" style="display:none;">
             <div class="ui basic segment">
                 <i class="ui green circle check icon"></i> Account options are not available due to -noauth flag is set to true.
@@ -99,7 +99,7 @@
             </form>
         </div>
     </div>
-    <div class="ui bottom attached tab segment nettoolstab" data-tab="tab2">
+    <div class="ui bottom attached tab segment utilitiesTabs" data-tab="utiltab2">
         <h3> IP Address to CIDR</h3>
         <p>No experience with CIDR notations? Here are some tools you can use to make setting up easier.</p>
         <div class="ui basic segment">
@@ -128,7 +128,7 @@
         </div>
         <div class="ui divider"></div>
     </div>
-    <div class="ui bottom attached tab segment nettoolstab" data-tab="tab3">
+    <div class="ui bottom attached tab segment utilitiesTabs" data-tab="utiltab3">
         <!-- Config Tools -->
         <h3>System Backup & Restore</h3>
         <p>Options related to system backup, migrate and restore.</p>
@@ -175,7 +175,16 @@
     <br>
 </div>
 <script>
-    $('.menu .nettools.item').tab();
+    $('.menu .utils.item').tab();
+    // Switch tabs when clicking on the menu items
+    $('.menu .utils.item').on('click', function() {
+        $('.menu .utils.item').removeClass('active');
+        $(this).addClass('active');
+        var tab = $(this).attr('data-tab');
+        $('.utilitiesTabs.tab.segment').removeClass('active');
+        $('div[data-tab="' + tab + '"]').addClass('active');
+    }); 
+
     /*
         Account Password utilities
     */