mirror of
https://github.com/fatedier/frp.git
synced 2025-06-17 17:18:21 +00:00
Compare commits
3 Commits
753ee10e3d
...
9e4e9e377f
Author | SHA1 | Date | |
---|---|---|---|
|
9e4e9e377f | ||
|
bc5fb91c05 | ||
|
002831ea82 |
19
README.md
19
README.md
@ -78,6 +78,7 @@ frp also offers a P2P connect mode.
|
|||||||
* [URL Routing](#url-routing)
|
* [URL Routing](#url-routing)
|
||||||
* [TCP Port Multiplexing](#tcp-port-multiplexing)
|
* [TCP Port Multiplexing](#tcp-port-multiplexing)
|
||||||
* [Connecting to frps via PROXY](#connecting-to-frps-via-proxy)
|
* [Connecting to frps via PROXY](#connecting-to-frps-via-proxy)
|
||||||
|
* [Port range mapping](#port-range-mapping)
|
||||||
* [Client Plugins](#client-plugins)
|
* [Client Plugins](#client-plugins)
|
||||||
* [Server Manage Plugins](#server-manage-plugins)
|
* [Server Manage Plugins](#server-manage-plugins)
|
||||||
* [SSH Tunnel Gateway](#ssh-tunnel-gateway)
|
* [SSH Tunnel Gateway](#ssh-tunnel-gateway)
|
||||||
@ -1158,6 +1159,24 @@ serverPort = 7000
|
|||||||
transport.proxyURL = "http://user:pwd@192.168.1.128:8080"
|
transport.proxyURL = "http://user:pwd@192.168.1.128:8080"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Port range mapping
|
||||||
|
|
||||||
|
*Added in v0.56.0*
|
||||||
|
|
||||||
|
We can use the range syntax of Go template combined with the built-in `parseNumberRangePair` function to achieve port range mapping.
|
||||||
|
|
||||||
|
The following example, when run, will create 8 proxies named `test-6000, test-6001 ... test-6007`, each mapping the remote port to the local port.
|
||||||
|
|
||||||
|
```
|
||||||
|
{{- range $_, $v := parseNumberRangePair "6000-6006,6007" "6000-6006,6007" }}
|
||||||
|
[[proxies]]
|
||||||
|
name = "tcp-{{ $v.First }}"
|
||||||
|
type = "tcp"
|
||||||
|
localPort = {{ $v.First }}
|
||||||
|
remotePort = {{ $v.Second }}
|
||||||
|
{{- end }}
|
||||||
|
```
|
||||||
|
|
||||||
### Client Plugins
|
### Client Plugins
|
||||||
|
|
||||||
frpc only forwards requests to local TCP or UDP ports by default.
|
frpc only forwards requests to local TCP or UDP ports by default.
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
This will create 8 proxies such as `tcp-6000, tcp-6001, ... tcp-6007`.
|
This will create 8 proxies such as `tcp-6000, tcp-6001, ... tcp-6007`.
|
||||||
|
|
||||||
|
* Health check supports custom request headers.
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
* Fix the issue of incorrect interval time for rotating the log by day.
|
* Fix the issue of incorrect interval time for rotating the log by day.
|
||||||
|
@ -41,7 +41,7 @@ type Monitor struct {
|
|||||||
|
|
||||||
// For http
|
// For http
|
||||||
url string
|
url string
|
||||||
|
header http.Header
|
||||||
failedTimes uint64
|
failedTimes uint64
|
||||||
statusOK bool
|
statusOK bool
|
||||||
statusNormalFn func()
|
statusNormalFn func()
|
||||||
@ -73,6 +73,11 @@ func NewMonitor(ctx context.Context, cfg v1.HealthCheckConfig, addr string,
|
|||||||
}
|
}
|
||||||
url = s + cfg.Path
|
url = s + cfg.Path
|
||||||
}
|
}
|
||||||
|
header := make(http.Header)
|
||||||
|
for _, h := range cfg.HTTPHeaders {
|
||||||
|
header.Set(h.Name, h.Value)
|
||||||
|
}
|
||||||
|
|
||||||
return &Monitor{
|
return &Monitor{
|
||||||
checkType: cfg.Type,
|
checkType: cfg.Type,
|
||||||
interval: time.Duration(cfg.IntervalSeconds) * time.Second,
|
interval: time.Duration(cfg.IntervalSeconds) * time.Second,
|
||||||
@ -80,6 +85,7 @@ func NewMonitor(ctx context.Context, cfg v1.HealthCheckConfig, addr string,
|
|||||||
maxFailedTimes: cfg.MaxFailed,
|
maxFailedTimes: cfg.MaxFailed,
|
||||||
addr: addr,
|
addr: addr,
|
||||||
url: url,
|
url: url,
|
||||||
|
header: header,
|
||||||
statusOK: false,
|
statusOK: false,
|
||||||
statusNormalFn: statusNormalFn,
|
statusNormalFn: statusNormalFn,
|
||||||
statusFailedFn: statusFailedFn,
|
statusFailedFn: statusFailedFn,
|
||||||
@ -163,6 +169,8 @@ func (monitor *Monitor) doHTTPCheck(ctx context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
req.Header = monitor.header
|
||||||
|
req.Host = monitor.header.Get("Host")
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -216,6 +216,10 @@ healthCheck.path = "/status"
|
|||||||
healthCheck.intervalSeconds = 10
|
healthCheck.intervalSeconds = 10
|
||||||
healthCheck.maxFailed = 3
|
healthCheck.maxFailed = 3
|
||||||
healthCheck.timeoutSeconds = 3
|
healthCheck.timeoutSeconds = 3
|
||||||
|
# set health check headers
|
||||||
|
healthCheck.httpHeaders=[
|
||||||
|
{ name = "x-from-where", value = "frp" }
|
||||||
|
]
|
||||||
|
|
||||||
[[proxies]]
|
[[proxies]]
|
||||||
name = "web02"
|
name = "web02"
|
||||||
|
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.22
|
|||||||
require (
|
require (
|
||||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
|
||||||
github.com/coreos/go-oidc/v3 v3.6.0
|
github.com/coreos/go-oidc/v3 v3.6.0
|
||||||
github.com/fatedier/golib v0.4.1
|
github.com/fatedier/golib v0.4.2
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
|
4
go.sum
4
go.sum
@ -24,8 +24,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/fatedier/golib v0.4.1 h1:C37VN3M+F3nUdh13laZsiyb5EXNe3tZnUdoHi+7rx+Q=
|
github.com/fatedier/golib v0.4.2 h1:k+ZBdUFTTipnP1RHfEhGbzyShRdz/rZtFGnjpXG9D9c=
|
||||||
github.com/fatedier/golib v0.4.1/go.mod h1:gpu+1vXxtJ072NYaNsn/YWgojDL8Ap2kFZQtbzT2qkg=
|
github.com/fatedier/golib v0.4.2/go.mod h1:gpu+1vXxtJ072NYaNsn/YWgojDL8Ap2kFZQtbzT2qkg=
|
||||||
github.com/fatedier/yamux v0.0.0-20230628132301-7aca4898904d h1:ynk1ra0RUqDWQfvFi5KtMiSobkVQ3cNc0ODb8CfIETo=
|
github.com/fatedier/yamux v0.0.0-20230628132301-7aca4898904d h1:ynk1ra0RUqDWQfvFi5KtMiSobkVQ3cNc0ODb8CfIETo=
|
||||||
github.com/fatedier/yamux v0.0.0-20230628132301-7aca4898904d/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
github.com/fatedier/yamux v0.0.0-20230628132301-7aca4898904d/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||||
github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA=
|
github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA=
|
||||||
|
@ -129,3 +129,8 @@ type HTTPPluginOptions struct {
|
|||||||
type HeaderOperations struct {
|
type HeaderOperations struct {
|
||||||
Set map[string]string `json:"set,omitempty"`
|
Set map[string]string `json:"set,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HTTPHeader struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
@ -97,6 +97,9 @@ type HealthCheckConfig struct {
|
|||||||
// Path specifies the path to send health checks to if the
|
// Path specifies the path to send health checks to if the
|
||||||
// health check type is "http".
|
// health check type is "http".
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
|
// HTTPHeaders specifies the headers to send with the health request, if
|
||||||
|
// the health check type is "http".
|
||||||
|
HTTPHeaders []HTTPHeader `json:"httpHeaders,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DomainConfig struct {
|
type DomainConfig struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user