From 5c9909aeefca55b98a4cf9d2bbb4a0152be2761e Mon Sep 17 00:00:00 2001 From: fatedier Date: Tue, 30 Jan 2018 22:07:16 +0800 Subject: [PATCH 1/8] typo --- conf/frpc_full.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/frpc_full.ini b/conf/frpc_full.ini index 1204b26..4bec160 100644 --- a/conf/frpc_full.ini +++ b/conf/frpc_full.ini @@ -73,7 +73,7 @@ local_port = 22 # if remote_port is 0, frps will assgin a random port for you remote_port = 0 -# if you want tp expose multiple ports, add 'range:' prefix to the section name +# if you want to expose multiple ports, add 'range:' prefix to the section name # frpc will generate multiple proxies such as 'tcp_port_6010', 'tcp_port_6011' and so on. [range:tcp_port] type = tcp From 1d0865ca49ff50d2b81d3c0d39f680f763310eae Mon Sep 17 00:00:00 2001 From: fatedier Date: Thu, 1 Feb 2018 11:15:35 +0800 Subject: [PATCH 2/8] statsConn: avoid repetition of close function --- utils/net/conn.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/net/conn.go b/utils/net/conn.go index 78319cc..b187733 100644 --- a/utils/net/conn.go +++ b/utils/net/conn.go @@ -21,6 +21,7 @@ import ( "io" "net" "sync" + "sync/atomic" "time" "github.com/fatedier/frp/utils/log" @@ -178,6 +179,7 @@ func (sc *SharedConn) WriteBuff(buffer []byte) (err error) { type StatsConn struct { Conn + closed int64 // 1 means closed totalRead int64 totalWrite int64 statsFunc func(totalRead, totalWrite int64) @@ -203,9 +205,12 @@ func (statsConn *StatsConn) Write(p []byte) (n int, err error) { } func (statsConn *StatsConn) Close() (err error) { - err = statsConn.Conn.Close() - if statsConn.statsFunc != nil { - statsConn.statsFunc(statsConn.totalRead, statsConn.totalWrite) + old := atomic.SwapInt64(&statsConn.closed, 1) + if old != 1 { + err = statsConn.Conn.Close() + if statsConn.statsFunc != nil { + statsConn.statsFunc(statsConn.totalRead, statsConn.totalWrite) + } } return } From 9e8980429f6f21a714baeab0595b5aa60248b0fa Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 7 Feb 2018 11:39:30 +0800 Subject: [PATCH 3/8] typo --- cmd/frpc/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/frpc/main.go b/cmd/frpc/main.go index 51eb53c..845f4f7 100644 --- a/cmd/frpc/main.go +++ b/cmd/frpc/main.go @@ -86,7 +86,7 @@ func main() { if args["reload"] != nil { if args["reload"].(bool) { if err = CmdReload(); err != nil { - fmt.Printf("frps reload error: %v\n", err) + fmt.Printf("frpc reload error: %v\n", err) os.Exit(1) } else { fmt.Printf("reload success\n") From 1739e012d6f26faa12078c6de9cb0fa9eb466145 Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Mon, 26 Feb 2018 21:00:55 -0700 Subject: [PATCH 4/8] build freebsd packages --- Makefile.cross-compiles | 4 ++++ package.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.cross-compiles b/Makefile.cross-compiles index 086d8b6..2b2ec0b 100644 --- a/Makefile.cross-compiles +++ b/Makefile.cross-compiles @@ -9,6 +9,10 @@ build: app app: env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_darwin_amd64 ./cmd/frpc env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_darwin_amd64 ./cmd/frps + env CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frpc_freebsd_386 ./cmd/frpc + env CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frps_freebsd_386 ./cmd/frps + env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_freebsd_amd64 ./cmd/frpc + env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_freebsd_amd64 ./cmd/frps env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_386 ./cmd/frpc env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_386 ./cmd/frps env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_amd64 ./cmd/frpc diff --git a/package.sh b/package.sh index a5c55f1..65d1446 100755 --- a/package.sh +++ b/package.sh @@ -14,7 +14,7 @@ make -f ./Makefile.cross-compiles rm -rf ./packages mkdir ./packages -os_all='linux windows darwin' +os_all='linux windows darwin freebsd' arch_all='386 amd64 arm mips64 mips64le mips mipsle' for os in $os_all; do From e9241aeb943d903ffe82a23ac516d703f8675741 Mon Sep 17 00:00:00 2001 From: fatedier Date: Mon, 19 Mar 2018 20:22:15 +0800 Subject: [PATCH 5/8] udp proxy: fix #652 --- models/proto/udp/udp.go | 1 + server/control.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models/proto/udp/udp.go b/models/proto/udp/udp.go index fe548f1..15ecb9c 100644 --- a/models/proto/udp/udp.go +++ b/models/proto/udp/udp.go @@ -82,6 +82,7 @@ func Forwarder(dstAddr *net.UDPAddr, readCh <-chan *msg.UdpPacket, sendCh chan<- mu.Lock() delete(udpConnMap, addr) mu.Unlock() + udpConn.Close() }() buf := pool.GetBuf(1500) diff --git a/server/control.go b/server/control.go index dbb99ad..d7938e7 100644 --- a/server/control.go +++ b/server/control.go @@ -265,13 +265,14 @@ func (ctl *Control) stoper() { ctl.conn.Close() ctl.readerShutdown.WaitDone() + ctl.mu.Lock() + defer ctl.mu.Unlock() + close(ctl.workConnCh) for workConn := range ctl.workConnCh { workConn.Close() } - ctl.mu.Lock() - defer ctl.mu.Unlock() for _, pxy := range ctl.proxies { pxy.Close() ctl.svr.DelProxy(pxy.GetName()) @@ -303,6 +304,7 @@ func (ctl *Control) manager() { if time.Since(ctl.lastPing) > time.Duration(config.ServerCommonCfg.HeartBeatTimeout)*time.Second { ctl.conn.Warn("heartbeat timeout") ctl.allShutdown.Start() + return } case rawMsg, ok := <-ctl.readCh: if !ok { From 8af70c8822fe86f468386e1b87133316b3099867 Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 21 Mar 2018 11:52:11 +0800 Subject: [PATCH 6/8] update go version to go1.10 --- .travis.yml | 3 +-- Makefile | 7 +------ Makefile.cross-compiles | 8 ++++---- Makefile.cross-compiles.bak | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 Makefile.cross-compiles.bak diff --git a/.travis.yml b/.travis.yml index 51c2421..ff656e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,7 @@ sudo: false language: go go: - - 1.8.x - - 1.9.x + - 1.10.x install: - make diff --git a/Makefile b/Makefile index 63927f9..b91b334 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,7 @@ file: go generate ./assets/... fmt: - go fmt ./assets/... - go fmt ./client/... - go fmt ./cmd/... - go fmt ./models/... - go fmt ./server/... - go fmt ./utils/... + go fmt ./... frps: go build -o bin/frps ./cmd/frps diff --git a/Makefile.cross-compiles b/Makefile.cross-compiles index 2b2ec0b..c5dda4d 100644 --- a/Makefile.cross-compiles +++ b/Makefile.cross-compiles @@ -27,10 +27,10 @@ app: env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips64 ./cmd/frps env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips64le ./cmd/frpc env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips64le ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mipsle ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mipsle ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mipsle ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mipsle ./cmd/frps temp: env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_amd64 ./cmd/frps diff --git a/Makefile.cross-compiles.bak b/Makefile.cross-compiles.bak new file mode 100644 index 0000000..3e79fa8 --- /dev/null +++ b/Makefile.cross-compiles.bak @@ -0,0 +1,35 @@ +export PATH := $(GOPATH)/bin:$(PATH) +export GO15VENDOREXPERIMENT := 1 +LDFLAGS := -s -w + +all: build + +build: app + +app: + env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_darwin_amd64 ./cmd/frpc + env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_darwin_amd64 ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_386 ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_386 ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_amd64 ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_amd64 ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_arm ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o ./frps_linux_arm ./cmd/frps + env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frpc_windows_386.exe ./cmd/frpc + env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frps_windows_386.exe ./cmd/frps + env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_windows_amd64.exe ./cmd/frpc + env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_windows_amd64.exe ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips64 ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips64 ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips64le ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips64le ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mipsle ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mipsle ./cmd/frps + +temp: + env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips ./cmd/frps + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mipsle ./cmd/frpc + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mipsle ./cmd/frps From 3166bdf3f0554b758c72366d64194b83dcb3c0f6 Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 21 Mar 2018 11:54:51 +0800 Subject: [PATCH 7/8] bump version to v0.16.1 --- Makefile.cross-compiles.bak | 35 ----------------------------------- models/config/proxy.go | 2 +- utils/version/version.go | 2 +- 3 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 Makefile.cross-compiles.bak diff --git a/Makefile.cross-compiles.bak b/Makefile.cross-compiles.bak deleted file mode 100644 index 3e79fa8..0000000 --- a/Makefile.cross-compiles.bak +++ /dev/null @@ -1,35 +0,0 @@ -export PATH := $(GOPATH)/bin:$(PATH) -export GO15VENDOREXPERIMENT := 1 -LDFLAGS := -s -w - -all: build - -build: app - -app: - env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_darwin_amd64 ./cmd/frpc - env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_darwin_amd64 ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_386 ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_386 ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_amd64 ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_amd64 ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_arm ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "$(LDFLAGS)" -o ./frps_linux_arm ./cmd/frps - env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frpc_windows_386.exe ./cmd/frpc - env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$(LDFLAGS)" -o ./frps_windows_386.exe ./cmd/frps - env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frpc_windows_amd64.exe ./cmd/frpc - env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o ./frps_windows_amd64.exe ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips64 ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips64 ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips64le ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips64le ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mipsle ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mipsle ./cmd/frps - -temp: - env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mips ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mips ./cmd/frps - env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frpc_linux_mipsle ./cmd/frpc - env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "$(LDFLAGS)" -o ./frps_linux_mipsle ./cmd/frps diff --git a/models/config/proxy.go b/models/config/proxy.go index b506c43..49835c3 100644 --- a/models/config/proxy.go +++ b/models/config/proxy.go @@ -788,7 +788,7 @@ func ParseRangeSection(name string, section ini.Section) (sections map[string]in return } if len(localPorts) == 0 { - err = fmt.Errorf("Parse conf error: range section [%s] local_port and remote_port is necessary") + err = fmt.Errorf("Parse conf error: range section [%s] local_port and remote_port is necessary", name) return } diff --git a/utils/version/version.go b/utils/version/version.go index 4a08611..5c901e7 100644 --- a/utils/version/version.go +++ b/utils/version/version.go @@ -19,7 +19,7 @@ import ( "strings" ) -var version string = "0.16.0" +var version string = "0.16.1" func Full() string { return version From 82dc1e924fcb7a2da4adca4c1c3dcd75ca7f1aca Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 21 Mar 2018 18:06:43 +0800 Subject: [PATCH 8/8] vhost: typo fix --- utils/vhost/https.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/vhost/https.go b/utils/vhost/https.go index a1a0645..a6ef55d 100644 --- a/utils/vhost/https.go +++ b/utils/vhost/https.go @@ -108,7 +108,7 @@ func readHandshake(rd io.Reader) (host string, err error) { return } if len(data) < 2 { - err = fmt.Errorf("readHandshake: extension dataLen[%d] is too short") + err = fmt.Errorf("readHandshake: extension dataLen[%d] is too short", len(data)) return }