Skip to content

Commit 980f084

Browse files
authored
Merge pull request #2302 from fatedier/dev
bump version
2 parents 3bf1eb8 + 0c35863 commit 980f084

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3092
-1722
lines changed

Diff for: .circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ version: 2
22
jobs:
33
test1:
44
docker:
5-
- image: circleci/golang:1.15-node
5+
- image: circleci/golang:1.16-node
66
working_directory: /go/src/github.com/fatedier/frp
77
steps:
88
- checkout
99
- run: make
1010
- run: make alltest
1111
test2:
1212
docker:
13-
- image: circleci/golang:1.14-node
13+
- image: circleci/golang:1.15-node
1414
working_directory: /go/src/github.com/fatedier/frp
1515
steps:
1616
- checkout

Diff for: .github/workflows/build-and-push-image.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: Set up Go 1.x
1919
uses: actions/setup-go@v2
2020
with:
21-
go-version: 1.15
21+
go-version: 1.16
2222
-
2323
run: go version
2424
-

Diff for: .github/workflows/goreleaser.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v2
1717
with:
18-
go-version: 1.15
18+
go-version: 1.16
1919

2020
- name: Make All
2121
run: |

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ release/
3030
test/bin/
3131
vendor/
3232
dist/
33+
.idea/
3334

3435
# Cache
3536
*.swp

Diff for: Makefile.cross-compiles

+16-26
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,24 @@ export PATH := $(GOPATH)/bin:$(PATH)
22
export GO111MODULE=on
33
LDFLAGS := -s -w
44

5+
os-archs=darwin:amd64 darwin:arm64 freebsd:386 freebsd:amd64 linux:386 linux:amd64 linux:arm windows:386 windows:amd64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat
6+
57
all: build
68

79
build: app
810

911
app:
10-
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_darwin_amd64 ./cmd/frpc
11-
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_darwin_amd64 ./cmd/frps
12-
env CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_freebsd_386 ./cmd/frpc
13-
env CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_freebsd_386 ./cmd/frps
14-
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_freebsd_amd64 ./cmd/frpc
15-
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_freebsd_amd64 ./cmd/frps
16-
env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_386 ./cmd/frpc
17-
env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_386 ./cmd/frps
18-
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_amd64 ./cmd/frpc
19-
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_amd64 ./cmd/frps
20-
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_arm ./cmd/frpc
21-
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_arm ./cmd/frps
22-
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_arm64 ./cmd/frpc
23-
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_arm64 ./cmd/frps
24-
env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_windows_386.exe ./cmd/frpc
25-
env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_windows_386.exe ./cmd/frps
26-
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_windows_amd64.exe ./cmd/frpc
27-
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_windows_amd64.exe ./cmd/frps
28-
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_mips64 ./cmd/frpc
29-
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_mips64 ./cmd/frps
30-
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_mips64le ./cmd/frpc
31-
env CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_mips64le ./cmd/frps
32-
env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_mips ./cmd/frpc
33-
env CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_mips ./cmd/frps
34-
env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_linux_mipsle ./cmd/frpc
35-
env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_linux_mipsle ./cmd/frps
12+
@$(foreach n, $(os-archs),\
13+
os=$(shell echo "$(n)" | cut -d : -f 1);\
14+
arch=$(shell echo "$(n)" | cut -d : -f 2);\
15+
gomips=$(shell echo "$(n)" | cut -d : -f 3);\
16+
target_suffix=$${os}_$${arch};\
17+
echo "Build $${os}-$${arch}...";\
18+
env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_$${target_suffix} ./cmd/frpc;\
19+
env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_$${target_suffix} ./cmd/frps;\
20+
echo "Build $${os}-$${arch} done";\
21+
)
22+
@mv ./release/frpc_windows_386 ./release/frpc_windows_386.exe
23+
@mv ./release/frps_windows_386 ./release/frps_windows_386.exe
24+
@mv ./release/frpc_windows_amd64 ./release/frpc_windows_amd64.exe
25+
@mv ./release/frps_windows_amd64 ./release/frps_windows_amd64.exe

Diff for: README.md

+99-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# frp
23

34
[![Build Status](https://circleci.com/gh/fatedier/frp.svg?style=shield)](https://circleci.com/gh/fatedier/frp)
@@ -67,7 +68,7 @@ frp also has a P2P connect mode.
6768
* [Donation](#donation)
6869
* [AliPay](#alipay)
6970
* [Wechat Pay](#wechat-pay)
70-
* [Paypal](#paypal)
71+
* [PayPal](#paypal)
7172

7273
<!-- vim-markdown-toc -->
7374

@@ -257,7 +258,9 @@ Configure `frps` same as above.
257258

258259
2. Visit `http://x.x.x.x:6000/static/` from your browser and specify correct user and password to view files in `/tmp/files` on the `frpc` machine.
259260

260-
### Enable HTTPS for local HTTP service
261+
### Enable HTTPS for local HTTP(S) service
262+
263+
You may substitute `https2https` for the plugin, and point the `plugin_local_addr` to a HTTPS endpoint.
261264

262265
1. Start `frpc` with configuration:
263266

@@ -515,11 +518,100 @@ use_compression = true
515518

516519
frp supports the TLS protocol between `frpc` and `frps` since v0.25.0.
517520

518-
Config `tls_enable = true` in the `[common]` section to `frpc.ini` to enable this feature.
519-
520521
For port multiplexing, frp sends a first byte `0x17` to dial a TLS connection.
521522

522-
To enforce `frps` to only accept TLS connections - configure `tls_only = true` in the `[common]` section in `frps.ini`.
523+
Configure `tls_enable = true` in the `[common]` section to `frpc.ini` to enable this feature.
524+
525+
To **enforce** `frps` to only accept TLS connections - configure `tls_only = true` in the `[common]` section in `frps.ini`. **This is optional.**
526+
527+
**`frpc` TLS settings (under the `[common]` section):**
528+
```ini
529+
tls_enable = true
530+
tls_cert_file = certificate.crt
531+
tls_key_file = certificate.key
532+
tls_trusted_ca_file = ca.crt
533+
```
534+
535+
**`frps` TLS settings (under the `[common]` section):**
536+
```ini
537+
tls_only = true
538+
tls_enable = true
539+
tls_cert_file = certificate.crt
540+
tls_key_file = certificate.key
541+
tls_trusted_ca_file = ca.crt
542+
```
543+
544+
You will need **a root CA cert** and **at least one SSL/TLS certificate**. It **can** be self-signed or regular (such as Let's Encrypt or another SSL/TLS certificate provider).
545+
546+
If you using `frp` via IP address and not hostname, make sure to set the appropriate IP address in the Subject Alternative Name (SAN) area when generating SSL/TLS Certificates.
547+
548+
Given an example:
549+
550+
* Prepare openssl config file. It exists at `/etc/pki/tls/openssl.cnf` in Linux System and `/System/Library/OpenSSL/openssl.cnf` in MacOS, and you can copy it to current path, like `cp /etc/pki/tls/openssl.cnf ./my-openssl.cnf`. If not, you can build it by yourself, like:
551+
```
552+
cat > my-openssl.cnf << EOF
553+
[ ca ]
554+
default_ca = CA_default
555+
[ CA_default ]
556+
x509_extensions = usr_cert
557+
[ req ]
558+
default_bits = 2048
559+
default_md = sha256
560+
default_keyfile = privkey.pem
561+
distinguished_name = req_distinguished_name
562+
attributes = req_attributes
563+
x509_extensions = v3_ca
564+
string_mask = utf8only
565+
[ req_distinguished_name ]
566+
[ req_attributes ]
567+
[ usr_cert ]
568+
basicConstraints = CA:FALSE
569+
nsComment = "OpenSSL Generated Certificate"
570+
subjectKeyIdentifier = hash
571+
authorityKeyIdentifier = keyid,issuer
572+
[ v3_ca ]
573+
subjectKeyIdentifier = hash
574+
authorityKeyIdentifier = keyid:always,issuer
575+
basicConstraints = CA:true
576+
EOF
577+
```
578+
579+
* build ca certificates:
580+
```
581+
openssl genrsa -out ca.key 2048
582+
openssl req -x509 -new -nodes -key ca.key -subj "/CN=example.ca.com" -days 5000 -out ca.crt
583+
```
584+
585+
* build frps certificates:
586+
```
587+
openssl genrsa -out server.key 2048
588+
589+
openssl req -new -sha256 -key server.key \
590+
-subj "/C=XX/ST=DEFAULT/L=DEFAULT/O=DEFAULT/CN=server.com" \
591+
-reqexts SAN \
592+
-config <(cat my-openssl.cnf <(printf "\n[SAN]\nsubjectAltName=DNS:localhost,IP:127.0.0.1,DNS:example.server.com")) \
593+
-out server.csr
594+
595+
openssl x509 -req -days 365 \
596+
-in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
597+
-extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1,DNS:example.server.com") \
598+
-out server.crt
599+
```
600+
601+
* build frpc certificates:
602+
```
603+
openssl genrsa -out client.key 2048
604+
openssl req -new -sha256 -key client.key \
605+
-subj "/C=XX/ST=DEFAULT/L=DEFAULT/O=DEFAULT/CN=client.com" \
606+
-reqexts SAN \
607+
-config <(cat my-openssl.cnf <(printf "\n[SAN]\nsubjectAltName=DNS:client.com,DNS:example.client.com")) \
608+
-out client.csr
609+
610+
openssl x509 -req -days 365 \
611+
-in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
612+
-extfile <(printf "subjectAltName=DNS:client.com,DNS:example.client.com") \
613+
-out client.crt
614+
```
523615

524616
### Hot-Reloading frpc configuration
525617

@@ -967,6 +1059,6 @@ frp QQ group: 606194980
9671059

9681060
![donation-wechatpay](/doc/pic/donate-wechatpay.png)
9691061

970-
### Paypal
1062+
### PayPal
9711063

972-
Donate money by [paypal](https://www.paypal.me/fatedier) to my account **[email protected]**.
1064+
Donate money by [PayPal](https://www.paypal.me/fatedier) to my account **[email protected]**.

Diff for: Release.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### New
2+
3+
* New plugin `https2https`.
4+
* frpc supports `tls_server_name` to override the default value from `server_addr`.
5+
6+
### Improvement
7+
8+
* Increase reconnect frequency if it occurs an network error between frpc and frps.
9+
110
### Fix
211

3-
* Reduce binary file size.
12+
* Fix panic issue about xtcp.

Diff for: client/admin.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package client
1616

1717
import (
18-
"fmt"
1918
"net"
2019
"net/http"
2120
"time"
@@ -31,7 +30,7 @@ var (
3130
httpServerWriteTimeout = 10 * time.Second
3231
)
3332

34-
func (svr *Service) RunAdminServer(addr string, port int) (err error) {
33+
func (svr *Service) RunAdminServer(address string) (err error) {
3534
// url router
3635
router := mux.NewRouter()
3736

@@ -51,7 +50,6 @@ func (svr *Service) RunAdminServer(addr string, port int) (err error) {
5150
http.Redirect(w, r, "/static/", http.StatusMovedPermanently)
5251
})
5352

54-
address := fmt.Sprintf("%s:%d", addr, port)
5553
server := &http.Server{
5654
Addr: address,
5755
Handler: router,

Diff for: client/admin_api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (svr *Service) apiReload(w http.ResponseWriter, r *http.Request) {
6262
return
6363
}
6464

65-
pxyCfgs, visitorCfgs, err := config.LoadAllConfFromIni(svr.cfg.User, content, newCommonCfg.Start)
65+
pxyCfgs, visitorCfgs, err := config.LoadAllProxyConfsFromIni(svr.cfg.User, content, newCommonCfg.Start)
6666
if err != nil {
6767
res.Code = 400
6868
res.Msg = err.Error()
@@ -243,7 +243,7 @@ func (svr *Service) apiGetConfig(w http.ResponseWriter, r *http.Request) {
243243
return
244244
}
245245

246-
rows := strings.Split(content, "\n")
246+
rows := strings.Split(string(content), "\n")
247247
newRows := make([]string, 0, len(rows))
248248
for _, row := range rows {
249249
row = strings.TrimSpace(row)

Diff for: client/control.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,17 @@ func (ctl *Control) connectServer() (conn net.Conn, err error) {
209209
conn = stream
210210
} else {
211211
var tlsConfig *tls.Config
212+
sn := ctl.clientCfg.TLSServerName
213+
if sn == "" {
214+
sn = ctl.clientCfg.ServerAddr
215+
}
212216

213217
if ctl.clientCfg.TLSEnable {
214218
tlsConfig, err = transport.NewClientTLSConfig(
215219
ctl.clientCfg.TLSCertFile,
216220
ctl.clientCfg.TLSKeyFile,
217221
ctl.clientCfg.TLSTrustedCaFile,
218-
ctl.clientCfg.ServerAddr)
222+
sn)
219223

220224
if err != nil {
221225
xl.Warn("fail to build tls configuration when connecting to server, err: %v", err)

Diff for: client/proxy/proxy.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (pxy *TCPProxy) Close() {
148148
}
149149

150150
func (pxy *TCPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
151-
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, pxy.limiter,
151+
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, pxy.cfg.GetBaseInfo(), pxy.limiter,
152152
conn, []byte(pxy.clientCfg.Token), m)
153153
}
154154

@@ -177,7 +177,7 @@ func (pxy *TCPMuxProxy) Close() {
177177
}
178178

179179
func (pxy *TCPMuxProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
180-
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, pxy.limiter,
180+
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, pxy.cfg.GetBaseInfo(), pxy.limiter,
181181
conn, []byte(pxy.clientCfg.Token), m)
182182
}
183183

@@ -206,7 +206,7 @@ func (pxy *HTTPProxy) Close() {
206206
}
207207

208208
func (pxy *HTTPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
209-
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, pxy.limiter,
209+
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, pxy.cfg.GetBaseInfo(), pxy.limiter,
210210
conn, []byte(pxy.clientCfg.Token), m)
211211
}
212212

@@ -235,7 +235,7 @@ func (pxy *HTTPSProxy) Close() {
235235
}
236236

237237
func (pxy *HTTPSProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
238-
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, pxy.limiter,
238+
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, pxy.cfg.GetBaseInfo(), pxy.limiter,
239239
conn, []byte(pxy.clientCfg.Token), m)
240240
}
241241

@@ -264,7 +264,7 @@ func (pxy *STCPProxy) Close() {
264264
}
265265

266266
func (pxy *STCPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
267-
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, pxy.limiter,
267+
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, pxy.cfg.GetBaseInfo(), pxy.limiter,
268268
conn, []byte(pxy.clientCfg.Token), m)
269269
}
270270

@@ -309,6 +309,10 @@ func (pxy *XTCPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
309309
raddr, _ := net.ResolveUDPAddr("udp",
310310
fmt.Sprintf("%s:%d", pxy.clientCfg.ServerAddr, pxy.serverUDPPort))
311311
clientConn, err := net.DialUDP("udp", nil, raddr)
312+
if err != nil {
313+
xl.Error("dial server udp addr error: %v", err)
314+
return
315+
}
312316
defer clientConn.Close()
313317

314318
err = msg.WriteMsg(clientConn, natHoleClientMsg)
@@ -410,7 +414,7 @@ func (pxy *XTCPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
410414
return
411415
}
412416

413-
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, pxy.limiter,
417+
HandleTCPWorkConnection(pxy.ctx, &pxy.cfg.LocalSvrConf, pxy.proxyPlugin, pxy.cfg.GetBaseInfo(), pxy.limiter,
414418
muxConn, []byte(pxy.cfg.Sk), m)
415419
}
416420

0 commit comments

Comments
 (0)