浏览代码

auto update script executed

tobychui 1 年之前
父节点
当前提交
7da34f69bc

+ 3 - 3
api.go

@@ -4,8 +4,8 @@ import (
 	"encoding/json"
 	"net/http"
 
-	"imuslab.com/Zoraxy/mod/auth"
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/auth"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 /*
@@ -70,7 +70,7 @@ func initAPIs() {
 
 	//Statistic API
 	authRouter.HandleFunc("/api/stats/summary", statisticCollector.HandleTodayStatLoad)
-
+	authRouter.HandleFunc("/api/stats/countries", HandleCountryDistrSummary)
 	//Upnp
 	authRouter.HandleFunc("/api/upnp/discover", handleUpnpDiscover)
 	//If you got APIs to add, append them here

+ 1 - 1
blacklist.go

@@ -4,7 +4,7 @@ import (
 	"encoding/json"
 	"net/http"
 
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 /*

+ 1 - 1
cert.go

@@ -9,7 +9,7 @@ import (
 	"os"
 	"path/filepath"
 
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 // Check if the default certificates is correctly setup

+ 1 - 1
config.go

@@ -8,7 +8,7 @@ import (
 	"path/filepath"
 	"strings"
 
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 type Record struct {

+ 1 - 1
go.mod

@@ -1,4 +1,4 @@
-module imuslab.com/Zoraxy
+module imuslab.com/zoraxy
 
 go 1.16
 

+ 38 - 0
handlers.go

@@ -0,0 +1,38 @@
+package main
+
+import (
+	"encoding/json"
+	"net/http"
+
+	"imuslab.com/zoraxy/mod/utils"
+)
+
+func HandleCountryDistrSummary(w http.ResponseWriter, r *http.Request) {
+	requestClientCountry := map[string]int{}
+	statisticCollector.DailySummary.RequestClientIp.Range(func(key, value interface{}) bool {
+		//Get this client country of original
+		clientIp := key.(string)
+		//requestCount := value.(int)
+
+		ci, err := geodbStore.ResolveCountryCodeFromIP(clientIp)
+		if err != nil {
+			return true
+		}
+
+		isoCode := ci.CountryIsoCode
+		if isoCode == "" {
+			isoCode = "Local"
+		}
+		uc, ok := requestClientCountry[isoCode]
+		if !ok {
+			//Create the counter
+			requestClientCountry[isoCode] = 1
+		} else {
+			requestClientCountry[isoCode] = uc + 1
+		}
+		return true
+	})
+
+	js, _ := json.Marshal(requestClientCountry)
+	utils.SendJSONResponse(w, string(js))
+}

+ 8 - 8
main.go

@@ -10,14 +10,14 @@ import (
 	"syscall"
 	"time"
 
-	"imuslab.com/Zoraxy/mod/aroz"
-	"imuslab.com/Zoraxy/mod/auth"
-	"imuslab.com/Zoraxy/mod/database"
-	"imuslab.com/Zoraxy/mod/dynamicproxy/redirection"
-	"imuslab.com/Zoraxy/mod/geodb"
-	"imuslab.com/Zoraxy/mod/statistic"
-	"imuslab.com/Zoraxy/mod/tlscert"
-	"imuslab.com/Zoraxy/mod/upnp"
+	"imuslab.com/zoraxy/mod/aroz"
+	"imuslab.com/zoraxy/mod/auth"
+	"imuslab.com/zoraxy/mod/database"
+	"imuslab.com/zoraxy/mod/dynamicproxy/redirection"
+	"imuslab.com/zoraxy/mod/geodb"
+	"imuslab.com/zoraxy/mod/statistic"
+	"imuslab.com/zoraxy/mod/tlscert"
+	"imuslab.com/zoraxy/mod/upnp"
 )
 
 //General flags

+ 2 - 2
mod/auth/auth.go

@@ -17,8 +17,8 @@ import (
 	"log"
 
 	"github.com/gorilla/sessions"
-	db "imuslab.com/Zoraxy/mod/database"
-	"imuslab.com/Zoraxy/mod/utils"
+	db "imuslab.com/zoraxy/mod/database"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 type AuthAgent struct {

+ 8 - 2
mod/dynamicproxy/Server.go

@@ -5,7 +5,7 @@ import (
 	"os"
 	"strings"
 
-	"imuslab.com/Zoraxy/mod/geodb"
+	"imuslab.com/zoraxy/mod/geodb"
 )
 
 /*
@@ -57,10 +57,16 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 
 	//Clean up the request URI
 	proxyingPath := strings.TrimSpace(r.RequestURI)
-
 	targetProxyEndpoint := h.Parent.getTargetProxyEndpointFromRequestURI(proxyingPath)
 	if targetProxyEndpoint != nil {
 		h.proxyRequest(w, r, targetProxyEndpoint)
+	} else if !strings.HasSuffix(proxyingPath, "/") {
+		potentialProxtEndpoint := h.Parent.getTargetProxyEndpointFromRequestURI(proxyingPath + "/")
+		if potentialProxtEndpoint != nil {
+			h.proxyRequest(w, r, potentialProxtEndpoint)
+		} else {
+			h.proxyRequest(w, r, h.Parent.Root)
+		}
 	} else {
 		h.proxyRequest(w, r, h.Parent.Root)
 	}

+ 6 - 6
mod/dynamicproxy/dynamicproxy.go

@@ -13,12 +13,12 @@ import (
 	"sync"
 	"time"
 
-	"imuslab.com/Zoraxy/mod/dynamicproxy/dpcore"
-	"imuslab.com/Zoraxy/mod/dynamicproxy/redirection"
-	"imuslab.com/Zoraxy/mod/geodb"
-	"imuslab.com/Zoraxy/mod/reverseproxy"
-	"imuslab.com/Zoraxy/mod/statistic"
-	"imuslab.com/Zoraxy/mod/tlscert"
+	"imuslab.com/zoraxy/mod/dynamicproxy/dpcore"
+	"imuslab.com/zoraxy/mod/dynamicproxy/redirection"
+	"imuslab.com/zoraxy/mod/geodb"
+	"imuslab.com/zoraxy/mod/reverseproxy"
+	"imuslab.com/zoraxy/mod/statistic"
+	"imuslab.com/zoraxy/mod/tlscert"
 )
 
 /*

+ 3 - 3
mod/dynamicproxy/proxyRequestHandler.go

@@ -8,9 +8,9 @@ import (
 	"net/url"
 	"strings"
 
-	"imuslab.com/Zoraxy/mod/geodb"
-	"imuslab.com/Zoraxy/mod/statistic"
-	"imuslab.com/Zoraxy/mod/websocketproxy"
+	"imuslab.com/zoraxy/mod/geodb"
+	"imuslab.com/zoraxy/mod/statistic"
+	"imuslab.com/zoraxy/mod/websocketproxy"
 )
 
 func (router *Router) getTargetProxyEndpointFromRequestURI(requestURI string) *ProxyEndpoint {

+ 1 - 1
mod/dynamicproxy/redirection/redirection.go

@@ -9,7 +9,7 @@ import (
 	"strings"
 	"sync"
 
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 type RuleTable struct {

+ 1 - 1
mod/dynamicproxy/subdomain.go

@@ -4,7 +4,7 @@ import (
 	"log"
 	"net/url"
 
-	"imuslab.com/Zoraxy/mod/reverseproxy"
+	"imuslab.com/zoraxy/mod/reverseproxy"
 )
 
 /*

+ 1 - 1
mod/geodb/geodb.go

@@ -6,7 +6,7 @@ import (
 	"strings"
 
 	"github.com/oschwald/geoip2-golang"
-	"imuslab.com/Zoraxy/mod/database"
+	"imuslab.com/zoraxy/mod/database"
 )
 
 type Store struct {

+ 1 - 1
mod/statistic/handler.go

@@ -4,7 +4,7 @@ import (
 	"encoding/json"
 	"net/http"
 
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 /*

+ 1 - 1
mod/statistic/statistic.go

@@ -5,7 +5,7 @@ import (
 	"sync"
 	"time"
 
-	"imuslab.com/Zoraxy/mod/database"
+	"imuslab.com/zoraxy/mod/database"
 )
 
 /*

+ 1 - 1
mod/tlscert/tlscert.go

@@ -11,7 +11,7 @@ import (
 	"path/filepath"
 	"strings"
 
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 type Manager struct {

+ 1 - 1
redirect.go

@@ -5,7 +5,7 @@ import (
 	"net/http"
 	"strconv"
 
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 /*

+ 2 - 2
reverseproxy.go

@@ -10,8 +10,8 @@ import (
 	"strings"
 	"time"
 
-	"imuslab.com/Zoraxy/mod/dynamicproxy"
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/dynamicproxy"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 var (

+ 2 - 2
upnp.go

@@ -9,8 +9,8 @@ import (
 	"strconv"
 	"time"
 
-	"imuslab.com/Zoraxy/mod/upnp"
-	"imuslab.com/Zoraxy/mod/utils"
+	"imuslab.com/zoraxy/mod/upnp"
+	"imuslab.com/zoraxy/mod/utils"
 )
 
 var upnpEnabled = false

+ 64 - 6
web/components/status.html

@@ -27,10 +27,12 @@
         <div class="column">
             <div id="connections" class="ui yellow statustab inverted segment">
                 <h4 class="ui header">
-                    <i class="exchange icon"></i>
+                    <i class="arrows alternate horizontal icon"></i>
                     <div class="content">
-                      <span></span>
-                      <div class="sub header"></div>
+                      <span id="forwardtype"></span>
+                      <div class="sub header" id="forwardtypeList">
+
+                      </div>
                     </div>
                 </h4>
             </div>
@@ -38,10 +40,12 @@
         <div class="column">
             <div id="connections" class="ui pink statustab inverted segment">
                 <h4 class="ui header">
-                    <i class="exchange icon"></i>
+                    <i class="map marker alternate icon"></i>
                     <div class="content">
-                      <span></span>
-                      <div class="sub header"></div>
+                      <span id="country"></span>
+                      <div class="sub header" id="countryList">
+
+                      </div>
                     </div>
                 </h4>
             </div>
@@ -161,6 +165,60 @@
         return newValue + suffixes[suffixNum];
     }
 
+    function getDailySummaryDetails(){
+        function sortObjectByValue(obj) {
+            // Convert object to array of [key, value] pairs
+            const entries = Object.entries(obj);
+            
+            // Sort array based on value of each pair
+            entries.sort((a, b) => {
+                return a[1] - b[1];
+            });
+            
+            // Convert sorted array back to object
+            const sortedObj = {};
+            for (const [key, value] of entries) {
+                sortedObj[key] = value;
+            }
+            
+            return sortedObj;
+        }
+
+        $.get("/api/stats/countries", function(data){
+            data = sortObjectByValue(data);
+            $("#country").text(Object.keys(data)[0] + ": " +data[Object.keys(data)[0]]);
+            $("#countryList").html(`
+            <div style="color: white;">
+                ${(Object.keys(data)[1])?Object.keys(data)[1] + ": " +data[Object.keys(data)[1]]:"-"}<br>
+                ${(Object.keys(data)[2])?Object.keys(data)[2] + ": " +data[Object.keys(data)[2]]:"-"}
+            </div>
+            `);
+        });
+
+        //Filter forward type
+        function fft(ft){
+            if (ft.indexOf("-") >= 0){
+                ft = ft.replace("-", " (");
+                ft = ft + ")";
+            }
+
+            ft = ft.charAt(0).toUpperCase() + ft.slice(1);
+            return ft;
+        }
+
+        $.get("/api/stats/summary", function(data){
+            data = sortObjectByValue(data.ForwardTypes);
+            $("#forwardtype").text(fft(Object.keys(data)[0]));
+            $("#forwardtypeList").html(`
+            <div style="color: white;">
+                ${(Object.keys(data)[1])?fft(Object.keys(data)[1]) + ": " +data[Object.keys(data)[1]]:"-"}<br>
+                ${(Object.keys(data)[2])?fft(Object.keys(data)[2]) + ": " +data[Object.keys(data)[2]]:"-"}
+            </div>
+            `);
+        });
+    }
+    getDailySummaryDetails();
+
 
     function getDailySummary(){
         $.get("/api/stats/summary?fast=true", function(data){

+ 1 - 1
web/components/subd.html

@@ -33,7 +33,7 @@
                     $("#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" onclick='deleteEndpoint("subd","${subd.MatchingDomain}")'><i class="remove icon"></i> Remove Subdomain</button></td>
+                        <td data-label=""><button class="ui circular mini red basic button" onclick='deleteEndpoint("subd","${subd.MatchingDomain}")'><i class="remove icon"></i> Delete</button></td>
                     </tr>`);
                 });
             }

+ 1 - 1
web/components/vdir.html

@@ -38,7 +38,7 @@
                     $("#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"  onclick='deleteEndpoint("vdir","${vdir.Root}")'><i class="remove icon"></i> Remove Virtual Directory</button></td>
+                        <td data-label=""><button class="ui circular mini red basic button"  onclick='deleteEndpoint("vdir","${vdir.Root}")'><i class="remove icon"></i> Delete</button></td>
                     </tr>`);
                 });
             }