Commit graph

1327 commits

Author SHA1 Message Date
Toby
42ebbc5576
feat(realm): add ipMode option to restrict connections to v4 or v6 (#1602)
Adds a new realm "ipMode" config option (v4 | v6 | dual, default dual)
on both client and server that restricts realm connections to a single
IP family end-to-end: the UDP socket is bound to udp4/udp6, STUN only
gathers addresses of that family, and hole punching only tries peer
candidates of that family.
2026-06-13 12:07:05 -07:00
Toby
33bb55a208
feat(realm): UPnP/NAT-PMP port mapping support (#1600) 2026-06-10 18:16:27 -07:00
白日梦主义
247c91321f
fix(outbounds): bound standard resolver CNAME chains (#1595)
The standardResolver's lookup4/lookup6 methods recursively follow CNAME
chains without any depth limit or cycle detection. A malicious or
misconfigured DNS server returning a self-referential CNAME record
(e.g. loop.example. CNAME loop.example.) causes infinite recursion,
leading to stack overflow and crash.

Add a max depth limit of 16 and a visited-set to detect cycles. The
original lookup4/lookup6 entry points are preserved; they delegate to
lookup4WithCNAMEDepth/lookup6WithCNAMEDepth which track depth and seen
hosts across recursive calls.
2026-06-04 18:16:18 -07:00
白日梦主义
8e78342c2b
fix(http): decode proxy Basic auth with standard base64 (#1596)
The HTTP proxy server's dispatch method decodes the Proxy-Authorization
Basic credential using base64.URLEncoding, but RFC 7617 specifies that
Basic authentication uses standard Base64 encoding (base64.StdEncoding).
The two encodings differ in their use of +/ vs -_ characters, so any
credential containing 0xff or other bytes that encode to / or + in
standard Base64 will fail to decode with URLEncoding, causing valid
authentication attempts to always be rejected with 407.

Additionally, the "Basic " scheme prefix check was case-sensitive, but
RFC 7235 section 2.1 specifies that auth-scheme is case-insensitive.

Fix both issues by switching to base64.StdEncoding and using
strings.ToLower for the scheme comparison.
2026-06-04 15:14:58 -07:00
白日梦主义
829d125ea2
fix(outbounds): use hostname for HTTPS proxy SNI (#1597)
The httpOutbound.dial() method incorrectly sets tls.Config.ServerName
to o.Addr, which is the "host:port" address string. TLS SNI must be a
pure hostname without a port number. Sending "host:port" as SNI causes
invalid TLS ClientHello messages and may prevent the proxy server from
correctly routing the connection.

Use o.ServerName instead, which is already correctly set to u.Hostname()
in NewHTTPOutbound.
2026-06-04 15:08:18 -07:00
l27001
f4c9de56cc
fix(certloader): add SKI, AKI, KeyUsage extensions to test certs (#1589)
OpenSSL 3.x requires Subject Key Identifier, Authority Key Identifier,
and Key Usage (keyCertSign) extensions for CA certificate chain
validation. The test certificate generator was missing these, causing
test failures on systems with OpenSSL 3.x.

Co-authored-by: Vladislav Tatjanin <l27001@altlinux.org>
2026-06-03 12:52:29 -07:00
Toby
c3a806b5cb
feat: gecko obfs (experimental) (#1584) 2026-05-22 20:35:41 -07:00
Toby
3b64f66995
fix(outbounds): incorrect use of SOCKS5 UDP dst.addr & dst.port (#1583) 2026-05-21 16:08:15 -07:00
Toby
2412f23646
Merge commit from fork
The UDP relay treated the destination address as packet-scoped while
applying ACL/outbound policy only once when a new session was created.
After an authenticated client opened a UDP session using a permitted
first destination, later packets carrying a different Addr in the same
SessionID were written via the established outbound socket without
re-checking policy, allowing the client to reach destinations that ACL
should reject — including localhost and RFC1918 from the server's
network perspective. See GHSA-vgrc-hq28-p3xp.

Add a no-I/O CheckUDP method to the Outbound / PluggableOutbound
chain. The UDP session entry now consults CheckUDP for every packet
whose destination differs from the session's first one, dropping
rejected packets before WriteTo. Decisions are cached per destination
within the session (bounded at 256 entries with simple eviction) so
steady-state cost is one map lookup per packet and no extra sockets
or dials. CheckUDP propagates through the existing chain:

  - aclEngine routes through the matched outbound's CheckUDP, with
    aclRejectOutbound returning the rejection error.
  - directOutbound / socks5Outbound / speedtestHandler return nil.
  - httpOutbound returns errHTTPUDPNotSupported.
  - Resolvers (system / dot / doh) run resolve() then forward to
    Next.CheckUDP so IP-based ACL rules keep matching.

Regression tests in core/internal/integration_tests/udp_acl_test.go
use an in-package stub Outbound to assert that a rejected destination
is not relayed after the session is opened on a permitted one, and
that multi-destination sessions over permitted addresses still work.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 14:09:41 -07:00
Toby
02d7b0a54d fix: format 2026-05-21 13:41:49 -07:00
白日梦主义
d6f24e13d7
Merge commit from fork
Signed-off-by: Cherrling <me@cherr.cc>
2026-05-21 13:11:40 -07:00
白日梦主义
89521dd80a
Merge commit from fork
Cap HTTP sniff reads to a fixed budget so incomplete or
oversized requests can't cause unbounded memory growth
while preserving normal sniff behavior.

Signed-off-by: Cherrling <me@cherr.cc>
2026-05-21 13:09:11 -07:00
Blossom
9f93125afe
docs: hyphenate compound modifiers in tagline (#1578) 2026-05-20 17:35:33 -07:00
白日梦主义
3991117d27
fix(acl): normalize trailing dot in domain matches (#1574)
* fix(acl): normalize trailing dot in domain matches

The ACL like

```yaml
    - reject(example.com)
    - reject(suffix:blocked.test)
    - reject(*.wild.test)
```

can be easily bypass through by adding a dot to the domain like

example.com.:443

Signed-off-by: Cherrling <me@cherr.cc>

* fix(acl): trim all trailing dots and add tests

Use strings.TrimRight instead of strings.TrimSuffix so domains with
multiple trailing dots (e.g. example.com..) are also normalized and
cannot bypass ACL rules. Add test coverage for trailing-dot handling
on exact, wildcard and suffix domain rules, as well as for trailing
dots in rule patterns.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Signed-off-by: Cherrling <me@cherr.cc>
Co-authored-by: Toby <tobyxdd@gmail.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 14:06:04 -07:00
prudhvi
0e2b37ad6c
Reuse 32KB buffers in copyBufferLog with sync.Pool (#1572)
* Bolt: Reuse 32KB buffers in copyBufferLog with sync.Pool

Delete .jules directory

* Add benchmark test for copyBufferLog function
2026-05-15 22:19:36 -07:00
白日梦主义
6dc0f3f792
fix: prefix match in DNS https (#1573)
Signed-off-by: Cherrling <me@cherr.cc>
2026-05-15 16:37:19 -07:00
白日梦主义
d34dc40eff
fix(outbounds): reject invalid port values (#1569) 2026-05-15 16:24:47 -07:00
Toby
64c3963856 fix(realm): client should accept punch packets from any source address 2026-05-10 10:13:49 -07:00
Toby
2639b064b8 fix: add "sniGuard: disable" to cert command output 2026-05-10 01:06:05 -07:00
Toby
97a341690a chore: log server address on connect, log realm peer address candidates 2026-05-09 13:24:13 -07:00
Toby
c1868d5c14 feat(realm): STUN on connect 2026-05-08 19:13:20 -07:00
Toby
891b7ad7cf fix(hyperbole): android build 2026-05-08 16:26:15 -07:00
Toby
93f68c526b
feat: Hysteria Realms (#1560)
* feat(wip): hysteria realms

* feat: port prediction for punching symmetric NAT

* feat: add "cert" subcommand for easy self signed cert generation

* refactor: update address scheme from "hysteria2+realm" to just "realm"

* fix: give up on realm register fatal errors

* chore: update formatting (gofumpt)

* perf: realm proxy UDP methods on PunchPacketConn so quic-go and obfs keep DF/PMTU and buffer sizing

* feat: add support for local UDP source port config in realm addresses

* doc: README for realm pkg
2026-05-08 14:16:21 -07:00
Toby
ed4127abca ci: bump action versions 2026-05-05 17:08:54 -07:00
Toby
99ad91c58a fix: avoid mutating PSK backing storage in salamander obfs 2026-04-26 13:57:19 -07:00
Toby
3bbc0e198a ci: update actions version & bump go to 1.26 2026-04-25 17:31:19 -07:00
Toby
697203f49d feat: omit datagram TP 2026-04-25 17:07:05 -07:00
Lenar Khannanov
fca7ece7b2
fix(app): invalid priority in output hook when setting redirect with nft (#1551)
* fix(app): invalid priority in output hook when setting redirect with nft

Server startup fails with nftables before v1.0.9, as it doesn't support
dstnat mnemonic in the output hook. Work around this by using the raw
number (-100) as recommended by Florian Westphal [1].

1. https://bugzilla.netfilter.org/show_bug.cgi?id=1694#c1

* chore(app): use "-100" instead of "dstnat" for both chains

---------

Co-authored-by: Toby <tobyxdd@gmail.com>
2026-04-22 13:46:59 -07:00
Toby
6476d21c59
feat: client & server use quic.Transport (#1550) 2026-04-21 14:02:37 -07:00
Toby
5647de5b87 ci: add code format check 2026-04-18 11:48:29 -07:00
白日梦主义
1b6636afe6
fix: repair the oom problem when enable sniff (#1547) 2026-04-18 11:33:00 -07:00
Theodore Chang
996612d6b7
Add nftables to Dockerfile for firewall rules (#1543) 2026-04-02 12:44:13 -07:00
Toby
25a2530ac7 fix: add -w flag to iptables commands and env var for firewall backend 2026-03-30 12:21:04 -07:00
Toby
724e469f70
Merge pull request #1540 from TLCFEM/bugfix-add-iptables
Add iptables to Dockerfile dependencies
2026-03-29 22:30:35 -07:00
Toby
d08b493ff9 fix: quic-go congestion datagram size panic issue 2026-03-29 22:16:13 -07:00
Theodore Chang
4bb6d0111b
Add iptables to Dockerfile dependencies 2026-03-30 04:15:17 +02:00
Toby
d25251e374
Merge pull request #1538 from apernet/ci/test
ci: test workflow
2026-03-29 15:05:40 -07:00
Toby
9e363c93c4 fix: update requirements.txt 2 2026-03-29 15:03:43 -07:00
Toby
7b866a81e4 fix: update requirements.txt 2026-03-29 14:59:11 -07:00
Toby
2c46b2cdba fix: go test command 2026-03-29 14:54:12 -07:00
Toby
14500fdb40 ci: test workflow 2026-03-29 14:52:14 -07:00
Toby
d425068a41
Merge pull request #1537 from apernet/feat/udphop-rand
feat: port hopping random interval
2026-03-29 14:00:46 -07:00
Toby
6ef838d2c8 feat: port hopping random interval 2026-03-29 14:00:12 -07:00
Toby
82d9935c85
Merge pull request #1536 from apernet/feat/udphop-server
feat: server side UDP port range listening (nftables/iptables)
2026-03-29 13:24:08 -07:00
Toby
5fd6d4d887 feat: server side UDP port range listening (nftables/iptables) 2026-03-29 11:47:09 -07:00
Toby
97f91ab774
Merge pull request #1535 from apernet/ci/bump-actions-ver
ci: bump download-artifact/upload-artifact versions
2026-03-29 10:30:33 -07:00
Toby
9778a05264 ci: bump download-artifact/upload-artifact versions 2026-03-29 10:30:01 -07:00
Toby
8059de329c
Merge pull request #1534 from apernet/feat/bbr-profiles
feat: add configurable congestion modes and BBR profiles
2026-03-29 10:08:02 -07:00
Toby
b3f2193f10 feat: add configurable congestion modes and BBR profiles 2026-03-28 13:11:17 -07:00
Toby
a00368f9e3
Merge pull request #1533 from apernet/dev/bbr-scale
fix: BBR scale window for datagram size
2026-03-27 18:31:15 -07:00