Skip to content

Commit

Permalink
Merge pull request #3668 from fatedier/dev
Browse files Browse the repository at this point in the history
bump version to v0.52.1
  • Loading branch information
fatedier authored Oct 11, 2023
2 parents 2d3af8a + 01a0d55 commit 31fa3f0
Show file tree
Hide file tree
Showing 26 changed files with 261 additions and 238 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ allowPorts = [

`vhostHTTPPort` and `vhostHTTPSPort` in frps can use same port with `bindPort`. frps will detect the connection's protocol and handle it correspondingly.

What you need to pay attention to is that if you want to configure `vhostHTTPSPort` and `bindPort` to the same port, you need to first set `transport.tls.disableCustomTLSFirstByte` to false.

We would like to try to allow multiple proxies bind a same remote port with different protocols in the future.

### Bandwidth Limit
Expand Down
13 changes: 5 additions & 8 deletions Release.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
### Features
### Fixes

* Configuration: We now support TOML, YAML, and JSON for configuration. Please note that INI is deprecated and will be removed in future releases. New features will only be available in TOML, YAML, or JSON. Users wanting these new features should switch their configuration format accordingly. #2521

### Breaking Changes

* Change the way to start the visitor through the command line from `frpc stcp --role=visitor xxx` to `frpc stcp visitor xxx`.
* Modified the semantics of the `server_addr` in the command line, no longer including the port. Added the `server_port` parameter to configure the port.
* No longer support range ports mapping in TOML/YAML/JSON.
* `transport.tls.disableCustomTLSFirstByte` doesn't have any effect.
* The Server API did not return the data correctly.
* The Dashboard is unable to display data.
* `natHoleStunServer` is missing a default value.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/frps/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<title>frps dashboard</title>
<script type="module" crossorigin src="./index-ea3edf22.js"></script>
<script type="module" crossorigin src="./index-9465253b.js"></script>
<link rel="stylesheet" href="./index-1e0c7400.css">
</head>

Expand Down
3 changes: 3 additions & 0 deletions client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ func (cm *ConnectionManager) realConnect() (net.Conn, error) {
// Make sure that if it is wss, the websocket hook is executed after the tls hook.
dialOptions = append(dialOptions, libdial.WithAfterHook(libdial.AfterHook{Hook: utilnet.DialHookWebsocket(protocol, tlsConfig.ServerName), Priority: 110}))
default:
dialOptions = append(dialOptions, libdial.WithAfterHook(libdial.AfterHook{
Hook: utilnet.DialHookCustomTLSHeadByte(tlsConfig != nil, lo.FromPtr(cm.cfg.Transport.TLS.DisableCustomTLSFirstByte)),
}))
dialOptions = append(dialOptions, libdial.WithTLSConfig(tlsConfig))
}

Expand Down
2 changes: 1 addition & 1 deletion conf/frps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ enablePrometheus = true
# console or real logFile path like ./frps.log
log.to = "./frps.log"
# trace, debug, info, warn, error
log.level = info
log.level = "info"
log.maxDays = 3
# disable log colors when log.to is console, default is false
log.disablePrintColor = false
Expand Down
1 change: 1 addition & 0 deletions pkg/config/legacy/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func Convert_ProxyConf_To_v1(conf ProxyConf) v1.ProxyConfigurer {
c := &v1.XTCPProxyConfig{ProxyBaseConfig: *outBase}
c.Secretkey = v.Sk
c.AllowUsers = v.AllowUsers
out = c
}
return out
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/legacy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type HTTPPluginOptions struct {
Addr string `ini:"addr"`
Path string `ini:"path"`
Ops []string `ini:"ops"`
TLSVerify bool `ini:"tls_verify"`
TLSVerify bool `ini:"tlsVerify"`
}

// ServerCommonConf contains information for a server service. It is
Expand Down
1 change: 1 addition & 0 deletions pkg/config/v1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (c *ClientCommonConfig) Complete() {
c.ServerAddr = util.EmptyOr(c.ServerAddr, "0.0.0.0")
c.ServerPort = util.EmptyOr(c.ServerPort, 7000)
c.LoginFailExit = util.EmptyOr(c.LoginFailExit, lo.ToPtr(true))
c.NatHoleSTUNServer = util.EmptyOr(c.NatHoleSTUNServer, "stun.easyvoip.com:3478")

c.Auth.Complete()
c.Log.Complete()
Expand Down
1 change: 1 addition & 0 deletions pkg/config/v1/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ func TestClientConfigComplete(t *testing.T) {
require.Equal(true, lo.FromPtr(c.LoginFailExit))
require.Equal(true, lo.FromPtr(c.Transport.TLS.Enable))
require.Equal(true, lo.FromPtr(c.Transport.TLS.DisableCustomTLSFirstByte))
require.NotEmpty(c.NatHoleSTUNServer)
}
2 changes: 1 addition & 1 deletion pkg/config/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type HTTPPluginOptions struct {
Addr string `json:"addr"`
Path string `json:"path"`
Ops []string `json:"ops"`
TLSVerify bool `json:"tls_verify,omitempty"`
TLSVerify bool `json:"tlsVerify,omitempty"`
}

type HeaderOperations struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/config/v1/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package v1

import (
"encoding/json"
"errors"
"fmt"
"reflect"
)
Expand All @@ -30,7 +29,7 @@ type TypedClientPluginOptions struct {

func (c *TypedClientPluginOptions) UnmarshalJSON(b []byte) error {
if len(b) == 4 && string(b) == "null" {
return errors.New("type is required")
return nil
}

typeStruct := struct {
Expand All @@ -41,6 +40,9 @@ func (c *TypedClientPluginOptions) UnmarshalJSON(b []byte) error {
}

c.Type = typeStruct.Type
if c.Type == "" {
return nil
}

v, ok := clientPluginOptionsTypeMap[typeStruct.Type]
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"
)

var version = "0.52.0"
var version = "0.52.1"

func Full() string {
return version
Expand Down
70 changes: 35 additions & 35 deletions server/dashboard_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ type GeneralResponse struct {

type serverInfoResp struct {
Version string `json:"version"`
BindPort int `json:"bind_port"`
VhostHTTPPort int `json:"vhost_http_port"`
VhostHTTPSPort int `json:"vhost_https_port"`
TCPMuxHTTPConnectPort int `json:"tcpmux_httpconnect_port"`
KCPBindPort int `json:"kcp_bind_port"`
QUICBindPort int `json:"quic_bind_port"`
SubdomainHost string `json:"subdomain_host"`
MaxPoolCount int64 `json:"max_pool_count"`
MaxPortsPerClient int64 `json:"max_ports_per_client"`
HeartBeatTimeout int64 `json:"heart_beat_timeout"`
AllowPortsStr string `json:"allow_ports_str,omitempty"`
TLSOnly bool `json:"tls_only,omitempty"`

TotalTrafficIn int64 `json:"total_traffic_in"`
TotalTrafficOut int64 `json:"total_traffic_out"`
CurConns int64 `json:"cur_conns"`
ClientCounts int64 `json:"client_counts"`
ProxyTypeCounts map[string]int64 `json:"proxy_type_count"`
BindPort int `json:"bindPort"`
VhostHTTPPort int `json:"vhostHTTPPort"`
VhostHTTPSPort int `json:"vhostHTTPSPort"`
TCPMuxHTTPConnectPort int `json:"tcpmuxHTTPConnectPort"`
KCPBindPort int `json:"kcpBindPort"`
QUICBindPort int `json:"quicBindPort"`
SubdomainHost string `json:"subdomainHost"`
MaxPoolCount int64 `json:"maxPoolCount"`
MaxPortsPerClient int64 `json:"maxPortsPerClient"`
HeartBeatTimeout int64 `json:"heartbeatTimeout"`
AllowPortsStr string `json:"allowPortsStr,omitempty"`
TLSForce bool `json:"tlsForce,omitempty"`

TotalTrafficIn int64 `json:"totalTrafficIn"`
TotalTrafficOut int64 `json:"totalTrafficOut"`
CurConns int64 `json:"curConns"`
ClientCounts int64 `json:"clientCounts"`
ProxyTypeCounts map[string]int64 `json:"proxyTypeCount"`
}

// /healthz
Expand Down Expand Up @@ -85,7 +85,7 @@ func (svr *Service) APIServerInfo(w http.ResponseWriter, r *http.Request) {
MaxPortsPerClient: svr.cfg.MaxPortsPerClient,
HeartBeatTimeout: svr.cfg.Transport.HeartbeatTimeout,
AllowPortsStr: types.PortsRangeSlice(svr.cfg.AllowPorts).String(),
TLSOnly: svr.cfg.Transport.TLS.Force,
TLSForce: svr.cfg.Transport.TLS.Force,

TotalTrafficIn: serverStats.TotalTrafficIn,
TotalTrafficOut: serverStats.TotalTrafficOut,
Expand All @@ -104,7 +104,7 @@ type BaseOutConf struct {

type TCPOutConf struct {
BaseOutConf
RemotePort int `json:"remote_port"`
RemotePort int `json:"remotePort"`
}

type TCPMuxOutConf struct {
Expand All @@ -115,14 +115,14 @@ type TCPMuxOutConf struct {

type UDPOutConf struct {
BaseOutConf
RemotePort int `json:"remote_port"`
RemotePort int `json:"remotePort"`
}

type HTTPOutConf struct {
BaseOutConf
v1.DomainConfig
Locations []string `json:"locations"`
HostHeaderRewrite string `json:"host_header_rewrite"`
HostHeaderRewrite string `json:"hostHeaderRewrite"`
}

type HTTPSOutConf struct {
Expand Down Expand Up @@ -163,12 +163,12 @@ func getConfByType(proxyType string) any {
type ProxyStatsInfo struct {
Name string `json:"name"`
Conf interface{} `json:"conf"`
ClientVersion string `json:"client_version,omitempty"`
TodayTrafficIn int64 `json:"today_traffic_in"`
TodayTrafficOut int64 `json:"today_traffic_out"`
CurConns int64 `json:"cur_conns"`
LastStartTime string `json:"last_start_time"`
LastCloseTime string `json:"last_close_time"`
ClientVersion string `json:"clientVersion,omitempty"`
TodayTrafficIn int64 `json:"todayTrafficIn"`
TodayTrafficOut int64 `json:"todayTrafficOut"`
CurConns int64 `json:"curConns"`
LastStartTime string `json:"lastStartTime"`
LastCloseTime string `json:"lastCloseTime"`
Status string `json:"status"`
}

Expand Down Expand Up @@ -236,11 +236,11 @@ func (svr *Service) getProxyStatsByType(proxyType string) (proxyInfos []*ProxySt
type GetProxyStatsResp struct {
Name string `json:"name"`
Conf interface{} `json:"conf"`
TodayTrafficIn int64 `json:"today_traffic_in"`
TodayTrafficOut int64 `json:"today_traffic_out"`
CurConns int64 `json:"cur_conns"`
LastStartTime string `json:"last_start_time"`
LastCloseTime string `json:"last_close_time"`
TodayTrafficIn int64 `json:"todayTrafficIn"`
TodayTrafficOut int64 `json:"todayTrafficOut"`
CurConns int64 `json:"curConns"`
LastStartTime string `json:"lastStartTime"`
LastCloseTime string `json:"lastCloseTime"`
Status string `json:"status"`
}

Expand Down Expand Up @@ -310,8 +310,8 @@ func (svr *Service) getProxyStatsByTypeAndName(proxyType string, proxyName strin
// /api/traffic/:name
type GetProxyTrafficResp struct {
Name string `json:"name"`
TrafficIn []int64 `json:"traffic_in"`
TrafficOut []int64 `json:"traffic_out"`
TrafficIn []int64 `json:"trafficIn"`
TrafficOut []int64 `json:"trafficOut"`
}

func (svr *Service) APIProxyTraffic(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/framework/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ log.level = "trace"
DefaultClientConfig = `
serverAddr = "127.0.0.1"
serverPort = {{ .%s }}
loginFailExit = false
log.level = "trace"
`

Expand All @@ -38,6 +39,7 @@ log.level = "trace"
[common]
server_addr = 127.0.0.1
server_port = {{ .%s }}
login_fail_exit = false
log_level = trace
`
)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/framework/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []str
currentServerProcesses = append(currentServerProcesses, p)
err = p.Start()
ExpectNoError(err)
time.Sleep(500 * time.Millisecond)
}
time.Sleep(1 * time.Second)

Expand Down
20 changes: 19 additions & 1 deletion test/e2e/v1/basic/client_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ var _ = ginkgo.Describe("[Feature: Client-Server]", func() {
})
})

ginkgo.Describe("TLS with disable_custom_tls_first_byte set to false", func() {
ginkgo.Describe("TLS with disableCustomTLSFirstByte set to false", func() {
supportProtocols := []string{"tcp", "kcp", "quic", "websocket"}
for _, protocol := range supportProtocols {
tmp := protocol
Expand Down Expand Up @@ -322,4 +322,22 @@ var _ = ginkgo.Describe("[Feature: Client-Server]", func() {
})
}
})

ginkgo.Describe("Use same port for bindPort and vhostHTTPSPort", func() {
supportProtocols := []string{"tcp", "kcp", "quic", "websocket"}
for _, protocol := range supportProtocols {
tmp := protocol
defineClientServerTest("Use same port for bindPort and vhostHTTPSPort: "+strings.ToUpper(tmp), f, &generalTestConfigures{
server: fmt.Sprintf(`
vhostHTTPSPort = {{ .%s }}
%s
`, consts.PortServerName, renderBindPortConfig(protocol)),
// transport.tls.disableCustomTLSFirstByte should set to false when vhostHTTPSPort is same as bindPort
client: fmt.Sprintf(`
transport.protocol = "%s"
transport.tls.disableCustomTLSFirstByte = false
`, protocol),
})
}
})
})
4 changes: 3 additions & 1 deletion web/frps/auto-imports.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Generated by 'unplugin-auto-import'
export {}
declare global {}
declare global {

}
12 changes: 6 additions & 6 deletions web/frps/src/components/ProxiesHTTP.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import ProxyView from './ProxyView.vue'
let proxies = ref<HTTPProxy[]>([])
const fetchData = () => {
let vhost_http_port: number
let subdomain_host: string
let vhostHTTPPort: number
let subdomainHost: string
fetch('../api/serverinfo', { credentials: 'include' })
.then((res) => {
return res.json()
})
.then((json) => {
vhost_http_port = json.vhost_http_port
subdomain_host = json.subdomain_host
if (vhost_http_port == null || vhost_http_port == 0) {
vhostHTTPPort = json.vhostHTTPPort
subdomainHost = json.subdomainHost
if (vhostHTTPPort == null || vhostHTTPPort == 0) {
return
}
fetch('../api/proxy/http', { credentials: 'include' })
Expand All @@ -29,7 +29,7 @@ const fetchData = () => {
.then((json) => {
for (let proxyStats of json.proxies) {
proxies.value.push(
new HTTPProxy(proxyStats, vhost_http_port, subdomain_host)
new HTTPProxy(proxyStats, vhostHTTPPort, subdomainHost)
)
}
})
Expand Down
12 changes: 6 additions & 6 deletions web/frps/src/components/ProxiesHTTPS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import ProxyView from './ProxyView.vue'
let proxies = ref<HTTPSProxy[]>([])
const fetchData = () => {
let vhost_https_port: number
let subdomain_host: string
let vhostHTTPSPort: number
let subdomainHost: string
fetch('../api/serverinfo', { credentials: 'include' })
.then((res) => {
return res.json()
})
.then((json) => {
vhost_https_port = json.vhost_https_port
subdomain_host = json.subdomain_host
if (vhost_https_port == null || vhost_https_port == 0) {
vhostHTTPSPort = json.vhostHTTPSPort
subdomainHost = json.subdomainHost
if (vhostHTTPSPort == null || vhostHTTPSPort == 0) {
return
}
fetch('../api/proxy/https', { credentials: 'include' })
Expand All @@ -29,7 +29,7 @@ const fetchData = () => {
.then((json) => {
for (let proxyStats of json.proxies) {
proxies.value.push(
new HTTPSProxy(proxyStats, vhost_https_port, subdomain_host)
new HTTPSProxy(proxyStats, vhostHTTPSPort, subdomainHost)
)
}
})
Expand Down
Loading

0 comments on commit 31fa3f0

Please sign in to comment.