Skip to content

Commit

Permalink
Merge pull request fatedier#1588 from fatedier/dev
Browse files Browse the repository at this point in the history
bump version to v0.31.0
  • Loading branch information
fatedier authored Jan 3, 2020
2 parents 75f3bce + 42014ee commit 30c246c
Show file tree
Hide file tree
Showing 27 changed files with 815 additions and 34 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ frp also has a P2P connect mode.
* [URL routing](#url-routing)
* [Connecting to frps via HTTP PROXY](#connecting-to-frps-via-http-proxy)
* [Range ports mapping](#range-ports-mapping)
* [Plugins](#plugins)
* [Client Plugins](#client-plugins)
* [Server Manage Plugins](#server-manage-plugins)
* [Development Plan](#development-plan)
* [Contributing](#contributing)
* [Donation](#donation)
Expand Down Expand Up @@ -806,7 +807,7 @@ remote_port = 6000-6006,6007

frpc will generate 8 proxies like `test_tcp_0`, `test_tcp_1`, ..., `test_tcp_7`.

### Plugins
### Client Plugins

frpc only forwards requests to local TCP or UDP ports by default.

Expand All @@ -828,6 +829,10 @@ plugin_http_passwd = abc

`plugin_http_user` and `plugin_http_passwd` are configuration parameters used in `http_proxy` plugin.

### Server Manage Plugins

Read the [document](/doc/server_plugin.md).

## Development Plan

* Log HTTP request information in frps.
Expand Down
11 changes: 8 additions & 3 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp
* [URL 路由](#url-路由)
* [通过代理连接 frps](#通过代理连接-frps)
* [范围端口映射](#范围端口映射)
* [插件](#插件)
* [客户端插件](#客户端插件)
* [服务端管理插件](#服务端管理插件)
* [开发计划](#开发计划)
* [为 frp 做贡献](#为-frp-做贡献)
* [捐助](#捐助)
Expand Down Expand Up @@ -858,11 +859,11 @@ remote_port = 6000-6006,6007

实际连接成功后会创建 8 个 proxy,命名为 `test_tcp_0, test_tcp_1 ... test_tcp_7`

### 插件
### 客户端插件

默认情况下,frpc 只会转发请求到本地 tcp 或 udp 端口。

插件模式是为了在客户端提供更加丰富的功能,目前内置的插件有 `unix_domain_socket``http_proxy``socks5``static_file`。具体使用方式请查看[使用示例](#使用示例)
客户端插件模式是为了在客户端提供更加丰富的功能,目前内置的插件有 `unix_domain_socket``http_proxy``socks5``static_file`。具体使用方式请查看[使用示例](#使用示例)

通过 `plugin` 指定需要使用的插件,插件的配置参数都以 `plugin_` 开头。使用插件后 `local_ip``local_port` 不再需要配置。

Expand All @@ -880,6 +881,10 @@ plugin_http_passwd = abc

`plugin_http_user``plugin_http_passwd` 即为 `http_proxy` 插件可选的配置参数。

### 服务端管理插件

[使用说明](/doc/server_plugin_zh.md)

## 开发计划

计划在后续版本中加入的功能与优化,排名不分先后,如果有其他功能建议欢迎在 [issues](https://github.com/fatedier/frp/issues) 中反馈。
Expand Down
4 changes: 2 additions & 2 deletions client/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/fatedier/frp/models/config"
"github.com/fatedier/frp/models/msg"
"github.com/fatedier/frp/models/plugin"
plugin "github.com/fatedier/frp/models/plugin/client"
"github.com/fatedier/frp/models/proto/udp"
"github.com/fatedier/frp/utils/limit"
frpNet "github.com/fatedier/frp/utils/net"
Expand Down Expand Up @@ -349,7 +349,7 @@ func (pxy *XtcpProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {

lConn.WriteToUDP(sidBuf[:n], uAddr)

kcpConn, err := frpNet.NewKcpConnFromUdp(lConn, false, natHoleRespMsg.VisitorAddr)
kcpConn, err := frpNet.NewKcpConnFromUdp(lConn, false, uAddr.String())
if err != nil {
xl.Error("create kcp connection from udp connection error: %v", err)
return
Expand Down
1 change: 1 addition & 0 deletions client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (svr *Service) login() (conn net.Conn, session *fmux.Session, err error) {
PrivilegeKey: util.GetAuthKey(svr.cfg.Token, now),
Timestamp: now,
RunId: svr.runId,
Metas: svr.cfg.Metas,
}

if err = msg.WriteMsg(conn, loginMsg); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions conf/frpc_full.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ tls_enable = true
# heartbeat_interval = 30
# heartbeat_timeout = 90

# additional meta info for client
meta_var1 = 123
meta_var2 = 234

# 'ssh' is the unique proxy name
# if user in [common] section is not empty, it will be changed to {user}.{proxy} such as 'your_name.ssh'
[ssh]
Expand Down Expand Up @@ -92,6 +96,9 @@ health_check_timeout_s = 3
health_check_max_failed = 3
# every 10 seconds will do a health check
health_check_interval_s = 10
# additional meta info for each proxy
meta_var1 = 123
meta_var2 = 234

[ssh_random]
type = tcp
Expand Down
10 changes: 10 additions & 0 deletions conf/frps_full.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,13 @@ tcp_mux = true

# custom 404 page for HTTP requests
# custom_404_page = /path/to/404.html

[plugin.user-manager]
addr = 127.0.0.1:9000
path = /handler
ops = Login

[plugin.port-manager]
addr = 127.0.0.1:9001
path = /handler
ops = NewProxy
171 changes: 171 additions & 0 deletions doc/server_plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
### Manage Plugin

frp manage plugin is aim to extend frp's ability without modifing self code.

It runs as a process and listen on a port to provide RPC interface. Before frps doing some operations, frps will send RPC requests to manage plugin and do operations by it's response.

### RPC request

Support HTTP first.

When manage plugin accept the operation request, it can give three different responses.

* Reject operation and return the reason.
* Allow operation and keep original content.
* Allow operation and return modified content.

### Interface

HTTP path can be configured for each manage plugin in frps. Assume here is `/handler`.

Request

```
POST /handler
{
"version": "0.1.0",
"op": "Login",
"content": {
... // Operation info
}
}
Request Header
X-Frp-Reqid: for tracing
```

Response

Error if not return 200 http code.

Reject opeartion

```
{
"reject": true,
"reject_reason": "invalid user"
}
```

Allow operation and keep original content

```
{
"reject": false,
"unchange": true
}
```

Allow opeartion and modify content

```
{
"unchange": "false",
"content": {
... // Replaced content
}
}
```

### Operation

Now it supports `Login` and `NewProxy`.

#### Login

Client login operation

```
{
"content": {
"version": <string>,
"hostname": <string>,
"os": <string>,
"arch": <string>,
"user": <string>,
"timestamp": <int64>,
"privilege_key": <string>,
"run_id": <string>,
"pool_count": <int>,
"metas": map<string>string
}
}
```

#### NewProxy

Create new proxy

```
{
"content": {
"user": {
"user": <string>,
"metas": map<string>string
},
"proxy_name": <string>,
"proxy_type": <string>,
"use_encryption": <bool>,
"use_compression": <bool>,
"group": <string>,
"group_key": <string>,
// tcp and udp only
"remote_port": <int>,
// http and https only
"custom_domains": []<string>,
"subdomain": <string>,
"locations": <string>,
"http_user": <string>,
"http_pwd": <string>,
"host_header_rewrite": <string>,
"headers": map<string>string,
"metas": map<string>string
}
}
```

### manage plugin configure

```ini
[common]
bind_port = 7000

[plugin.user-manager]
addr = 127.0.0.1:9000
path = /handler
ops = Login

[plugin.port-manager]
addr = 127.0.0.1:9001
path = /handler
ops = NewProxy
```

addr: plugin listen on.
path: http request url path.
ops: opeartions plugin needs handle.

### meta data

Meta data will be sent to manage plugin in each RCP request.

Meta data start with `meta_`. It can be configured in `common` and each proxy.

```
# frpc.ini
[common]
server_addr = 127.0.0.1
server_port = 7000
user = fake
meta_token = fake
meta_version = 1.0.0
[ssh]
type = tcp
local_port = 22
remote_port = 6000
meta_id = 123
```
Loading

0 comments on commit 30c246c

Please sign in to comment.