707 Commits
Author SHA1 Message Date
kazeyukiro a534463c18 test(listener): allow HTTP/SOCKS; keep excluding tun/tproxy/mixed 2026-10-07 16:47:54 +00:00
kazeyukiro a46b3b010b feat(listener): HTTP/SOCKS inbounds with client share and Clash proxies
Re-apply on post-theme baseline (52e848a): schema, compile modules,
http:// and socks5:// share URIs, and client subscription YAML
(type: http / socks5). Fixes gofmt for CI.
2026-10-07 16:42:27 +00:00
kazeyukiro b63dad2992 fix(shadowquic): require jls-upstream.addr so Mihomo -t succeeds
Empty/missing jls-upstream caused whole config reload to fail and left
new listeners stuck as config_not_applied. Autofill defaults and ensure
addr/sni when compiling shadowquic listeners.
2026-10-06 01:46:45 +00:00
kazeyukiro 0a00487291 fix(sub): apply tfo/mptcp only to TCP outbound types 2026-10-06 01:15:32 +00:00
kazeyukiro 6126381e6c fix(config): persist clientTfo/clientMptcp in visual-config
yaml:"-" dropped the subscription dial flags on save so UI switches
reset after refresh. Store as client-tfo/client-mptcp and strip them
when merging the visual fragment into the serving Mihomo YAML.
2026-10-06 01:12:25 +00:00
kazeyukiro 29da3acda7 fix(sub): stamp client tfo/mptcp on subscription nodes 2026-10-06 00:38:37 +00:00
kazeyukiro 325f603420 fix(docs): restore openapi.yaml after accidental truncate 2026-10-05 15:27:19 +00:00
kazeyukiro b787cd9fda fix(config): separate server inbound dial flags from client proxy tfo/mptcp
- Remove mode from Config general settings UI
- Client proxies only emit wiki tfo/mptcp booleans; strip inbound-* and
  other server-only keys from subscription YAML
- OpenAPI SSL engine notes match current acmez stack
2026-10-05 15:26:56 +00:00
kazeyukiro 04d637f817 docs(api): document visual TFO/MPTCP and certmagic SSL engine
OpenAPI: GET/POST /config/visual with inboundTfo/inboundMptcp and
per-proxy tfo/mptcp; SSL notes use certmagic instead of autocert/acmez.
2026-10-05 15:10:39 +00:00
7099315eb1 feat(proxy): expose per-proxy tfo / mptcp (#97)
* feat(proxy): expose per-proxy tfo / mptcp (TCP Fast Open / Multipath TCP)

Add Mihomo's proxy-level `tfo` and `mptcp` options (wiki.metacubex.one/config/proxies)
to the panel so clients can opt into TCP Fast Open / Multipath TCP on a per-node basis.

Mapping accuracy:
- These are PROXY-level keys, distinct from the global `inbound-tfo` / `inbound-mptcp`
  general switches. They travel through ProxyEntry.Options (the same catch-all that already
  feeds both the serving config and the client subscription document), so they surface in
  BOTH the server mihomo config and the generated client subscription config — no field is
  lost or misrouted.

Frontend (web + mobile share the same Config page / responsive Modal):
- Proxy editor gains TFO (TCP Fast Open) and MPTCP (Multipath TCP) switches.
- An info note states they only take effect on TCP transports.
- Modal body becomes scrollable on phones (maxHeight 78vh) so the added rows stay reachable
  on small screens; width/top already adapt via useIsMobile.

i18n: zh-CN / en strings for proxyTfo, proxyMptcp, proxyTcpOnly.

Tests:
- config: tfo/mptcp serialize into proxy YAML and round-trip; absent stays absent, explicit
  false is preserved.
- converter: client subscription document preserves tfo/mptcp from visual proxies.

* fix(i18n): add missing commas after proxy TFO/MPTCP keys

---------

Co-authored-by: 3m-ui dev <dev@local>
Co-authored-by: kazeyukiro <kazeyukiro@users.noreply.github.com>
2026-10-05 22:18:50 +08:00
d26b7e1534 feat(config): add inbound-tfo / inbound-mptcp global kernel settings (#96)
* feat(config): add inbound-tfo / inbound-mptcp global kernel settings

Expose Mihomo's top-level `inbound-tfo` and `inbound-mptcp` general keys
(TCP Fast Open / Multipath TCP applied to every inbound listener socket) in
the panel. These are GLOBAL switches, not per-listener fields, so they are
carried on VisualConfig — the same struct that feeds the serving Mihomo
config fragment — and never copied into client subscription documents.

Backend:
- VisualConfig gains InboundTfo / InboundMPTCP (json inboundTfo/inboundMptcp,
  yaml inbound-tfo/inbound-mptcp), matching Mihomo's exact key names.
- MihomoConfig gains the same keys (omitempty) for schema completeness.
- GenerateFinalConfig already merges the visual-config fragment over the
  template (only listeners/rules/proxies/groups are stripped), so the keys
  surface in the serving config exactly as Mihomo expects.

Frontend:
- Config page gains a 'General' card (mode, log level, allow-lan, ipv6,
  inbound-tfo, inbound-mptcp) loaded from /config/visual and saved via
  POST /config/visual. The full VisualConfig is preserved on save so existing
  proxies/groups/rules/DNS are not clobbered.
- i18n zh-CN / en strings added.

Tests:
- config package tests assert inbound-tfo / inbound-mptcp appear as `true`
  in GenerateFinalConfig output when enabled and never become `true` when off.

* fix: gofmt visual.go; type saveVisualConfig payload as VisualConfig

---------

Co-authored-by: 3m-ui dev <dev@local>
Co-authored-by: kazeyukiro <kazeyukiro@users.noreply.github.com>
2026-10-05 22:16:49 +08:00
風雪and風雪 2ac3714619 fix(config): also let TCP+UDP coexist on the same port at generate time (#94)
PR #91 made the creation-time guards (ensureEndpointAvailable,
ensureBatchEndpointsAvailable) transport-aware so a TCP listener and a UDP
listener can share an address:port. But the third copy of the conflict check
inside Mihomo config generation — validateListenerEndpoints in
internal/mihomo/config/generator.go — was left untouched. So a TCP+UDP pair
that creation now permits was still rejected when the panel regenerated the
Mihomo config, surfacing as:

  warning: Mihomo config generate after listener change failed: ...
  listeners "节点2" and "节点5" have conflicting bind address/port ranges
  (0.0.0.0:16201 and 0.0.0.0:16201)

Make validateListenerEndpoints reuse protocol.ListenerTransports and only flag
a conflict when the two listeners share an L4 transport, matching the
creation-time guard. Same-protocol pairs on the same address:port still
conflict.

Tests:
- TestValidateListenerEndpointsAllowsTCPandUDPOnSamePort
- TestValidateListenerEndpointsRejectsTwoTCPOnSamePort
- TestValidateListenerEndpointsRejectsTwoUDPOnSamePort

Co-authored-by: 風雪 <kazeyukiro@users.noreply.github.com>
2026-10-05 19:09:18 +08:00
風雪and風雪 d73613387d fix(backup): snapshot the live DB with VACUUM INTO instead of a racy file copy (#92)
The in-app "Download backup" button exported the SQLite file with a plain
`os.Open` + `io.Copy` while the panel's GORM pool was still open and writing.
That copy races with concurrent writes (torn pages) and, even after the prior
WAL checkpoint, could leave committed frames in -wal that the copy never
replayed — an inconsistent or partially-lost backup.

Replace the checkpoint + file copy with SQLite's online backup primitive
VACUUM INTO, which reads through the WAL and in-flight transactions to produce
a self-contained, fully-replayed snapshot without stopping the panel.

Also stop bundling 3m-ui.db-wal / 3m-ui.db-shm into the zip. The VACUUM INTO
result is already complete (WAL merged in), so the sidecars were dead weight —
and they were never restored on import anyway, which silently dropped
un-checkpointed writes on restore.

Tests:
- TestWriteZipSnapshotIsConsistentAndSelfContained: a WAL-mode db with 200 rows
  held open by a live connection; WriteZip produces a zip whose 3m-ui.db opens
  standalone with all 200 rows and contains no -wal/-shm entries.
- go vet + go test -tags sqlite_modernc ./... green.

Co-authored-by: 風雪 <kazeyukiro@users.noreply.github.com>
2026-10-05 17:17:27 +08:00
風雪and風雪 f18419da8b fix(listener): allow TCP and UDP listeners to share a port (#91)
The endpoint conflict guard in ensureEndpointAvailable (and its batch
counterpart ensureBatchEndpointsAvailable) compared only port ranges and
bind addresses — it never looked at the L4 protocol. A TCP listener on
443 and a UDP listener on 443 are independent sockets at the OS level and
Mihomo serves both fine, but 3m-ui rejected the second one with
"conflicts on 0.0.0.0:443". So you could not run e.g. VLESS (TCP) and
TUIC/Hysteria2 (UDP) on the same port.

Add protocol.ListenerTransports, which maps a listener's protocol kind to
the L4 transport(s) its inbound binds (UDP for tuic / hysteria /
hysteria2 / shadowquic / mieru; TCP for everything else). The proxy `udp`
toggle is UDP relay over an established connection and is intentionally
ignored — it does not open a UDP listening socket. The conflict check now
also requires the two listeners to share an L4 transport, so a TCP+UDP
pair on the same address:port no longer collides while two TCP or two UDP
listeners still do.

Tests:
- protocol.ListenerTransports unit tests (udp/tcp/case-insensitive).
- listener.listenersShareTransport unit tests.
- End-to-end: a TCP+UDP pair on 443 coexists and the UDP listener stays on
  443 through Create (it is not silently reassigned to a free port), while
  two TCP or two UDP on 443 still conflict.

Co-authored-by: 風雪 <kazeyukiro@users.noreply.github.com>
2026-10-05 16:51:18 +08:00
kazeyukiro 7bff84bcfa fix(cli): stop rejecting reset-config own flags as unknown arguments
main() 的全局参数扫描在遇到子命令后仍继续遍历,把 reset-config 的
--panel/--access/--public/--all/--yes 当成未知参数直接 log.Fatal,
导致 SSH 救援菜单(选项 16)必然失败并回滚重启:

    unknown argument: --panel

但 reset_config.go 本身是支持这些 flag 的(且 main.go 里的注释也
写了要交给子命令自己解析),只是扫描循环抢先拒绝了。

改为登记接受自有 flag 的子命令,扫描时放行其 flag。无子命令时的
未知参数(如 3m-ui --foo)仍照旧拒绝。
2026-10-05 14:13:44 +08:00
kazeyukiro a1c7013a0c docs(api): document split panel vs Mihomo log endpoints
OpenAPI: GET /system/panel-logs; clarify /mihomo/logs is core-only;
add LogEntry schema; note SSL auto-renew windows on SSL status.
2026-10-04 10:41:51 +00:00
kazeyukiro 3d93b2497a feat(logs): separate panel and Mihomo log streams
Mihomo: GET /mihomo/logs only. Panel: GET /system/panel-logs.
Logs page uses tabs (core vs panel). Stdlib log still captured in panellog.
2026-10-04 10:35:00 +00:00
kazeyukiro a52ab85ab8 feat(logs): include panel runtime logs in UI log stream
Ring-buffer stdlib log output (ACME, bootstrap, errors) with [panel]
prefix and merge with Mihomo lines on GET /mihomo/logs, sorted by time.
2026-10-04 10:31:42 +00:00
kazeyukiro 605533003e fix(acme): restore IP GetCertificate via certificate()/ALPN 2026-10-04 10:20:54 +00:00
kazeyukiro 8af4b09733 fix(acme): check cert renewal every 6 hours 2026-10-04 10:00:26 +00:00
kazeyukiro ab444a8f22 fix(acme): renew domain certs 15 days before expiry
HTTP-01 and DNS-01: renew when <15d remain (was 30d). IP short-lived
certs unchanged (<48h). Status API domain_note documents the window.
2026-10-04 09:57:04 +00:00
kazeyukiro 6698e496ae refactor(acme): merge panel SSL onto acmez only
Replace golang.org/x/crypto/acme/autocert domain HTTP-01 with
domainHTTPIssuer (acmez + scheduled renew). DNS-01 and IP already used
acmez. PEM cache: http-<domain>.crt/.key; auto-renew ~30d before expiry.
2026-10-04 09:48:09 +00:00
kazeyukiro 6ecfe86ad7 fix(ci): align sing-box TUN test with current sub template
Restore interface_name=singbox_tun; expect dns.final=google (wuziwei-style
Ali/Google DNS) instead of legacy remote tag.
2026-10-04 08:26:04 +00:00
kazeyukiro 1871d0c586 feat(sub): add http_clients to sing-box sub; keep jsDelivr rule-sets
Restore wuziwei-style remote rule-sets (no panel hosting) and add
http_clients default (HTTP/2) for rule-set downloads per template.
2026-10-04 05:22:52 +00:00
kazeyukiro 622f42d82f feat(sub): add sing-box http_clients for rule-set downloads 2026-10-04 05:22:11 +00:00
kazeyukiro b1e19b2f7e feat(sub): sing-box CN split via jsDelivr (wuziwei sb-1.15 style)
No panel-hosted rule-sets. Remote MetaCubeX geosite (cn/apple@cn/…) and
cn_ip via cdn.jsdelivr.net; DNS Ali for CN, Google DoH via proxy otherwise.
Remove embedded .srs and /client/rule-set routes.
2026-10-04 05:19:23 +00:00
kazeyukiro 4f1002229d fix(sub): drop TUN route_exclude_address_set for SFI compatibility 2026-10-04 05:14:51 +00:00
kazeyukiro 5c6c856c0f feat(sub): sing-box CN/overseas split per LongLights v1.14 template
DNS: cn_dns (119.29.29.29) for cnsite, proxy_dns (DoH) for gfw/default.
Route: private/BT → Direct-Out, gfw → Default, resolve, cnip → Direct-Out.
Embed MetaCubeX cnsite/cnip/gfw.srs and serve from the panel rule-set API.
2026-10-04 05:14:24 +00:00
kazeyukiro 37d81aaccf feat(sub): full CN split via panel-hosted sing-box rule-sets
Embed geosite-cn.srs / geoip-cn.srs and serve them at
/api/v1/client/rule-set/*.srs on the same host as the subscription.
Subscription stays small for SFI while domain+IP CN coverage is complete.
Remove multi-MB inline domain/IP dumps that broke mobile clients.
2026-10-04 03:47:16 +00:00
kazeyukiro 7f68b7f414 fix(sub): shrink sing-box CN domains so SFI can start 2026-10-04 03:41:13 +00:00
kazeyukiro 833e0f3835 feat(sub): full offline CN domain list for sing-box direct
Embed dnsmasq-china-list accelerated-domains (~110k suffixes) plus
existing CN IP CIDRs so domestic domains/IPs go direct without remote
rule-set downloads that break client startup.
2026-10-03 09:47:49 +00:00
kazeyukiro 16c983e6eb feat(sub): embed CN IP CIDRs for sing-box direct route
Offline geoip-cn equivalent from 17mon/china_ip_list (no remote rule-set).
Private + CN domains + CN ip_cidr → direct; rest → proxy.
2026-10-03 07:52:04 +00:00
kazeyukiro c0d0ac86f2 fix(sub): remove sing-box remote rule-set entirely 2026-10-03 07:49:01 +00:00
kazeyukiro de75878378 fix(sub): use fastly.jsdelivr for sing-box CN rule-sets 2026-10-03 07:38:21 +00:00
kazeyukiro e13c0b01ba fix(sub): sing-box CN rule-set via fastly.jsdelivr.net 2026-10-03 07:37:45 +00:00
kazeyukiro 9a38c824d1 fix(sub): drop remote rule-set for sing-box (startup failure)
GitHub raw geosite/geoip downloads fail on many networks and prevent
SFI/SFM from starting. Use private IP + offline CN domain_suffix list
for direct, final still proxy.
2026-10-03 07:33:43 +00:00
kazeyukiro bd914bc308 revert: remove HY2 URI param refactor
Keep sing-box CN geosite/geoip routing; restore previous HY2 URI export.
2026-10-03 07:08:22 +00:00
kazeyukiro 7cc933e073 feat(sub): sing-box CN geo split; harden HY2 URI for Loon
sing-box subscriptions now route geosite-cn + geoip-cn (remote rule-sets)
and private IPs to direct, matching Clash CN defaults. HY2 share query
params are centralized: always sni/alpn=h3, insecure+allowInsecure when
skip-cert, optional mport for hop — aligned with official URI scheme and
Loon parsers.
2026-10-03 07:06:14 +00:00
kazeyukiro b289523823 fix(sub): restore missing nodes on sing-box subscription
GenerateUserSingboxSubscription only used listenerToProxies and dropped
nodes on export errors; it also ignored remote mirrors and external
links (unlike Clash/v2ray). Add Share ClientYAML recovery (same export
TLS path), merge mirrors/external proxies, unique outbound tags, richer
port parsing, and HY2 auth/password fallback.
2026-10-03 06:42:51 +00:00
kazeyukiro db4b340b5c fix(ci): restore domain SNI preference without PEM 2026-10-03 02:46:35 +00:00
kazeyukiro 5539873cb9 fix(export,uri): Reality SNI, IP-without-PEM, UUID fallback
- ApplyToConfig no longer overwrites Reality camouflage SNI with
  cert-derived IP; Reality always skip-cert
- ResolveClientSNI: IP dial target without PEM uses IP SNI (not AccessSNI
  domain like www.bing.com which forced broken verify)
- VLESS/VMess UUID from username when uuid field empty
- Credential rows always populate uuid for panel UUID-in-username users
2026-10-03 02:12:31 +00:00
kazeyukiro c912769199 fix(sub,uri): stop wiping users; restore same-TLS share recovery
ClientURIsWithCredentials no longer writes an empty users map over
Config (this dropped HY2/AnyTLS/Mieru passwords and emptied subscriptions).
HY2 URI export accepts password/auth when users is absent. Subscription
may still recover via ExportShare* only when primary fails, and Share
already resolves SNI via export.BuildProfile — not a divergent policy.
2026-10-03 01:51:58 +00:00
kazeyukiro 615b199888 fix(ci): set Listener ID via embedded BaseModel in export/share 2026-10-03 01:33:53 +00:00
kazeyukiro a2d7048bbd fix(sub): ban silent alternate SNI path in subscription export
v2ray base64 and Clash/Mihomo YAML subscriptions only use
ClientURIsWithCredentials / listenerToProxies (export.BuildProfile).
Remove ExportShare* fallbacks that could emit a different sni/insecure
without the operator noticing.
2026-10-03 01:31:28 +00:00
kazeyukiro aac7517172 fix(protocol): add NodeModel.ID for certstore-backed share TLS 2026-10-03 01:25:39 +00:00
kazeyukiro 842fd72ea4 refactor(export): unify TLS profile for URI, share and subscription
Introduce internal/export as the single cert/SNI/skip-cert resolver.
ClientURIs, DecodeNodeModel, resolveShareTLS and Clash proxy TLS helpers
all consume BuildProfileFromConfig so formal IP certs always emit sni and
subscriptions no longer diverge from share links on certificate identity.
2026-10-03 01:25:14 +00:00
kazeyukiro 05816736a0 fix(share,uri): load certstore PEM and always emit HY2 sni
DecodeNodeModel now sets listener ID and materializes certificate paths
or certstore PEM. resolveShareTLS expands paths and never leaves SNI
empty on IP hosts. HY2 share/URI default alpn=h3 and force sni=host
when unresolved so Loon no longer sees bare host:port links.
2026-10-03 01:14:45 +00:00
kazeyukiro b36f930099 fix(sub,share,uri): unify SNI/skip-cert across all protocol exports 2026-10-02 15:15:34 +00:00
kazeyukiro 91a9f924a4 fix(share): emit HY2 SNI for IP hosts (formal cert path) 2026-10-02 15:03:42 +00:00
kazeyukiro e9046ffc3f fix(auth): reuse ParseToken err in RequireAuth retry loop 2026-10-02 05:29:26 +00:00