Commit Graph
56 Commits
Author SHA1 Message Date
fatedierandGitHub 00e4fc4dd3 feat(client): reload plugin certificates on frpc reload (#5576)
The https2http and https2https plugins read their certificate and key
once when the proxy starts, so a certificate that an external tool renews
on disk is only picked up after the proxy itself is recreated. frpc
reload rebuilt proxies only when their configuration changed, and a
rebuild closes the work connections that are already in use.

Let the plugin own the refresh. The HTTPS plugin server keeps the active
keypair and the last refresh error in one immutable snapshot published
through an atomic pointer, so a TLS handshake only loads that pointer and
never touches the disk. Reload rereads both files, and when their bytes
match the published pair it returns without parsing or replacing
anything; otherwise it parses the pair and swaps the snapshot in. A read
or parse failure keeps the previous certificate serving and records the
error next to it.

frpc reload collects the reloadable plugins of the live proxies and
applies the new configuration inside the same reload transaction that
also serializes control handoff, so a reload that races a reconnect
still refreshes the plugins of the published control. The certificate
files are read only after that transaction has been released. The config
store API keeps applying configuration without refreshing certificates,
because only an explicit reload may reread files. Proxy status reports a
refresh failure next to the still running proxy instead of dropping its
remote address.

No configuration field is added, and frps and the wire protocol are
unchanged. Without a reload nothing changes: certificates are still read
once at startup, generated self-signed certificates still never reload,
and a proxy whose configuration changed still goes through the existing
rebuild path.
2026-10-19 17:16:55 +08:00
fatedierandGitHub f6688e2a0d client: reject invalid work connection addresses (#5472) 2026-08-09 18:39:21 +08:00
fatedierandGitHub f666d97b64 limit: clamp bandwidth limiter burst (#5471) 2026-08-09 17:30:39 +08:00
fatedierandGitHub effa496859 feat: add negotiated binary UDP packets (#5456) 2026-07-30 13:19:55 +08:00
fatedierandGitHub cf396563f8 client/proxy: unify work conn wrapping across all proxy types (#5212)
* client/proxy: extract wrapWorkConn to deduplicate UDP/SUDP connection wrapping

Move the repeated rate-limiting, encryption, and compression wrapping
logic from UDPProxy and SUDPProxy into a shared BaseProxy.wrapWorkConn
method, reducing ~18 lines of duplication in each proxy type.

* client/proxy: unify work conn wrapping with pooled compression for all proxy types

Refactor wrapWorkConn to accept encKey parameter and return
(io.ReadWriteCloser, recycleFn, error), enabling HandleTCPWorkConnection
to reuse the same limiter/encryption/compression pipeline.

Switch all proxy types from WithCompression to WithCompressionFromPool.
TCP non-plugin path calls recycleFn via defer after Join; plugin and
UDP/SUDP paths skip recycle (objects are GC'd safely, per golib contract).
2026-03-07 01:33:37 +08:00
fatedierandGitHub c62a1da161 fix: close connections on error paths to prevent resource leaks (#5202)
Fix connection leaks in multiple error paths across client and server:
- server/proxy/http: close tmpConn when WithEncryption fails
- client/proxy: close localConn when ProxyProtocol WriteTo fails
- client/visitor/sudp: close visitorConn on all error paths in getNewVisitorConn
- client/visitor/xtcp: close tunnelConn when WithEncryption fails
- client/visitor/xtcp: close lConn when NewKCPConnFromUDP fails
- pkg/plugin/client/unix_domain_socket: close localConn and connInfo.Conn when WriteTo fails, close connInfo.Conn when DialUnix fails
- pkg/plugin/client/tls2raw: close tlsConn when Handshake or Dial fails
2026-03-06 15:18:38 +08:00
fatedierandGitHub 7526d7a69a refactor: separate auth config from runtime and defer token resolution (#5105) 2025-12-25 00:53:08 +08:00
fatedier 3fa76b72f3 add proxy protocol support for UDP proxies (#4810) 2025-06-25 11:40:23 +08:00
fatedierandGitHub a78814a2e9 virtual-net: initial (#4751) 2025-04-16 16:05:54 +08:00
fatedierandGitHub 69cc422edf client plugin: added plugin tls2raw (#4341) 2024-07-25 14:28:17 +08:00
fatedierandGitHub dd7e2e8473 return 504 instead of 404 for proxy type http request timeout (#4151) 2024-04-11 20:19:08 +08:00
fatedierandGitHub 590ccda677 fix x-forwarded-for header (#4111) 2024-03-28 16:47:27 +08:00
fatedierandGitHub 43ba7bd338 use new log package (#4054) 2024-03-12 13:58:53 +08:00
fatedier d5b41f1e14 sshTunnelGateway refactor (#3784) 2023-11-22 14:35:37 +08:00
fatedierandGitHub 5e70d5bee0 code optimization (#3625) 2023-09-20 15:18:50 +08:00
fatedierandGitHub c95311d1a0 support yaml/json/toml configuration format, make ini deprecated (#3599) 2023-09-06 10:18:02 +08:00
fatedierandGitHub e9e12cf888 fix incorrect use of snappy pool (#3549) 2023-07-25 21:31:26 +08:00
fatedierandGitHub efcc028a3d fix a race condition issue (#3536) 2023-07-20 22:32:32 +08:00
fatedierandGitHub cceab7e1b1 client/proxy: simplify the code (#3465) 2023-05-30 22:18:56 +08:00
fatedierandGitHub 9aef3b9944 adjust code style about config (#3464) 2023-05-30 20:25:22 +08:00
fatedierandGitHub 555db9d272 format import package name (#3455) 2023-05-29 14:10:34 +08:00
fatedierandGitHub c71efde303 refactor the code related to xtcp (#3449) 2023-05-28 16:50:43 +08:00
fatedierandGitHub 8f394dba27 trace log adds join errors (#3352) 2023-03-11 19:34:06 +08:00
fatedierandGitHub fccd518512 frpc: add parameter nat_hole_server_addr (#3351) 2023-03-10 15:51:14 +08:00
Craig O'DonnellandGitHub aa31d7ad0b support bandwidth_limit set by server plugin (#3271)
* support bandwidth_limit set by server plugin

* limiter at proxy level

* bandwidth_limit_mode

* updates tests for bandwidth_limit_mode default

* bandwidth_limit_mode as string

* add checkForSrv for bandwidth_limit_mode

* bandwidth_limit flags for sub cmds

* gci write
2023-02-09 00:38:36 +08:00
fatedierandGitHub 9d077b02cf lint by golangci-lint (#3080) 2022-08-29 01:02:53 +08:00
fatedierandGitHub c652b8ef07 fix ipv6 address parsing (#2978) 2022-06-14 14:24:34 +08:00
cui fliterandGitHub 915d9f4c09 fix some typos (#2882)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-02 17:35:51 +08:00
fatedierandGitHub 10100c28d9 client: add dial_server_timeout (#2805) 2022-02-19 16:49:21 +08:00
fatedierandGitHub 6194273615 use net.JoinHostPort instead of fmt.Sprintf (#2791) 2022-02-09 15:19:35 +08:00
fatedierandGitHub 70f4caac23 move dial functions into golib (#2767) 2022-01-20 20:03:07 +08:00
ea568e8a4f refactor: refine pkg net utils (#2720)
* refactor: refine pkg net utils

* fix: x

Co-authored-by: blizard863 <760076784@qq.com>
2021-12-28 21:14:57 +08:00
kekeimikuandGitHub 0cee1877e3 refactor: move from io/ioutil to io and os package (#2592) 2021-09-29 10:33:57 +08:00
fatedier fe4e9b55f3 update github.com/pires/go-proxyproto to v0.5.0 2021-06-21 19:35:52 +08:00
iikiraandGitHub 0a2384a283 fix XTCP error handling (#2273) 2021-03-03 20:54:46 +08:00
yuyuleiandGitHub 3621aad1c1 Reconstruct config (#2098)
* refactoring config

* Update by comments
2021-01-26 11:31:08 +08:00
fatedierandGitHub 3fbdea0f6b rename models to pkg (#2005) 2020-09-23 13:49:14 +08:00
fatedierandGitHub c9fe23eb10 more e2e tests (#1845) 2020-09-07 14:57:23 +08:00
fatedierandGitHub 8b75b8b837 fix by golint (#1822) 2020-05-24 17:48:37 +08:00
TankandGitHub d193519329 feat: Support user specify udp packet size in config (#1794) 2020-05-07 17:47:36 +08:00
TankandGitHub 4797136965 feat: support sudp proxy (#1730) 2020-04-22 21:37:45 +08:00
fatedierandGitHub 1db091b381 tcp multiplexing over http connect tunnel 2020-03-05 21:47:49 +08:00
fatedier 42014eea23 improve xtcp, fix #1585 2020-01-03 11:39:44 +08:00
fatedier 91e46a2c53 support server plugin feature 2019-12-23 20:00:04 +08:00
fatedier 12cc53d699 update bandwidth_limit 2019-11-09 01:13:30 +08:00
fatedier 6da093a402 support bandwith limit for one proxy 2019-11-03 01:20:49 +08:00
fatedier 649f47c345 change log method 2019-10-12 20:13:12 +08:00
fatedier fdc6902a90 proxy protocol: fix detect method for IPV4 and IPV6 2019-08-26 11:13:33 +08:00
Tyler Compton 666f122a72 Pass client configuration as an argument
The ClientCommonConf, configuration file path, and server UDP port are
now passed around as arguments instead of being shared between
components as global variables. This allows for multiple clients to
exist in the same process, and allows client.Session to be used as a
library more easily.
2019-08-20 14:08:01 -07:00
fatedier 6a1f15b25e support proxy protocol in unix_domain_socket 2019-04-25 12:01:57 +08:00