Compare commits

...

3 Commits

Author SHA1 Message Date
mrasong
c97e2f9342
Merge 4991596daea57d78dbc0320a6ac708f7dc288021 into 354091087955f6fcb7216ee03a2397376e4526c4 2023-12-21 13:37:16 +08:00
Remember
3540910879
fix(backoff): close of closed out channel (#3871)
* fix: close of closed channel

* feat: replace Try0 to std
2023-12-21 11:43:42 +08:00
mrasong
4991596dae fixed: API error when the proxy name contains "#". 2023-12-15 17:50:23 +08:00
3 changed files with 11 additions and 9 deletions

View File

@ -16,10 +16,9 @@ package wait
import (
"math/rand"
"sync"
"time"
"github.com/samber/lo"
"github.com/fatedier/frp/pkg/util/util"
)
@ -182,16 +181,18 @@ func Until(f func(), period time.Duration, stopCh <-chan struct{}) {
func MergeAndCloseOnAnyStopChannel[T any](upstreams ...<-chan T) <-chan T {
out := make(chan T)
closeOnce := sync.Once{}
for _, upstream := range upstreams {
ch := upstream
go lo.Try0(func() {
go func() {
select {
case <-ch:
close(out)
closeOnce.Do(func() {
close(out)
})
case <-out:
}
})
}()
}
return out
}

View File

@ -17,6 +17,7 @@ package server
import (
"encoding/json"
"net/http"
"net/url"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
@ -282,7 +283,7 @@ func (svr *Service) apiProxyByTypeAndName(w http.ResponseWriter, r *http.Request
res := GeneralResponse{Code: 200}
params := mux.Vars(r)
proxyType := params["type"]
name := params["name"]
name, _ := url.QueryUnescape(params["name"])
defer func() {
log.Info("Http response [%s]: code [%d]", r.URL.Path, res.Code)
@ -350,7 +351,7 @@ type GetProxyTrafficResp struct {
func (svr *Service) apiProxyTraffic(w http.ResponseWriter, r *http.Request) {
res := GeneralResponse{Code: 200}
params := mux.Vars(r)
name := params["name"]
name, _ := url.QueryUnescape(params["name"])
defer func() {
log.Info("Http response [%s]: code [%d]", r.URL.Path, res.Code)

View File

@ -11,7 +11,7 @@ const props = defineProps<{
}>()
const fetchData = () => {
let url = '../api/traffic/' + props.proxyName
let url = '../api/traffic/' + encodeURIComponent(props.proxyName)
fetch(url, { credentials: 'include' })
.then((res) => {
return res.json()