Skip to content

Commit

Permalink
Merge pull request #3454 from fatedier/dev
Browse files Browse the repository at this point in the history
release v0.49.0
  • Loading branch information
fatedier committed May 28, 2023
2 parents 8fb99ef + 9806840 commit 0d6d968
Show file tree
Hide file tree
Showing 88 changed files with 4,063 additions and 1,806 deletions.
10 changes: 10 additions & 0 deletions .github/pull_request_template.md
@@ -0,0 +1,10 @@
### Summary

copilot:summary

### WHY
<!-- author to complete -->

### Walkthrough

copilot:walkthrough
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -19,6 +19,9 @@ fmt:
fmt-more:
gofumpt -l -w .

gci:
gci write -s standard -s default -s "prefix(github.com/fatedier/frp/)" ./

vet:
go vet ./...

Expand Down
25 changes: 9 additions & 16 deletions README.md
@@ -1,4 +1,3 @@

# frp

[![Build Status](https://circleci.com/gh/fatedier/frp.svg?style=shield)](https://circleci.com/gh/fatedier/frp)
Expand All @@ -12,12 +11,7 @@
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=frp&utm_source=github" target="_blank">
<img width="350px" src="https://raw.githubusercontent.com/fatedier/frp/dev/doc/pic/sponsor_workos.png">
</a>
<a>&nbsp</a>
<a href="https://asocks.com/c/vDu6Dk" target="_blank">
<img width="350px" src="https://raw.githubusercontent.com/fatedier/frp/dev/doc/pic/sponsor_asocks.jpg">
</a>
</p>

<!--gold sponsors end-->

## What is frp?
Expand Down Expand Up @@ -349,20 +343,15 @@ Configure `frps` same as above.

Note that it may not work with all types of NAT devices. You might want to fallback to stcp if xtcp doesn't work.

1. In `frps.ini` configure a UDP port for xtcp:

```ini
# frps.ini
bind_udp_port = 7001
```

2. Start `frpc` on machine B, and expose the SSH port. Note that the `remote_port` field is removed:
1. Start `frpc` on machine B, and expose the SSH port. Note that the `remote_port` field is removed:

```ini
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
# set up a new stun server if the default one is not available.
# nat_hole_stun_server = xxx

[p2p_ssh]
type = xtcp
Expand All @@ -371,13 +360,15 @@ Note that it may not work with all types of NAT devices. You might want to fallb
local_port = 22
```

3. Start another `frpc` (typically on another machine C) with the configuration to connect to SSH using P2P mode:
2. Start another `frpc` (typically on another machine C) with the configuration to connect to SSH using P2P mode:

```ini
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
# set up a new stun server if the default one is not available.
# nat_hole_stun_server = xxx

[p2p_ssh_visitor]
type = xtcp
Expand All @@ -386,9 +377,11 @@ Note that it may not work with all types of NAT devices. You might want to fallb
sk = abcdefg
bind_addr = 127.0.0.1
bind_port = 6000
# when automatic tunnel persistence is required, set it to true
keep_tunnel_open = false
```

4. On machine C, connect to SSH on machine B, using this command:
3. On machine C, connect to SSH on machine B, using this command:

`ssh -oPort=6000 127.0.0.1`

Expand Down
6 changes: 1 addition & 5 deletions README_zh.md
@@ -1,6 +1,6 @@
# frp

[![Build Status](https://travis-ci.org/fatedier/frp.svg?branch=master)](https://travis-ci.org/fatedier/frp)
[![Build Status](https://circleci.com/gh/fatedier/frp.svg?style=shield)](https://circleci.com/gh/fatedier/frp)
[![GitHub release](https://img.shields.io/github/tag/fatedier/frp.svg?label=release)](https://github.com/fatedier/frp/releases)

[README](README.md) | [中文文档](README_zh.md)
Expand All @@ -13,10 +13,6 @@ frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=frp&utm_source=github" target="_blank">
<img width="350px" src="https://raw.githubusercontent.com/fatedier/frp/dev/doc/pic/sponsor_workos.png">
</a>
<a>&nbsp</a>
<a href="https://asocks.com/c/vDu6Dk" target="_blank">
<img width="350px" src="https://raw.githubusercontent.com/fatedier/frp/dev/doc/pic/sponsor_asocks.jpg">
</a>
</p>
<!--gold sponsors end-->

Expand Down
19 changes: 15 additions & 4 deletions Release.md
@@ -1,8 +1,19 @@
## Notes

We have thoroughly refactored xtcp in this version to improve its penetration rate and stability.

In this version, different penetration strategies can be attempted by retrying connections multiple times. Once a hole is successfully punched, the strategy will be recorded in the server cache for future reuse. When new users connect, the successfully penetrated tunnel can be reused instead of punching a new hole.

**Due to a significant refactor of xtcp, this version is not compatible with previous versions of xtcp.**

**To use features related to xtcp, both frpc and frps need to be updated to the latest version.**

### New

* The `httpconnect` type in `tcpmux` now supports authentication through the parameters `http_user` and `http_pwd`.
* The frpc has added the `nathole discover` command for testing the NAT type of the current network.
* `XTCP` has been refactored, resulting in a significant improvement in the success rate of penetration.
* When verifying passwords, use `subtle.ConstantTimeCompare` and introduce a certain delay when the password is incorrect.

### Improved
### Fix

* The web framework has been upgraded to vue3 + element-plus, and the dashboard has added some information display and supports dark mode.
* The e2e testing has been switched to ginkgo v2.
* Fix the problem of lagging when opening multiple table entries in the frps dashboard.
32 changes: 32 additions & 0 deletions assets/frpc/static/index-1c7ed8b0.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/frpc/static/index-1e2a7ce0.css

Large diffs are not rendered by default.

32 changes: 0 additions & 32 deletions assets/frpc/static/index-7dd223da.js

This file was deleted.

1 change: 0 additions & 1 deletion assets/frpc/static/index-aa3c7267.css

This file was deleted.

4 changes: 2 additions & 2 deletions assets/frpc/static/index.html
Expand Up @@ -4,8 +4,8 @@
<head>
<meta charset="utf-8">
<title>frp client admin UI</title>
<script type="module" crossorigin src="./index-7dd223da.js"></script>
<link rel="stylesheet" href="./index-aa3c7267.css">
<script type="module" crossorigin src="./index-1c7ed8b0.js"></script>
<link rel="stylesheet" href="./index-1e2a7ce0.css">
</head>

<body>
Expand Down
1 change: 1 addition & 0 deletions assets/frps/static/index-1e0c7400.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion assets/frps/static/index-7b4711f8.css

This file was deleted.

74 changes: 74 additions & 0 deletions assets/frps/static/index-93e38bbf.js

Large diffs are not rendered by default.

74 changes: 0 additions & 74 deletions assets/frps/static/index-b8250b3f.js

This file was deleted.

4 changes: 2 additions & 2 deletions assets/frps/static/index.html
Expand Up @@ -4,8 +4,8 @@
<head>
<meta charset="utf-8">
<title>frps dashboard</title>
<script type="module" crossorigin src="./index-b8250b3f.js"></script>
<link rel="stylesheet" href="./index-7b4711f8.css">
<script type="module" crossorigin src="./index-93e38bbf.js"></script>
<link rel="stylesheet" href="./index-1e0c7400.css">
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion client/admin.go
Expand Up @@ -48,7 +48,7 @@ func (svr *Service) RunAdminServer(address string) (err error) {

subRouter := router.NewRoute().Subrouter()
user, passwd := svr.cfg.AdminUser, svr.cfg.AdminPwd
subRouter.Use(frpNet.NewHTTPAuthMiddleware(user, passwd).Middleware)
subRouter.Use(frpNet.NewHTTPAuthMiddleware(user, passwd).SetAuthFailDelay(200 * time.Millisecond).Middleware)

// api, see admin_api.go
subRouter.HandleFunc("/api/reload", svr.apiReload).Methods("GET")
Expand Down
5 changes: 3 additions & 2 deletions client/admin_api.go
Expand Up @@ -25,10 +25,11 @@ import (
"strconv"
"strings"

"github.com/samber/lo"

"github.com/fatedier/frp/client/proxy"
"github.com/fatedier/frp/pkg/config"
"github.com/fatedier/frp/pkg/util/log"
"github.com/fatedier/frp/pkg/util/util"
)

type GeneralResponse struct {
Expand Down Expand Up @@ -98,7 +99,7 @@ func NewProxyStatusResp(status *proxy.WorkingStatus, serverAddr string) ProxySta

if status.Err == "" {
psr.RemoteAddr = status.RemoteAddr
if util.InSlice(status.Type, []string{"tcp", "udp"}) {
if lo.Contains([]string{"tcp", "udp"}, status.Type) {
psr.RemoteAddr = serverAddr + psr.RemoteAddr
}
}
Expand Down
48 changes: 30 additions & 18 deletions client/control.go
Expand Up @@ -25,22 +25,29 @@ import (
"github.com/fatedier/golib/crypto"

"github.com/fatedier/frp/client/proxy"
"github.com/fatedier/frp/client/visitor"
"github.com/fatedier/frp/pkg/auth"
"github.com/fatedier/frp/pkg/config"
"github.com/fatedier/frp/pkg/msg"
"github.com/fatedier/frp/pkg/transport"
"github.com/fatedier/frp/pkg/util/xlog"
)

type Control struct {
// uniq id got from frps, attach it in loginMsg
// service context
ctx context.Context
xl *xlog.Logger

// Unique ID obtained from frps.
// It should be attached to the login message when reconnecting.
runID string

// manage all proxies
pxyCfgs map[string]config.ProxyConf
pm *proxy.Manager

// manage all visitors
vm *VisitorManager
vm *visitor.Manager

// control connection
conn net.Conn
Expand Down Expand Up @@ -68,28 +75,23 @@ type Control struct {
writerShutdown *shutdown.Shutdown
msgHandlerShutdown *shutdown.Shutdown

// The UDP port that the server is listening on
serverUDPPort int

xl *xlog.Logger

// service context
ctx context.Context

// sets authentication based on selected method
authSetter auth.Setter

msgTransporter transport.MessageTransporter
}

func NewControl(
ctx context.Context, runID string, conn net.Conn, cm *ConnectionManager,
clientCfg config.ClientCommonConf,
pxyCfgs map[string]config.ProxyConf,
visitorCfgs map[string]config.VisitorConf,
serverUDPPort int,
authSetter auth.Setter,
) *Control {
// new xlog instance
ctl := &Control{
ctx: ctx,
xl: xlog.FromContextSafe(ctx),
runID: runID,
conn: conn,
cm: cm,
Expand All @@ -102,14 +104,12 @@ func NewControl(
readerShutdown: shutdown.New(),
writerShutdown: shutdown.New(),
msgHandlerShutdown: shutdown.New(),
serverUDPPort: serverUDPPort,
xl: xlog.FromContextSafe(ctx),
ctx: ctx,
authSetter: authSetter,
}
ctl.pm = proxy.NewManager(ctl.ctx, ctl.sendCh, clientCfg, serverUDPPort)
ctl.msgTransporter = transport.NewMessageTransporter(ctl.sendCh)
ctl.pm = proxy.NewManager(ctl.ctx, clientCfg, ctl.msgTransporter)

ctl.vm = NewVisitorManager(ctl.ctx, ctl)
ctl.vm = visitor.NewManager(ctl.ctx, ctl.clientCfg, ctl.connectServer, ctl.msgTransporter)
ctl.vm.Reload(visitorCfgs)
return ctl
}
Expand Down Expand Up @@ -173,6 +173,16 @@ func (ctl *Control) HandleNewProxyResp(inMsg *msg.NewProxyResp) {
}
}

func (ctl *Control) HandleNatHoleResp(inMsg *msg.NatHoleResp) {
xl := ctl.xl

// Dispatch the NatHoleResp message to the related proxy.
ok := ctl.msgTransporter.DispatchWithType(inMsg, msg.TypeNameNatHoleResp, inMsg.TransactionID)
if !ok {
xl.Trace("dispatch NatHoleResp message to related proxy error")
}
}

func (ctl *Control) Close() error {
return ctl.GracefulClose(0)
}
Expand All @@ -188,7 +198,7 @@ func (ctl *Control) GracefulClose(d time.Duration) error {
return nil
}

// ClosedDoneCh returns a channel which will be closed after all resources are released
// ClosedDoneCh returns a channel that will be closed after all resources are released
func (ctl *Control) ClosedDoneCh() <-chan struct{} {
return ctl.closedDoneCh
}
Expand Down Expand Up @@ -250,7 +260,7 @@ func (ctl *Control) writer() {
}
}

// msgHandler handles all channel events and do corresponding operations.
// msgHandler handles all channel events and performs corresponding operations.
func (ctl *Control) msgHandler() {
xl := ctl.xl
defer func() {
Expand Down Expand Up @@ -307,6 +317,8 @@ func (ctl *Control) msgHandler() {
go ctl.HandleReqWorkConn(m)
case *msg.NewProxyResp:
ctl.HandleNewProxyResp(m)
case *msg.NatHoleResp:
ctl.HandleNatHoleResp(m)
case *msg.Pong:
if m.Error != "" {
xl.Error("Pong contains error: %s", m.Error)
Expand Down

0 comments on commit 0d6d968

Please sign in to comment.