Compare commits

...

2 Commits

Author SHA1 Message Date
fatedier
69ff01d38b client: add StatusExporter in service 2024-04-25 20:13:56 +08:00
fatedier
c1893ee1b4
adjust arm compilation configuration (#4181) 2024-04-25 13:08:41 +08:00
6 changed files with 34 additions and 17 deletions

View File

@ -2,7 +2,7 @@ export PATH := $(PATH):`go env GOPATH`/bin
export GO111MODULE=on export GO111MODULE=on
LDFLAGS := -s -w LDFLAGS := -s -w
os-archs=darwin:amd64 darwin:arm64 freebsd:amd64 linux:amd64 linux:arm linux:arm:6 linux:arm64 windows:amd64 windows:arm64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat linux:riscv64 android:arm64 os-archs=darwin:amd64 darwin:arm64 freebsd:amd64 linux:amd64 linux:arm:7 linux:arm:5 linux:arm64 windows:amd64 windows:arm64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat linux:riscv64 android:arm64
all: build all: build
@ -16,8 +16,13 @@ app:
flags=''; \ flags=''; \
target_suffix=$${os}_$${arch}; \ target_suffix=$${os}_$${arch}; \
if [ "$${os}" = "linux" ] && [ "$${arch}" = "arm" ] && [ "$${extra}" != "" ] ; then \ if [ "$${os}" = "linux" ] && [ "$${arch}" = "arm" ] && [ "$${extra}" != "" ] ; then \
flags=GOARM=$${extra}; \ if [ "$${extra}" = "7" ]; then \
target_suffix=$${os}_$${arch}_$${extra}; \ flags=GOARM=7; \
target_suffix=$${os}_arm_hf; \
elif [ "$${extra}" = "5" ]; then \
flags=GOARM=5; \
target_suffix=$${os}_arm; \
fi; \
elif [ "$${os}" = "linux" ] && ([ "$${arch}" = "mips" ] || [ "$${arch}" = "mipsle" ]) && [ "$${extra}" != "" ] ; then \ elif [ "$${os}" = "linux" ] && ([ "$${arch}" = "mips" ] || [ "$${arch}" = "mipsle" ]) && [ "$${extra}" != "" ] ; then \
flags=GOMIPS=$${extra}; \ flags=GOMIPS=$${extra}; \
fi; \ fi; \

View File

@ -352,7 +352,6 @@ You may substitute `https2https` for the plugin, and point the `localAddr` to a
# frpc.toml # frpc.toml
serverAddr = "x.x.x.x" serverAddr = "x.x.x.x"
serverPort = 7000 serverPort = 7000
vhostHTTPSPort = 443
[[proxies]] [[proxies]]
name = "test_https2http" name = "test_https2http"

View File

@ -380,18 +380,31 @@ func (svr *Service) stop() {
} }
} }
// TODO(fatedier): Use StatusExporter to provide query interfaces instead of directly using methods from the Service. func (svr *Service) getProxyStatus(name string) (*proxy.WorkingStatus, bool) {
func (svr *Service) GetProxyStatus(name string) (*proxy.WorkingStatus, error) {
svr.ctlMu.RLock() svr.ctlMu.RLock()
ctl := svr.ctl ctl := svr.ctl
svr.ctlMu.RUnlock() svr.ctlMu.RUnlock()
if ctl == nil { if ctl == nil {
return nil, fmt.Errorf("control is not running") return nil, false
} }
ws, ok := ctl.pm.GetProxyStatus(name) return ctl.pm.GetProxyStatus(name)
if !ok { }
return nil, fmt.Errorf("proxy [%s] is not found", name)
} func (svr *Service) StatusExporter() StatusExporter {
return ws, nil return &statusExporterImpl{
getProxyStatusFunc: svr.getProxyStatus,
}
}
type StatusExporter interface {
GetProxyStatus(name string) (*proxy.WorkingStatus, bool)
}
type statusExporterImpl struct {
getProxyStatusFunc func(name string) (*proxy.WorkingStatus, bool)
}
func (s *statusExporterImpl) GetProxyStatus(name string) (*proxy.WorkingStatus, bool) {
return s.getProxyStatusFunc(name)
} }

View File

@ -19,7 +19,7 @@ mkdir -p ./release/packages
os_all='linux windows darwin freebsd android' os_all='linux windows darwin freebsd android'
arch_all='386 amd64 arm arm64 mips64 mips64le mips mipsle riscv64' arch_all='386 amd64 arm arm64 mips64 mips64le mips mipsle riscv64'
extra_all='_ 6' extra_all='_ hf'
cd ./release cd ./release

View File

@ -363,11 +363,13 @@ func (s *TunnelServer) waitProxyStatusReady(name string, timeout time.Duration)
timer := time.NewTimer(timeout) timer := time.NewTimer(timeout)
defer timer.Stop() defer timer.Stop()
statusExporter := s.vc.Service().StatusExporter()
for { for {
select { select {
case <-ticker.C: case <-ticker.C:
ps, err := s.vc.Service().GetProxyStatus(name) ps, ok := statusExporter.GetProxyStatus(name)
if err != nil { if !ok {
continue continue
} }
switch ps.Phase { switch ps.Phase {

View File

@ -32,8 +32,6 @@ import (
"github.com/fatedier/frp/pkg/util/version" "github.com/fatedier/frp/pkg/util/version"
) )
// TODO(fatedier): add an API to clean status of all offline proxies.
type GeneralResponse struct { type GeneralResponse struct {
Code int Code int
Msg string Msg string