Compare commits

...

6 Commits

Author SHA1 Message Date
mrasong
4d33400d49
Merge 4991596daea57d78dbc0320a6ac708f7dc288021 into 5b7b81a117c6cf8695b8546c70d3bb0046df6b8a 2023-12-21 22:06:45 +08:00
fatedier
5b7b81a117
let e2e concurrency configurable (#3881) 2023-12-21 21:58:56 +08:00
fatedier
2a9a7a0e4a
fix login retry interval (#3879) 2023-12-21 21:38:32 +08:00
fatedier
5e77c8e2d3
fix lint (#3877) 2023-12-21 21:19:49 +08:00
im_zhou
3bf6605e1a
fix: duplicate call loginFunc (#3860) (#3875)
modify ext func, specify whether exit immediately
2023-12-21 20:51:10 +08:00
mrasong
4991596dae fixed: API error when the proxy name contains "#". 2023-12-15 17:50:23 +08:00
10 changed files with 33 additions and 40 deletions

2
.gitignore vendored
View File

@ -34,6 +34,8 @@ dist/
.idea/
.vscode/
.autogen_ssh_key
client.crt
client.key
# Cache
*.swp

View File

@ -132,6 +132,9 @@ issues:
- linters:
- revive
text: "unused-parameter"
- linters:
- unparam
text: "is always false"
# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all

View File

@ -1,11 +1,3 @@
### Features
* The new command line parameter `--strict_config` has been added to enable strict configuration validation mode. It will throw an error for unknown fields instead of ignoring them. In future versions, we will set the default value of this parameter to true to avoid misconfigurations.
* Support `SSH reverse tunneling`. With this feature, you can expose your local service without running frpc, only using SSH. The SSH reverse tunnel agent has many functional limitations compared to the frpc agent. The currently supported proxy types are tcp, http, https, tcpmux, and stcp.
* The frpc tcpmux command line parameters have been updated to support configuring `http_user` and `http_pwd`.
* The frpc stcp/sudp/xtcp command line parameters have been updated to support configuring `allow_users`.
### Fixes
* frpc: Return code 1 when the first login attempt fails and exits.
* When auth.method is `oidc` and auth.additionalScopes contains `HeartBeats`, if obtaining AccessToken fails, the application will be unresponsive.
* frpc has a certain chance to panic when login: close of closed channel.

View File

@ -239,15 +239,15 @@ func (ctl *Control) heartbeatWorker() {
// Users can still enable heartbeat feature by setting HeartbeatInterval to a positive value.
if ctl.sessionCtx.Common.Transport.HeartbeatInterval > 0 {
// send heartbeat to server
sendHeartBeat := func() error {
sendHeartBeat := func() (bool, error) {
xl.Debug("send heartbeat to server")
pingMsg := &msg.Ping{}
if err := ctl.sessionCtx.AuthSetter.SetPing(pingMsg); err != nil {
xl.Warn("error during ping authentication: %v, skip sending ping message", err)
return err
return false, err
}
_ = ctl.msgDispatcher.Send(pingMsg)
return nil
return false, nil
}
go wait.BackoffUntil(sendHeartBeat,

View File

@ -192,16 +192,16 @@ func (svr *Service) keepControllerWorking() {
// the control immediately exits. It is necessary to limit the frequency of reconnection in this case.
// The interval for the first three retries in 1 minute will be very short, and then it will increase exponentially.
// The maximum interval is 20 seconds.
wait.BackoffUntil(func() error {
wait.BackoffUntil(func() (bool, error) {
// loopLoginUntilSuccess is another layer of loop that will continuously attempt to
// login to the server until successful.
svr.loopLoginUntilSuccess(20*time.Second, false)
if svr.ctl != nil {
<-svr.ctl.Done()
return errors.New("control is closed and try another loop")
return false, errors.New("control is closed and try another loop")
}
// If the control is nil, it means that the login failed and the service is also closed.
return nil
return false, nil
}, wait.NewFastBackoffManager(
wait.FastBackoffOptions{
Duration: time.Second,
@ -282,9 +282,8 @@ func (svr *Service) login() (conn net.Conn, connector Connector, err error) {
func (svr *Service) loopLoginUntilSuccess(maxInterval time.Duration, firstLoginExit bool) {
xl := xlog.FromContextSafe(svr.ctx)
successCh := make(chan struct{})
loginFunc := func() error {
loginFunc := func() (bool, error) {
xl.Info("try to connect to server...")
conn, connector, err := svr.login()
if err != nil {
@ -292,7 +291,7 @@ func (svr *Service) loopLoginUntilSuccess(maxInterval time.Duration, firstLoginE
if firstLoginExit {
svr.cancel(cancelErr{Err: err})
}
return err
return false, err
}
svr.cfgMu.RLock()
@ -315,7 +314,7 @@ func (svr *Service) loopLoginUntilSuccess(maxInterval time.Duration, firstLoginE
if err != nil {
conn.Close()
xl.Error("NewControl error: %v", err)
return err
return false, err
}
ctl.SetInWorkConnCallback(svr.handleWorkConnCb)
@ -327,9 +326,7 @@ func (svr *Service) loopLoginUntilSuccess(maxInterval time.Duration, firstLoginE
}
svr.ctl = ctl
svr.ctlMu.Unlock()
close(successCh)
return nil
return true, nil
}
// try to reconnect to server until success
@ -339,9 +336,7 @@ func (svr *Service) loopLoginUntilSuccess(maxInterval time.Duration, firstLoginE
Factor: 2,
Jitter: 0.1,
MaxDuration: maxInterval,
}),
true,
wait.MergeAndCloseOnAnyStopChannel(svr.ctx.Done(), successCh))
}), true, svr.ctx.Done())
}
func (svr *Service) UpdateAllConfigurer(proxyCfgs []v1.ProxyConfigurer, visitorCfgs []v1.VisitorConfigurer) error {

View File

@ -26,5 +26,9 @@ frpsPath=${ROOT}/bin/frps
if [ "${FRPS_PATH}" ]; then
frpsPath="${FRPS_PATH}"
fi
concurrency="12"
if [ "${CONCURRENCY}" ]; then
concurrency="${CONCURRENCY}"
fi
ginkgo -nodes=8 --poll-progress-after=60s ${ROOT}/test/e2e -- -frpc-path=${frpcPath} -frps-path=${frpsPath} -log-level=${logLevel} -debug=${debug}
ginkgo -nodes=${concurrency} --poll-progress-after=60s ${ROOT}/test/e2e -- -frpc-path=${frpcPath} -frps-path=${frpsPath} -log-level=${logLevel} -debug=${debug}

View File

@ -19,7 +19,7 @@ import (
"strings"
)
var version = "0.53.0"
var version = "0.53.2"
func Full() string {
return version

View File

@ -113,7 +113,7 @@ func (f *fastBackoffImpl) Backoff(previousDuration time.Duration, previousCondit
return f.options.Duration
}
func BackoffUntil(f func() error, backoff BackoffManager, sliding bool, stopCh <-chan struct{}) {
func BackoffUntil(f func() (bool, error), backoff BackoffManager, sliding bool, stopCh <-chan struct{}) {
var delay time.Duration
previousError := false
@ -131,7 +131,9 @@ func BackoffUntil(f func() error, backoff BackoffManager, sliding bool, stopCh <
delay = backoff.Backoff(delay, previousError)
}
if err := f(); err != nil {
if done, err := f(); done {
return
} else if err != nil {
previousError = true
} else {
previousError = false
@ -142,12 +144,6 @@ func BackoffUntil(f func() error, backoff BackoffManager, sliding bool, stopCh <
}
ticker.Reset(delay)
select {
case <-stopCh:
return
default:
}
select {
case <-stopCh:
return
@ -170,9 +166,9 @@ func Jitter(duration time.Duration, maxFactor float64) time.Duration {
}
func Until(f func(), period time.Duration, stopCh <-chan struct{}) {
ff := func() error {
ff := func() (bool, error) {
f()
return nil
return false, nil
}
BackoffUntil(ff, BackoffFunc(func(time.Duration, bool) time.Duration {
return period

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()