77 Commits

Author SHA1 Message Date
fatedier 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
fatedier 55107d003d fix: synchronize service startup and shutdown (#5560) 2026-10-09 12:27:12 +08:00
fatedier 758f07d59e deps: migrate to fatedier/yamux v0.2.0 (#5498) 2026-08-18 00:24:11 +08:00
fatedier f6688e2a0d client: reject invalid work connection addresses (#5472) 2026-08-09 18:39:21 +08:00
fatedier f666d97b64 limit: clamp bandwidth limiter burst (#5471) 2026-08-09 17:30:39 +08:00
fatedier 2291e8835f feat: use binary codec for SUDP packets (#5461) 2026-07-31 16:53:16 +08:00
fatedier effa496859 feat: add negotiated binary UDP packets (#5456) 2026-07-30 13:19:55 +08:00
fatedier 0773938d70 feat: bridge mixed wire protocol SUDP payloads (#5347)
SUDP payload codec follows transport wireProtocol; same-protocol v1/v1 and v2/v2 keep raw join; only mixed proxy/visitor protocols use message-aware bridge; no new capability/selection field.
2026-06-01 16:22:34 +08:00
fatedier 9bacce22a2 feat: use wire v2 framing for XTCP NatHoleSid (#5343) 2026-06-01 16:22:34 +08:00
fatedier 7f8d68b666 feat: use wire v2 framing for UDP workConn payload (#5340) 2026-06-01 16:22:34 +08:00
Oleksandr Redko c2454e7114 refactor: fix modernize lint issues (#5215) 2026-03-07 23:10:19 +08:00
fatedier 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
fatedier 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
fatedier 462c987f6d pkg/msg: change UDPPacket.Content from string to []byte to avoid redundant base64 encode/decode (#5198) 2026-03-06 01:38:24 +08:00
fatedier 01997deb98 add persistent proxy/visitor store with CRUD API and web UI (#5188) 2026-03-02 01:09:59 +08:00
fatedier 7526d7a69a refactor: separate auth config from runtime and defer token resolution (#5105) 2025-12-25 00:53:08 +08:00
fatedier 80d3f332e1 xtcp: add configuration to disable assisted addresses in NAT traversal (#4951) 2025-08-25 15:52:52 +08:00
fatedier 3fa76b72f3 add proxy protocol support for UDP proxies (#4810) 2025-06-25 11:40:23 +08:00
fatedier a78814a2e9 virtual-net: initial (#4751) 2025-04-16 16:05:54 +08:00
Gabriel Marin 092e5d3f94 client, pkg, server, test: replaced 'interface{}' with 'any' (#4611) 2025-01-02 11:24:08 +08:00
fatedier f7a06cbe61 use go1.23 (#4495) 2024-10-17 17:22:41 +08:00
fatedier 69cc422edf client plugin: added plugin tls2raw (#4341) 2024-07-25 14:28:17 +08:00
fatedier dd7e2e8473 return 504 instead of 404 for proxy type http request timeout (#4151) 2024-04-11 20:19:08 +08:00
fatedier 590ccda677 fix x-forwarded-for header (#4111) 2024-03-28 16:47:27 +08:00
fatedier 43ba7bd338 use new log package (#4054) 2024-03-12 13:58:53 +08:00
fatedier 69ae2b0b69 optimize some code (#3801) 2023-11-27 15:47:49 +08:00
fatedier d5b41f1e14 sshTunnelGateway refactor (#3784) 2023-11-22 14:35:37 +08:00
Aarni Koskela f5d5a00eef Fix various typos (#3783) 2023-11-22 14:30:22 +08:00
fatedier 5e70d5bee0 code optimization (#3625) 2023-09-20 15:18:50 +08:00
fatedier c95311d1a0 support yaml/json/toml configuration format, make ini deprecated (#3599) 2023-09-06 10:18:02 +08:00
fatedier e9e12cf888 fix incorrect use of snappy pool (#3549) 2023-07-25 21:31:26 +08:00
fatedier 46ff40543a update github actions (#3538) 2023-07-21 10:30:46 +08:00
fatedier efcc028a3d fix a race condition issue (#3536) 2023-07-20 22:32:32 +08:00
fatedier 685d7618f3 change default value of tls_enable and disable_custom_tls_first_byte (#3494) 2023-06-26 00:10:27 +08:00
fatedier ea08de668e yamux: change default MaxStreamWindowSize to 6MB (#3474) 2023-06-04 19:58:55 +08:00
fatedier cceab7e1b1 client/proxy: simplify the code (#3465) 2023-05-30 22:18:56 +08:00
fatedier 9aef3b9944 adjust code style about config (#3464) 2023-05-30 20:25:22 +08:00
fatedier 555db9d272 format import package name (#3455) 2023-05-29 14:10:34 +08:00
fatedier c71efde303 refactor the code related to xtcp (#3449) 2023-05-28 16:50:43 +08:00
fatedier 8f394dba27 trace log adds join errors (#3352) 2023-03-11 19:34:06 +08:00
fatedier fccd518512 frpc: add parameter nat_hole_server_addr (#3351) 2023-03-10 15:51:14 +08:00
Craig O'Donnell 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
fatedier 9d077b02cf lint by golangci-lint (#3080) 2022-08-29 01:02:53 +08:00
chenjiayao 1bc899ec12 [client] Remove redundant function parameters (#3016) 2022-07-14 15:31:32 +08:00
fatedier c652b8ef07 fix ipv6 address parsing (#2978) 2022-06-14 14:24:34 +08:00
cui fliter 915d9f4c09 fix some typos (#2882)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-02 17:35:51 +08:00
fatedier 10100c28d9 client: add dial_server_timeout (#2805) 2022-02-19 16:49:21 +08:00
fatedier 6194273615 use net.JoinHostPort instead of fmt.Sprintf (#2791) 2022-02-09 15:19:35 +08:00
fatedier 70f4caac23 move dial functions into golib (#2767) 2022-01-20 20:03:07 +08:00
Blizard 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