]> 127.0.0.1 Git - front/.git/commitdiff
1 v0.1.20240303114922
authorqydysky <qydysky@foxmail.com>
Sun, 3 Mar 2024 11:49:02 +0000 (19:49 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 3 Mar 2024 11:49:02 +0000 (19:49 +0800)
.github/workflows/main.yml [changed mode: 0644->0755]
.gitignore [changed mode: 0644->0755]
README.md [changed mode: 0644->0755]
config.go [changed mode: 0644->0755]
go.mod [changed mode: 0644->0755]
go.sum [changed mode: 0644->0755]
main.go [changed mode: 0644->0755]
main/cert.pem [changed mode: 0644->0755]
main/key.pem [changed mode: 0644->0755]
main/main.go [changed mode: 0644->0755]
main/main.json [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 2cc718f..372fb89
@@ -25,12 +25,12 @@ jobs:
       contents: write
     steps:
     - name: Set up Go 1.x
-      uses: actions/setup-go@v4
+      uses: actions/setup-go@v5
       with:
         go-version: '1.21'
 
     - name: Check out code into the Go module directory
-      uses: actions/checkout@v3
+      uses: actions/checkout@v4
 
     - name: Set Release Name
       run: |
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 9a591c3..df660bb
--- a/config.go
+++ b/config.go
@@ -30,6 +30,7 @@ type Route struct {
        Path     string `json:"path"`
        Sign     string `json:"-"`
        Splicing int    `json:"splicing"`
+       PathAdd  bool   `json:"pathAdd"`
        Back     []Back `json:"back"`
 }
 
@@ -60,7 +61,7 @@ func (t *Route) GenBack() []*Back {
                        To:          back.To,
                        Weight:      back.Weight,
                        ErrBanSec:   back.ErrBanSec,
-                       PathAdd:     back.PathAdd,
+                       PathAdd:     t.PathAdd,
                        MatchHeader: append([]Header{}, back.MatchHeader...),
                        ReqHeader:   append([]Header{}, back.ReqHeader...),
                        ResHeader:   append([]Header{}, back.ResHeader...),
@@ -90,12 +91,12 @@ type Back struct {
        lock        sync.RWMutex
        Sign        string `json:"-"`
        Splicing    int    `json:"-"`
+       PathAdd     bool   `json:"-"`
        upT         time.Time
        Name        string   `json:"name"`
        To          string   `json:"to"`
        Weight      int      `json:"weight"`
        ErrBanSec   int      `json:"errBanSec"`
-       PathAdd     bool     `json:"pathAdd"`
        MatchHeader []Header `json:"matchHeader"`
        ReqHeader   []Header `json:"reqHeader"`
        ResHeader   []Header `json:"resHeader"`
diff --git a/go.mod b/go.mod
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/go.sum b/go.sum
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/main.go b/main.go
old mode 100644 (file)
new mode 100755 (executable)
index 1dbd8b6..769c127
--- a/main.go
+++ b/main.go
@@ -267,6 +267,7 @@ var (
 
 func httpDealer(ctx context.Context, w http.ResponseWriter, r *http.Request, routePath string, backs []*Back, logger Logger, blocksi pslice.BlocksI[byte]) error {
        var (
+               opT        = time.Now()
                resp       *http.Response
                chosenBack *Back
        )
@@ -319,7 +320,7 @@ func httpDealer(ctx context.Context, w http.ResponseWriter, r *http.Request, rou
                return errors.New("后端故障")
        }
 
-       logger.Error(`T:`, fmt.Sprintf("%s=>%s", routePath, chosenBack.Name))
+       logger.Debug(`T:`, fmt.Sprintf("http %s=>%s %v", routePath, chosenBack.Name, time.Since(opT)))
 
        if validCookieDomain(r.Host) {
                w.Header().Add("Set-Cookie", (&http.Cookie{
@@ -361,6 +362,7 @@ func httpDealer(ctx context.Context, w http.ResponseWriter, r *http.Request, rou
 
 func wsDealer(ctx context.Context, w http.ResponseWriter, r *http.Request, routePath string, backs []*Back, logger Logger, blocksi pslice.BlocksI[byte]) error {
        var (
+               opT        = time.Now()
                resp       *http.Response
                conn       net.Conn
                chosenBack *Back
@@ -399,7 +401,7 @@ func wsDealer(ctx context.Context, w http.ResponseWriter, r *http.Request, route
                return errors.New("后端故障")
        }
 
-       logger.Error(`T:`, fmt.Sprintf("%s=>%s", routePath, chosenBack.Name))
+       logger.Debug(`T:`, fmt.Sprintf("ws %s=>%s %v", routePath, chosenBack.Name, time.Since(opT)))
 
        if validCookieDomain(r.Host) {
                w.Header().Add("Set-Cookie", (&http.Cookie{
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index c4ffeb8..95f14c5
@@ -7,18 +7,17 @@
       {
         "path": "/",
         "errRedirect": false,
+        "pathAdd": true,
         "back": [
           {
             "name": "baidu1",
             "to": "s://www.baidu.com",
-            "weight": 1,
-            "pathAdd": true
+            "weight": 1
           },
           {
             "name": "baidu2",
             "to": "s://www.baidu.com",
-            "weight": 1,
-            "pathAdd": true
+            "weight": 1
           }
         ]
       }