Skip to content

Commit 4c9d270

Browse files
committed
Squashed commit of the following:
commit 2b4726b Author: wwqgtxx <[email protected]> Date: Sat May 10 12:32:47 2025 +0800 fix: build on go1.24.3 golang/go#73617 commit 26e6d83 Author: xishang0128 <[email protected]> Date: Wed May 7 17:07:39 2025 +0800 chore: make select display the specified testUrl for MetaCubeX#2013 commit 50d7834 Author: wwqgtxx <[email protected]> Date: Mon May 5 01:32:25 2025 +0800 chore: change the separator of the `SAFE_PATHS` environment variable to the default separator of the operating system platform (i.e., `;` in Windows and `:` in other systems) commit 86c127d Author: wwqgtxx <[email protected]> Date: Sun May 4 10:39:15 2025 +0800 fix: missing read waiter for cancelers commit febb602 Author: wwqgtxx <[email protected]> Date: Sun May 4 11:09:40 2025 +0800 fix: hysteria2 inbound not set UDPTimeout commit 9e57b29 Author: wwqgtxx <[email protected]> Date: Sat May 3 15:06:13 2025 +0800 chore: update dependencies commit 791ea5e Author: wwqgtxx <[email protected]> Date: Thu May 1 12:33:21 2025 +0800 chore: allow setting addition safePaths by environment variable `SAFE_PATHS` package managers can allow for pre-defined safe paths without disabling the entire security check feature for MetaCubeX#2004 commit 7e7016b Author: wwqgtxx <[email protected]> Date: Thu May 1 01:27:08 2025 +0800 chore: removed `routing-mark` and `interface-name` of the group, please set it directly on the proxy instead commit b4fe669 Author: wwqgtxx <[email protected]> Date: Wed Apr 30 23:21:13 2025 +0800 chore: better path checks commit cad26ac Author: wwqgtxx <[email protected]> Date: Wed Apr 30 17:26:45 2025 +0800 chore: fetcher will change duration to achieve fast retry when the update failed with a 2x factor step from 1s to `interval` commit f328203 Author: wwqgtxx <[email protected]> Date: Wed Apr 30 16:03:02 2025 +0800 feat: not inline proxy-provider can also set `payload` as fallback proxies when file/http parsing fails commit 5c40a63 Author: wwqgtxx <[email protected]> Date: Wed Apr 30 14:09:15 2025 +0800 feat: not inline rule-provider can also set `payload` as fallback rules when file/http parsing fails commit 61d6a9a Author: wwqgtxx <[email protected]> Date: Wed Apr 30 13:21:42 2025 +0800 fix: fetcher does not start the pull loop when local file parsing errors occur and the first remote update fails commit a013ac3 Author: wwqgtxx <[email protected]> Date: Tue Apr 29 21:52:44 2025 +0800 chore: give better error messages for some stupid config files commit ee5d77c Author: wwqgtxx <[email protected]> Date: Tue Apr 29 21:15:48 2025 +0800 chore: cleanup tls clientFingerprint code commit 936df90 Author: wwqgtxx <[email protected]> Date: Tue Apr 29 09:01:54 2025 +0800 chore: update dependencies commit f774276 Author: Larvan2 <[email protected]> Date: Mon Apr 28 03:07:21 2025 +0000 fix: ensure wait group completes commit aa51b9f Author: wwqgtxx <[email protected]> Date: Mon Apr 28 10:28:45 2025 +0800 chore: replace using internal batch package to x/sync/errgroup In the original batch implementation, the Go() method will always start a new goroutine and then wait for the concurrency limit, which is unnecessary for the current code. x/sync/errgroup will block Go() until the concurrency limit is met, which can effectively reduce memory usage. In addition, the original batch always saves the return value of Go(), but it is not used in the current code, which will also waste a lot of memory space in high concurrency scenarios. commit d55b047 Author: wwqgtxx <[email protected]> Date: Sun Apr 27 09:39:46 2025 +0800 chore: ignore interfaces not with FlagUp in local interface finding commit efc7abc Author: xishang0128 <[email protected]> Date: Fri Apr 25 12:10:18 2025 +0800 actions: fix pacman build commit c2301f6 Author: wwqgtxx <[email protected]> Date: Fri Apr 25 10:34:34 2025 +0800 chore: rebuild fingerprint and keypair handle commit 468cfc3 Author: WeidiDeng <[email protected]> Date: Thu Apr 24 19:50:16 2025 +0800 fix: set sni to servername if not specified for trojan outbound (MetaCubeX#1991) commit 5dce957 Author: xishang0128 <[email protected]> Date: Thu Apr 24 17:25:14 2025 +0800 actions: improve build process commit 4ecb49b Author: wwqgtxx <[email protected]> Date: Wed Apr 23 12:25:42 2025 +0800 chore: dynamic fetch remoteAddr in hysteria2 service commit 7de4af2 Author: wwqgtxx <[email protected]> Date: Wed Apr 23 12:10:37 2025 +0800 fix: shadowtls test commit 48d8efb Author: wwqgtxx <[email protected]> Date: Wed Apr 23 12:00:10 2025 +0800 fix: do NOT reset the quic-go internal state when only port is different commit e6e7aa5 Author: wwqgtxx <[email protected]> Date: Tue Apr 22 23:44:55 2025 +0800 fix: alpn apply on shadowtls commit 99aa1b0 Author: wwqgtxx <[email protected]> Date: Tue Apr 22 20:49:54 2025 +0800 feat: inbound support shadow-tls commit 52ad793 Author: wwqgtxx <[email protected]> Date: Tue Apr 22 20:09:24 2025 +0800 fix: shadowtls v1 not work commit 2fb9331 Author: wwqgtxx <[email protected]> Date: Tue Apr 22 10:37:05 2025 +0800 fix: some resources are not released in listener commit 793ce45 Author: wwqgtxx <[email protected]> Date: Mon Apr 21 22:58:08 2025 +0800 chore: update quic-go to 0.51.0 commit 39d6a0d Author: wwqgtxx <[email protected]> Date: Mon Apr 21 12:07:33 2025 +0800 chore: update utls to 1.7.0 commit d5243ad Author: wwqgtxx <[email protected]> Date: Sat Apr 19 02:04:09 2025 +0800 chore: better global-client-fingerprint handle commit 6236cb1 Author: wwqgtxx <[email protected]> Date: Sat Apr 19 01:32:55 2025 +0800 chore: cleanup trojan code commit 619c9dc Author: wwqgtxx <[email protected]> Date: Fri Apr 18 20:16:51 2025 +0800 chore: apply the default interface/mark of the dialer in the final stage commit 9c5067e Author: wwqgtxx <[email protected]> Date: Fri Apr 18 19:34:21 2025 +0800 action: disable MinGW's path conversion in test commit feee9b3 Author: wwqgtxx <[email protected]> Date: Fri Apr 18 16:59:53 2025 +0800 chore: remove unneeded tls timeout in anytls commit 63e66f4 Author: wwqgtxx <[email protected]> Date: Fri Apr 18 16:59:28 2025 +0800 chore: cleanup trojan code commit bad61f9 Author: wwqgtxx <[email protected]> Date: Fri Apr 18 11:40:37 2025 +0800 fix: avoid panic in inbound test commit 69ce4d0 Author: wwqgtxx <[email protected]> Date: Thu Apr 17 23:40:46 2025 +0800 chore: speed up inbound test commit b59f11f Author: wwqgtxx <[email protected]> Date: Thu Apr 17 21:07:35 2025 +0800 chore: add singMux inbound test for shadowsocks/trojan/vless/vmess commit 30d90d4 Author: wwqgtxx <[email protected]> Date: Thu Apr 17 21:06:55 2025 +0800 chore: update option checks to use IsZeroOptions commit 76052b5 Author: wwqgtxx <[email protected]> Date: Thu Apr 17 12:54:36 2025 +0800 fix: grpc in trojan not apply client-fingerprint commit 7d7f5c8 Author: wwqgtxx <[email protected]> Date: Thu Apr 17 10:02:48 2025 +0800 chore: add inbound test for tuic commit e79465d Author: wwqgtxx <[email protected]> Date: Thu Apr 17 09:26:12 2025 +0800 chore: add inbound test for hysteria2 commit 345d3d7 Author: wwqgtxx <[email protected]> Date: Thu Apr 17 09:01:26 2025 +0800 chore: add inbound test for anytls commit 3d806b5 Author: wwqgtxx <[email protected]> Date: Thu Apr 17 01:36:14 2025 +0800 chore: add inbound test for shadowsocks/trojan commit b5fcd1d Author: wwqgtxx <[email protected]> Date: Thu Apr 17 00:11:24 2025 +0800 fix: chacha8-ietf-poly1305 not work commit b21b8ee Author: wwqgtxx <[email protected]> Date: Wed Apr 16 22:22:56 2025 +0800 fix: panic in ssr packet commit d0d0c39 Author: wwqgtxx <[email protected]> Date: Wed Apr 16 20:44:48 2025 +0800 chore: add inbound test for vmess/vless commit a75e570 Author: wwqgtxx <[email protected]> Date: Wed Apr 16 20:38:10 2025 +0800 fix: vision conn read short buffer error commit 9e0889c Author: wwqgtxx <[email protected]> Date: Wed Apr 16 13:16:11 2025 +0800 fix: observable test commit 55cbbf7 Author: wwqgtxx <[email protected]> Date: Wed Apr 16 13:13:01 2025 +0800 fix: singledo test commit 664b134 Author: wwqgtxx <[email protected]> Date: Wed Apr 16 13:02:50 2025 +0800 fix: websocket data losing commit ba3c44a Author: wwqgtxx <[email protected]> Date: Wed Apr 16 09:39:52 2025 +0800 chore: code cleanup commit dcb20e2 Author: wwqgtxx <[email protected]> Date: Wed Apr 16 08:47:44 2025 +0800 fix: websocket server upgrade in golang1.20 commit 3d2cb99 Author: wwqgtxx <[email protected]> Date: Wed Apr 16 01:00:06 2025 +0800 fix: grpc outbound not apply ca fingerprint commit 984535f Author: wwqgtxx <[email protected]> Date: Tue Apr 15 21:59:35 2025 +0800 action: run tests on more platforms commit 8fa4e81 Author: wwqgtxx <[email protected]> Date: Sun Apr 13 03:03:28 2025 +0800 chore: remove internal crypto/tls fork in reality server commit 7551c8a Author: wwqgtxx <[email protected]> Date: Sat Apr 12 23:42:57 2025 +0800 chore: remove unneed code commit 237e2ed Author: wwqgtxx <[email protected]> Date: Sat Apr 12 22:46:26 2025 +0800 chore: tun will add firewall rule for Profile ALL on windows system stack commit fe01033 Author: wwqgtxx <[email protected]> Date: Sat Apr 12 22:27:07 2025 +0800 chore: quic sniffer should use the exact length of crypto stream when assembling commit 84cd0ef Author: wwqgtxx <[email protected]> Date: Sat Apr 12 20:27:30 2025 +0800 chore: remove internal crypto/tls fork in shadowtls commit cedb36d Author: wwqgtxx <[email protected]> Date: Sat Apr 12 11:19:03 2025 +0800 chore: using SetupContextForConn to reduce the DialContext cannot be cancelled commit 7a260f7 Author: HiMetre <[email protected]> Date: Fri Apr 11 09:20:58 2025 +0800 fix: udp dial support ip4p (MetaCubeX#1377) commit 8085c68 Author: wwqgtxx <[email protected]> Date: Fri Apr 11 00:33:07 2025 +0800 chore: decrease direct using *net.TCPConn commit dbb5b7d Author: wwqgtxx <[email protected]> Date: Thu Apr 10 23:32:26 2025 +0800 fix: SetupContextForConn should return context error to user commit bfd06eb Author: wwqgtxx <[email protected]> Date: Thu Apr 10 01:16:54 2025 +0800 chore: rebuild SetupContextForConn with context.AfterFunc commit e8af058 Author: wwqgtxx <[email protected]> Date: Thu Apr 10 00:13:14 2025 +0800 fix: websocketWithEarlyDataConn can't close underlay conn when is dialing or not dialed commit 487d7fa Author: wwqgtxx <[email protected]> Date: Wed Apr 9 17:53:36 2025 +0800 fix: panic under some stupid input config commit 4b15568 Author: wwqgtxx <[email protected]> Date: Wed Apr 9 12:33:01 2025 +0800 chore: cleanup metadata code commit cac2bf7 Author: wwqgtxx <[email protected]> Date: Wed Apr 9 11:39:00 2025 +0800 chore: cleanup netip code commit b2d2890 Author: wwqgtxx <[email protected]> Date: Wed Apr 9 10:32:13 2025 +0800 chore: cleanup resolveUDPAddr code commit 8752f80 Author: anytls <[email protected]> Date: Wed Apr 9 10:55:53 2025 +0900 fix: anytls stream read error (MetaCubeX#1970) Co-authored-by: anytls <anytls> commit a6c0c02 Author: wwqgtxx <[email protected]> Date: Tue Apr 8 23:42:21 2025 +0800 chore: ignore interfaces not in IfOperStatusUp when fetch system dns server on windows commit 2acb0b7 Author: wwqgtxx <[email protected]> Date: Tue Apr 8 19:20:29 2025 +0800 fix: tun IncludeInterface/ExcludeInterface priority commit 2a40eba Author: wwqgtxx <[email protected]> Date: Tue Apr 8 19:07:39 2025 +0800 feat: tun add `exclude-src-port`,`exclude-src-port-range`,`exclude-dst-port` and `exclude-dst-port-range` on linux commit a22efd5 Author: okhowang <[email protected]> Date: Tue Apr 8 12:10:30 2025 +0800 feat: add exclude port and exclude port range options (MetaCubeX#1951) Fixes MetaCubeX#1769 commit 9e8f4ad Author: wwqgtxx <[email protected]> Date: Sun Apr 6 10:43:21 2025 +0800 chore: better addr parsing commit 09c7ee0 Author: wwqgtxx <[email protected]> Date: Sun Apr 6 10:12:57 2025 +0800 fix: grpc server panic commit 2a08c44 Author: wwqgtxx <[email protected]> Date: Sat Apr 5 10:48:07 2025 +0800 action: fix run build on pull_request commit 190047c Author: wwqgtxx <[email protected]> Date: Fri Apr 4 21:05:54 2025 +0800 fix: grpc transport not apply dial timeout commit 24a9ff6 Author: wwqgtxx <[email protected]> Date: Fri Apr 4 13:33:00 2025 +0800 fix: disallow dialFunc be called after grpc transport has be closed commit efa2243 Author: wwqgtxx <[email protected]> Date: Fri Apr 4 11:54:19 2025 +0800 fix: shut it down more aggressively in grpc transport closing commit b0bd4f4 Author: wwqgtxx <[email protected]> Date: Fri Apr 4 11:12:08 2025 +0800 fix: resources not released when hysteria2 verification failed commit eaaccff Author: wwqgtxx <[email protected]> Date: Fri Apr 4 10:55:16 2025 +0800 fix: race in Single.Do commit e81f3a9 Author: wwqgtxx <[email protected]> Date: Fri Apr 4 09:08:52 2025 +0800 fix: correctly implement references to proxies commit 323973f Author: wwqgtxx <[email protected]> Date: Fri Apr 4 00:22:52 2025 +0800 fix: converter judgment conditions commit ed7533c Author: 5aaee9 <[email protected]> Date: Thu Apr 3 08:52:19 2025 -0700 fix: tproxy high cpu usage (MetaCubeX#1957) commit 7de24e2 Author: wwqgtxx <[email protected]> Date: Thu Apr 3 23:41:24 2025 +0800 fix: StreamGunWithConn not synchronously close the incoming net.Conn commit 622d99d Author: wwqgtxx <[email protected]> Date: Thu Apr 3 22:42:32 2025 +0800 chore: rebuild outdated proxy auto close mechanism commit 7f1225b Author: wwqgtxx <[email protected]> Date: Thu Apr 3 22:41:05 2025 +0800 fix: grpc transport can't be closed commit 23ffe45 Author: wwqgtxx <[email protected]> Date: Thu Apr 3 19:47:49 2025 +0800 chore: using http/httptrace to get local/remoteAddr for grpc client commit 7b37fcf Author: wwqgtxx <[email protected]> Date: Wed Apr 2 23:47:34 2025 +0800 fix: auto_redirect should only hijack DNS requests from local addresses commit daa592c Author: wwqgtxx <[email protected]> Date: Wed Apr 2 21:13:46 2025 +0800 fix: converter panic commit 577f64a Author: wwqgtxx <[email protected]> Date: Wed Apr 2 14:39:07 2025 +0800 fix: X25519MLKEM768 does not work properly with reality commit 025ff19 Author: wwqgtxx <[email protected]> Date: Fri Mar 28 10:54:11 2025 +0800 fix: wrong conditional judgment in removeExtraHTTPHostPort MetaCubeX#1939 commit f615346 Author: anytls <[email protected]> Date: Thu Mar 27 20:25:31 2025 +0800 chore: anytls protocol version 2 (MetaCubeX#1936) commit 7b38261 Author: wwqgtxx <[email protected]> Date: Tue Mar 25 01:19:39 2025 +0800 chore: update gvisor commit 0f32c05 Author: enfein <[email protected]> Date: Thu Mar 20 05:58:04 2025 +0000 feat: support UDP over TCP in mieru (MetaCubeX#1926) commit 4f8b70c Author: 5aaee9 <[email protected]> Date: Wed Mar 19 12:20:48 2025 +0800 fix: buffer in tproxy not recycle (MetaCubeX#1923) commit dcef787 Author: wwqgtxx <[email protected]> Date: Tue Mar 18 09:09:54 2025 +0800 chore: update utls commit 7c444a9 Author: wwqgtxx <[email protected]> Date: Mon Mar 17 23:51:21 2025 +0800 fix: correctly handle ipv6 zone commit e3d4ec2 Author: wwqgtxx <[email protected]> Date: Mon Mar 17 14:00:51 2025 +0800 fix: race at interfaceName setting commit 14217e7 Author: xishang0128 <[email protected]> Date: Mon Mar 17 13:21:23 2025 +0800 chore: update service capabilities to include CAP_SYS_TIME and CAP_DAC_OVERRIDE commit 68abb13 Author: wwqgtxx <[email protected]> Date: Mon Mar 17 10:42:13 2025 +0800 chore: support longest-prefix matches in local interface finding commit dee5898 Author: Cesaryuan <[email protected]> Date: Sat Mar 15 13:27:29 2025 +0800 fix: memory leak due to unclosed session (MetaCubeX#1908) commit 1e22f4d Author: wwqgtxx <[email protected]> Date: Fri Mar 14 12:07:23 2025 +0800 chore: reduce data copying in quic sniffer and better handle data fragmentation and overlap commit a7a796b Author: wwqgtxx <[email protected]> Date: Thu Mar 13 16:27:29 2025 +0800 chore: cleanup quic sniff's code commit ff89bf0 Author: Cesaryuan <[email protected]> Date: Thu Mar 13 13:28:40 2025 +0800 feat: add gost-plugin in which only ws and mws are currently supported. (MetaCubeX#1896) commit 801f3c3 Author: 5aaee9 <[email protected]> Date: Thu Mar 13 13:19:36 2025 +0800 feat: support sniff quic fragment data (MetaCubeX#1899) commit 7ff046a Author: wwqgtxx <[email protected]> Date: Thu Mar 13 08:52:27 2025 +0800 chore: modify UDPSniff's function signature to prepare for its ability to handle multiple packets. commit 0ed159e Author: wwqgtxx <[email protected]> Date: Wed Mar 12 13:33:52 2025 +0800 chore: code cleanup commit 070eb31 Author: wwqgtxx <[email protected]> Date: Wed Mar 12 11:42:57 2025 +0800 chore: speedup system stack in tun commit f318b80 Author: wwqgtxx <[email protected]> Date: Tue Mar 11 22:50:55 2025 +0800 chore: better cache implement for group's getProxies commit c0de3c0 Author: wwqgtxx <[email protected]> Date: Mon Mar 10 11:10:39 2025 +0800 fix: some default value in dialer not restore in tun when config reload commit 4bd3ae5 Author: wwqgtxx <[email protected]> Date: Mon Mar 10 10:45:07 2025 +0800 chore: dialer will consider the routing of the local interface when auto-detect-interface in tun is enabled for MetaCubeX#1881 MetaCubeX#1819 commit 00e6466 Author: Skyxim <[email protected]> Date: Mon Mar 10 09:13:38 2025 +0800 chore: update checksum generation step commit c94b442 Author: Skyxim <[email protected]> Date: Mon Mar 10 09:02:08 2025 +0800 chore: add checksum generation for production artifacts
1 parent 02d5591 commit 4c9d270

File tree

181 files changed

+4637
-2317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+4637
-2317
lines changed

.github/release/.fpm_systemd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-s dir
2+
--name mihomo
3+
--category net
4+
--license GPL-3.0-or-later
5+
--description "The universal proxy platform."
6+
--url "https://wiki.metacubex.one/"
7+
--maintainer "MetaCubeX <[email protected]>"
8+
--deb-field "Bug: https://github.com/MetaCubeX/mihomo/issues"
9+
--no-deb-generate-changes
10+
--config-files /etc/mihomo/config.yaml
11+
12+
.github/release/config.yaml=/etc/mihomo/config.yaml
13+
14+
.github/release/mihomo.service=/usr/lib/systemd/system/mihomo.service
15+
.github/release/[email protected]=/usr/lib/systemd/system/[email protected]
16+
17+
18+
LICENSE=/usr/share/licenses/mihomo/LICENSE

.github/release/config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
mixed-port: 7890
2+
3+
dns:
4+
enable: true
5+
ipv6: true
6+
enhanced-mode: fake-ip
7+
fake-ip-filter:
8+
- "*"
9+
- "+.lan"
10+
- "+.local"
11+
nameserver:
12+
- system
13+
14+
rules:
15+
- MATCH,DIRECT

.github/mihomo.service renamed to .github/release/mihomo.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[Unit]
2-
Description=clash Daemon, Another Clash Kernel.
2+
Description=mihomo Daemon, Another Clash Kernel.
33
Documentation=https://wiki.metacubex.one
44
After=network.target nss-lookup.target network-online.target
55

66
[Service]
77
Type=simple
88
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
99
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
10-
ExecStart=/usr/bin/clash -d /etc/clash
10+
ExecStart=/usr/bin/mihomo -d /etc/mihomo
1111
ExecReload=/bin/kill -HUP $MAINPID
1212
Restart=on-failure
1313
RestartSec=10
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[Unit]
2-
Description=clash Daemon, Another Clash Kernel.
2+
Description=mihomo Daemon, Another Clash Kernel.
33
Documentation=https://wiki.metacubex.one
44
After=network.target nss-lookup.target network-online.target
55

66
[Service]
77
Type=simple
88
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
99
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
10-
ExecStart=/usr/bin/clash -d /etc/clash
10+
ExecStart=/usr/bin/mihomo -d /etc/mihomo
1111
ExecReload=/bin/kill -HUP $MAINPID
1212
Restart=on-failure
1313
RestartSec=10

.github/workflows/test.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Test
2+
on:
3+
push:
4+
paths-ignore:
5+
- "docs/**"
6+
- "README.md"
7+
- ".github/ISSUE_TEMPLATE/**"
8+
branches:
9+
- Alpha
10+
tags:
11+
- "v*"
12+
pull_request:
13+
branches:
14+
- Alpha
15+
16+
jobs:
17+
test:
18+
strategy:
19+
matrix:
20+
os:
21+
- 'ubuntu-latest' # amd64 linux
22+
- 'windows-latest' # amd64 windows
23+
- 'macos-latest' # arm64 macos
24+
- 'ubuntu-24.04-arm' # arm64 linux
25+
- 'macos-13' # amd64 macos
26+
go-version:
27+
- '1.24'
28+
- '1.23'
29+
- '1.22'
30+
- '1.21'
31+
- '1.20'
32+
fail-fast: false
33+
runs-on: ${{ matrix.os }}
34+
defaults:
35+
run:
36+
shell: bash
37+
env:
38+
CGO_ENABLED: 0
39+
GOTOOLCHAIN: local
40+
# Fix mingw trying to be smart and converting paths https://github.com/moby/moby/issues/24029#issuecomment-250412919
41+
MSYS_NO_PATHCONV: true
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Setup Go
46+
uses: actions/setup-go@v5
47+
with:
48+
go-version: ${{ matrix.go-version }}
49+
50+
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
51+
# this patch file only works on golang1.24.x
52+
# that means after golang1.25 release it must be changed
53+
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.24/
54+
# revert:
55+
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
56+
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
57+
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
58+
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"
59+
- name: Revert Golang1.24 commit for Windows7/8
60+
if: ${{ runner.os == 'Windows' && matrix.go-version == '1.24' }}
61+
run: |
62+
cd $(go env GOROOT)
63+
curl https://github.com/MetaCubeX/go/commit/2a406dc9f1ea7323d6ca9fccb2fe9ddebb6b1cc8.diff | patch --verbose -p 1
64+
curl https://github.com/MetaCubeX/go/commit/7b1fd7d39c6be0185fbe1d929578ab372ac5c632.diff | patch --verbose -p 1
65+
curl https://github.com/MetaCubeX/go/commit/979d6d8bab3823ff572ace26767fd2ce3cf351ae.diff | patch --verbose -p 1
66+
curl https://github.com/MetaCubeX/go/commit/ac3e93c061779dfefc0dd13a5b6e6f764a25621e.diff | patch --verbose -p 1
67+
68+
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
69+
# this patch file only works on golang1.23.x
70+
# that means after golang1.24 release it must be changed
71+
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.23/
72+
# revert:
73+
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
74+
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
75+
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
76+
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"
77+
- name: Revert Golang1.23 commit for Windows7/8
78+
if: ${{ runner.os == 'Windows' && matrix.go-version == '1.23' }}
79+
run: |
80+
cd $(go env GOROOT)
81+
curl https://github.com/MetaCubeX/go/commit/9ac42137ef6730e8b7daca016ece831297a1d75b.diff | patch --verbose -p 1
82+
curl https://github.com/MetaCubeX/go/commit/21290de8a4c91408de7c2b5b68757b1e90af49dd.diff | patch --verbose -p 1
83+
curl https://github.com/MetaCubeX/go/commit/6a31d3fa8e47ddabc10bd97bff10d9a85f4cfb76.diff | patch --verbose -p 1
84+
curl https://github.com/MetaCubeX/go/commit/69e2eed6dd0f6d815ebf15797761c13f31213dd6.diff | patch --verbose -p 1
85+
86+
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
87+
# this patch file only works on golang1.22.x
88+
# that means after golang1.23 release it must be changed
89+
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.22/
90+
# revert:
91+
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
92+
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
93+
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
94+
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"
95+
- name: Revert Golang1.22 commit for Windows7/8
96+
if: ${{ runner.os == 'Windows' && matrix.go-version == '1.22' }}
97+
run: |
98+
cd $(go env GOROOT)
99+
curl https://github.com/MetaCubeX/go/commit/9779155f18b6556a034f7bb79fb7fb2aad1e26a9.diff | patch --verbose -p 1
100+
curl https://github.com/MetaCubeX/go/commit/ef0606261340e608017860b423ffae5c1ce78239.diff | patch --verbose -p 1
101+
curl https://github.com/MetaCubeX/go/commit/7f83badcb925a7e743188041cb6e561fc9b5b642.diff | patch --verbose -p 1
102+
curl https://github.com/MetaCubeX/go/commit/83ff9782e024cb328b690cbf0da4e7848a327f4f.diff | patch --verbose -p 1
103+
104+
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
105+
- name: Revert Golang1.21 commit for Windows7/8
106+
if: ${{ runner.os == 'Windows' && matrix.go-version == '1.21' }}
107+
run: |
108+
cd $(go env GOROOT)
109+
curl https://github.com/golang/go/commit/9e43850a3298a9b8b1162ba0033d4c53f8637571.diff | patch --verbose -R -p 1
110+
111+
- name: Test
112+
run: go test ./... -v -count=1
113+
114+
- name: Test with tag with_gvisor
115+
run: go test ./... -v -count=1 -tags "with_gvisor"

adapter/adapter.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ import (
1313
"strings"
1414
"time"
1515

16-
"github.com/metacubex/clash/common/atomic"
17-
"github.com/metacubex/clash/common/queue"
18-
"github.com/metacubex/clash/common/utils"
19-
"github.com/metacubex/clash/component/ca"
20-
"github.com/metacubex/clash/component/dialer"
21-
C "github.com/metacubex/clash/constant"
22-
"github.com/metacubex/clash/log"
16+
"github.com/metacubex/mihomo/common/atomic"
17+
"github.com/metacubex/mihomo/common/queue"
18+
"github.com/metacubex/mihomo/common/utils"
19+
"github.com/metacubex/mihomo/component/ca"
20+
C "github.com/metacubex/mihomo/constant"
21+
"github.com/metacubex/mihomo/log"
2322
"github.com/puzpuzpuz/xsync/v3"
2423
)
2524

@@ -63,8 +62,8 @@ func (p *Proxy) Dial(metadata *C.Metadata) (C.Conn, error) {
6362
}
6463

6564
// DialContext implements C.ProxyAdapter
66-
func (p *Proxy) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (C.Conn, error) {
67-
conn, err := p.ProxyAdapter.DialContext(ctx, metadata, opts...)
65+
func (p *Proxy) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error) {
66+
conn, err := p.ProxyAdapter.DialContext(ctx, metadata)
6867
return conn, err
6968
}
7069

@@ -76,8 +75,8 @@ func (p *Proxy) DialUDP(metadata *C.Metadata) (C.PacketConn, error) {
7675
}
7776

7877
// ListenPacketContext implements C.ProxyAdapter
79-
func (p *Proxy) ListenPacketContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (C.PacketConn, error) {
80-
pc, err := p.ProxyAdapter.ListenPacketContext(ctx, metadata, opts...)
78+
func (p *Proxy) ListenPacketContext(ctx context.Context, metadata *C.Metadata) (C.PacketConn, error) {
79+
pc, err := p.ProxyAdapter.ListenPacketContext(ctx, metadata)
8180
return pc, err
8281
}
8382

@@ -290,6 +289,7 @@ func (p *Proxy) URLTest(ctx context.Context, url string, expectedStatus utils.In
290289
t = uint16(time.Since(start) / time.Millisecond)
291290
return
292291
}
292+
293293
func NewProxy(adapter C.ProxyAdapter) *Proxy {
294294
return &Proxy{
295295
ProxyAdapter: adapter,

adapter/inbound/util.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import (
77
"strconv"
88
"strings"
99

10-
"github.com/metacubex/clash/common/nnip"
11-
C "github.com/metacubex/clash/constant"
12-
"github.com/metacubex/clash/transport/socks5"
10+
C "github.com/metacubex/mihomo/constant"
11+
"github.com/metacubex/mihomo/transport/socks5"
1312
)
1413

1514
func parseSocksAddr(target socks5.Addr) *C.Metadata {
@@ -21,13 +20,13 @@ func parseSocksAddr(target socks5.Addr) *C.Metadata {
2120
metadata.Host = strings.TrimRight(string(target[2:2+target[1]]), ".")
2221
metadata.DstPort = uint16((int(target[2+target[1]]) << 8) | int(target[2+target[1]+1]))
2322
case socks5.AtypIPv4:
24-
metadata.DstIP = nnip.IpToAddr(net.IP(target[1 : 1+net.IPv4len]))
23+
metadata.DstIP, _ = netip.AddrFromSlice(target[1 : 1+net.IPv4len])
2524
metadata.DstPort = uint16((int(target[1+net.IPv4len]) << 8) | int(target[1+net.IPv4len+1]))
2625
case socks5.AtypIPv6:
27-
ip6, _ := netip.AddrFromSlice(target[1 : 1+net.IPv6len])
28-
metadata.DstIP = ip6.Unmap()
26+
metadata.DstIP, _ = netip.AddrFromSlice(target[1 : 1+net.IPv6len])
2927
metadata.DstPort = uint16((int(target[1+net.IPv6len]) << 8) | int(target[1+net.IPv6len+1]))
3028
}
29+
metadata.DstIP = metadata.DstIP.Unmap()
3130

3231
return metadata
3332
}

adapter/outbound/anytls.go

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ import (
44
"context"
55
"errors"
66
"net"
7-
"runtime"
87
"strconv"
98
"time"
109

11-
CN "github.com/metacubex/clash/common/net"
12-
"github.com/metacubex/clash/component/dialer"
13-
"github.com/metacubex/clash/component/proxydialer"
14-
"github.com/metacubex/clash/component/resolver"
15-
tlsC "github.com/metacubex/clash/component/tls"
16-
C "github.com/metacubex/clash/constant"
17-
"github.com/metacubex/clash/transport/anytls"
18-
"github.com/metacubex/clash/transport/vmess"
19-
20-
M "github.com/sagernet/sing/common/metadata"
21-
"github.com/sagernet/sing/common/uot"
10+
CN "github.com/metacubex/mihomo/common/net"
11+
"github.com/metacubex/mihomo/component/dialer"
12+
"github.com/metacubex/mihomo/component/proxydialer"
13+
"github.com/metacubex/mihomo/component/resolver"
14+
C "github.com/metacubex/mihomo/constant"
15+
"github.com/metacubex/mihomo/transport/anytls"
16+
"github.com/metacubex/mihomo/transport/vmess"
17+
18+
M "github.com/metacubex/sing/common/metadata"
19+
"github.com/metacubex/sing/common/uot"
2220
)
2321

2422
type AnyTLS struct {
@@ -45,20 +43,16 @@ type AnyTLSOption struct {
4543
MinIdleSession int `proxy:"min-idle-session,omitempty"`
4644
}
4745

48-
func (t *AnyTLS) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (_ C.Conn, err error) {
49-
options := t.Base.DialOptions(opts...)
50-
t.dialer.SetDialer(dialer.NewDialer(options...))
46+
func (t *AnyTLS) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) {
5147
c, err := t.client.CreateProxy(ctx, M.ParseSocksaddrHostPort(metadata.String(), metadata.DstPort))
5248
if err != nil {
5349
return nil, err
5450
}
55-
return NewConn(CN.NewRefConn(c, t), t), nil
51+
return NewConn(c, t), nil
5652
}
5753

58-
func (t *AnyTLS) ListenPacketContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (_ C.PacketConn, err error) {
54+
func (t *AnyTLS) ListenPacketContext(ctx context.Context, metadata *C.Metadata) (_ C.PacketConn, err error) {
5955
// create tcp
60-
options := t.Base.DialOptions(opts...)
61-
t.dialer.SetDialer(dialer.NewDialer(options...))
6256
c, err := t.client.CreateProxy(ctx, uot.RequestDestination(2))
6357
if err != nil {
6458
return nil, err
@@ -73,7 +67,7 @@ func (t *AnyTLS) ListenPacketContext(ctx context.Context, metadata *C.Metadata,
7367
metadata.DstIP = ip
7468
}
7569
destination := M.SocksaddrFromNet(metadata.UDPAddr())
76-
return newPacketConn(CN.NewRefPacketConn(CN.NewThreadSafePacketConn(uot.NewLazyConn(c, uot.Request{Destination: destination})), t), t), nil
70+
return newPacketConn(CN.NewThreadSafePacketConn(uot.NewLazyConn(c, uot.Request{Destination: destination})), t), nil
7771
}
7872

7973
// SupportUOT implements C.ProxyAdapter
@@ -88,10 +82,30 @@ func (t *AnyTLS) ProxyInfo() C.ProxyInfo {
8882
return info
8983
}
9084

85+
// Close implements C.ProxyAdapter
86+
func (t *AnyTLS) Close() error {
87+
return t.client.Close()
88+
}
89+
9190
func NewAnyTLS(option AnyTLSOption) (*AnyTLS, error) {
9291
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
92+
outbound := &AnyTLS{
93+
Base: &Base{
94+
name: option.Name,
95+
addr: addr,
96+
tp: C.AnyTLS,
97+
udp: option.UDP,
98+
tfo: option.TFO,
99+
mpTcp: option.MPTCP,
100+
iface: option.Interface,
101+
rmark: option.RoutingMark,
102+
prefer: C.NewDNSPrefer(option.IPVersion),
103+
},
104+
option: &option,
105+
}
93106

94-
singDialer := proxydialer.NewByNameSingDialer(option.DialerProxy, dialer.NewDialer())
107+
singDialer := proxydialer.NewByNameSingDialer(option.DialerProxy, dialer.NewDialer(outbound.DialOptions()...))
108+
outbound.dialer = singDialer
95109

96110
tOption := anytls.ClientConfig{
97111
Password: option.Password,
@@ -111,30 +125,10 @@ func NewAnyTLS(option AnyTLSOption) (*AnyTLS, error) {
111125
if tlsConfig.Host == "" {
112126
tlsConfig.Host = option.Server
113127
}
114-
if tlsC.HaveGlobalFingerprint() && len(option.ClientFingerprint) == 0 {
115-
tlsConfig.ClientFingerprint = tlsC.GetGlobalFingerprint()
116-
}
117128
tOption.TLSConfig = tlsConfig
118129

119-
outbound := &AnyTLS{
120-
Base: &Base{
121-
name: option.Name,
122-
addr: addr,
123-
tp: C.AnyTLS,
124-
udp: option.UDP,
125-
tfo: option.TFO,
126-
mpTcp: option.MPTCP,
127-
iface: option.Interface,
128-
rmark: option.RoutingMark,
129-
prefer: C.NewDNSPrefer(option.IPVersion),
130-
},
131-
client: anytls.NewClient(context.TODO(), tOption),
132-
option: &option,
133-
dialer: singDialer,
134-
}
135-
runtime.SetFinalizer(outbound, func(o *AnyTLS) {
136-
_ = o.client.Close()
137-
})
130+
client := anytls.NewClient(context.TODO(), tOption)
131+
outbound.client = client
138132

139133
return outbound, nil
140134
}

0 commit comments

Comments
 (0)