]> 127.0.0.1 Git - front/.git/commitdiff
1 v0.1.20240115050205
authorqydysky <qydysky@foxmail.com>
Mon, 15 Jan 2024 05:01:45 +0000 (13:01 +0800)
committerqydysky <qydysky@foxmail.com>
Mon, 15 Jan 2024 05:01:45 +0000 (13:01 +0800)
go.mod
go.sum
main.go

diff --git a/go.mod b/go.mod
index 94cefc7d3b783859d476fe0cc9b1cca38cc1b7fc..46c225815f5044dfc8d3505dfd33d7abee3a59b3 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -1,29 +1,24 @@
 module github.com/qydysky/front
 
-go 1.21.4
+go 1.21
 
 require (
        github.com/gorilla/websocket v1.5.1
-       github.com/qydysky/part v0.28.20231215215733
+       github.com/qydysky/part v0.28.20240114140844
+       golang.org/x/net v0.18.0
 )
 
 require (
-       github.com/andybalholm/brotli v1.0.6 // indirect
        github.com/davecgh/go-spew v1.1.1 // indirect
        github.com/dustin/go-humanize v1.0.1 // indirect
        github.com/go-ole/go-ole v1.3.0 // indirect
-       github.com/klauspost/compress v1.17.3 // indirect
-       github.com/miekg/dns v1.1.57 // indirect
+       github.com/google/uuid v1.4.0 // indirect
        github.com/pmezard/go-difflib v1.0.0 // indirect
        github.com/shirou/gopsutil v3.21.11+incompatible // indirect
-       github.com/thedevsaddam/gojsonq/v2 v2.5.2 // indirect
        github.com/tklauser/go-sysconf v0.3.12 // indirect
        github.com/tklauser/numcpus v0.6.1 // indirect
        github.com/yusufpapurcu/wmi v1.2.3 // indirect
-       golang.org/x/mod v0.14.0 // indirect
-       golang.org/x/net v0.18.0 // indirect
        golang.org/x/sys v0.14.0 // indirect
        golang.org/x/text v0.14.0 // indirect
-       golang.org/x/tools v0.15.0 // indirect
        gopkg.in/yaml.v3 v3.0.1 // indirect
 )
diff --git a/go.sum b/go.sum
index 61fca6cb0742d13e78dabe06145a64aa12313a24..50a87c800c6aa32aa6f82466de5cf22371706212 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -13,34 +13,20 @@ github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/
 github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
-github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA=
-github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
 github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
 github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
-github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
-github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/qydysky/part v0.28.20231209070216 h1:1hnOxnsd4sTBTA/nF2pLhyL+0DidpwHo5H08S1D7xHE=
-github.com/qydysky/part v0.28.20231209070216/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
-github.com/qydysky/part v0.28.20231214142916 h1:pr4AyzEdcByXYlAB6yMyLebSDFH1X5fVnRqsdZkYNqU=
-github.com/qydysky/part v0.28.20231214142916/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
-github.com/qydysky/part v0.28.20231214145324 h1:laylvWj1l83w3R3OkJBPd83fJutq+nYPwooPfa+aqDo=
-github.com/qydysky/part v0.28.20231214145324/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
-github.com/qydysky/part v0.28.20231214150658 h1:MH+smtA+SyIRJR0bZI1dEXVF8s09wRZYWS9Kf58xQgA=
-github.com/qydysky/part v0.28.20231214150658/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
-github.com/qydysky/part v0.28.20231215215733 h1:qxbqSdoLUBG6o2VkKxM1IAaXoCQZcgLcmierFW9zwvc=
-github.com/qydysky/part v0.28.20231215215733/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
+github.com/qydysky/part v0.28.20240114140844 h1:9d0NPLx2CHKFca5Q6brECXeCjj0VXXaXmZRcJo6W85w=
+github.com/qydysky/part v0.28.20240114140844/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
 github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
 github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/thedevsaddam/gojsonq/v2 v2.5.2 h1:CoMVaYyKFsVj6TjU6APqAhAvC07hTI6IQen8PHzHYY0=
-github.com/thedevsaddam/gojsonq/v2 v2.5.2/go.mod h1:bv6Xa7kWy82uT0LnXPE2SzGqTj33TAEeR560MdJkiXs=
 github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
 github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
 github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
diff --git a/main.go b/main.go
index d8d3aa6a3c768ba7adc8c9fa6da00dc048cd7890..804ae881d6c430b99ce96f6e1346baa6c9293e22 100644 (file)
--- a/main.go
+++ b/main.go
@@ -255,6 +255,7 @@ func applyConfig(ctx context.Context, configS *Config, routeP *pweb.WebPath, log
 }
 
 var (
+       ErrRedirect        = errors.New("ErrRedirect")
        ErrNoHttp          = errors.New("ErrNoHttp")
        ErrNoWs            = errors.New("ErrNoWs")
        ErrCopy            = errors.New("ErrCopy")
@@ -301,9 +302,13 @@ func httpDealer(ctx context.Context, w http.ResponseWriter, r *http.Request, rou
 
                req.Header.Del("Referer")
 
-               client := http.Client{}
+               client := http.Client{
+                       CheckRedirect: func(req *http.Request, via []*http.Request) error {
+                               return ErrRedirect
+                       },
+               }
                resp, e = client.Do(req)
-               if e != nil {
+               if e != nil && !errors.Is(e, ErrRedirect) {
                        chosenBack.Disable()
                        logger.Warn(`W:`, fmt.Sprintf("%s=>%s %v", routePath, chosenBack.Name, e))
                }
@@ -363,7 +368,7 @@ func wsDealer(ctx context.Context, w http.ResponseWriter, r *http.Request, route
                chosenBack *Back
        )
 
-       for 0 < len(backs) && resp == nil {
+       for 0 < len(backs) && (resp == nil || conn == nil) {
                chosenBack = backs[nanotime1()%int64(len(backs))]
                backs = backs[1:]