Skip to content

Fix with_tailscale/with_cloudflared/with_masque builds, register legacy WireGuard outbound#32

Open
hiddifydeveloper wants to merge 4 commits into
hiddify:v5from
hiddifydeveloper:v5-followup-fixes
Open

Fix with_tailscale/with_cloudflared/with_masque builds, register legacy WireGuard outbound#32
hiddifydeveloper wants to merge 4 commits into
hiddify:v5from
hiddifydeveloper:v5-followup-fixes

Conversation

@hiddifydeveloper

Copy link
Copy Markdown

Summary

Follow-up to #31 (merged before these 4 commits were pushed). Fixes build breaks in tag-gated packages that plain go build ./... doesn't cover, plus a real registration bug found during protocol testing.

What's fixed

  • cloudflare: sing-cloudflared's ICMPHandler interface changed from session-based RouteICMPConnection to RouteICMPFlow(source, destination) (tun.Port, error). Rewired to extract a tun.Port from the router's PreMatchResult.
  • tailscale (the big one): adapter.DirectRouteOutbound is gone, replaced by adapter.FlowOutbound (tun.Port + PreMatchFlow). ICMP flow routing now backs onto sing-tun's ping.Port. Also fixed PreferredAddress/PreferredDomain signatures, added the required Logout method, and stubbed three hooks with no current upstream replacement — netns.SetControlFunc (only Android protect-func has one now), tsnet.Server.PeerDNSQueryHandler, LocalBackend.SetExternalSSHHostKeys — each documented inline.
  • masque: same tun.NewICMPForwarder signature drift as cloudflare/tailscale.
  • wireguard (legacy outbound): was never registered at all — code existed but no call site, so configs silently hit upstream's "WireGuard outbound is deprecated" stub under the same "wireguard" name. Registered under a new wireguard_legacy type instead of overriding the stub.

Note: full-tag builds need the badlinkname tag dropped on Go 1.25.6 — pre-existing upstream crypto/tls linkname fragility, unrelated to this PR (confirmed common/badtls untouched by any commit here).

Test plan

  • go build with full release/DEFAULT_BUILD_TAGS (minus badlinkname) succeeds
  • go vet clean under the same tag set (aside from pre-existing upstream-only issues in untouched files)
  • sing-box check against configs for every ported protocol (WireGuard+Noise, AmneziaWG, WARP, VLESS+XHTTP, VLESS+Vision, mieru, snell, psiphon, balancer, hinvalid, dnstt, gooserelay, tunnel_client, SSH in/outbound, legacy WireGuard outbound, MASQUE, monitoring, proxyproto, cloudflared inbound, smart_dns_pool) — all construct/start/stop cleanly
  • Live network handshake test — not done, recommend before merge

sing-cloudflared's ICMPHandler interface changed from a session-based
RouteICMPConnection(ctx, session, routeContext, timeout) to
RouteICMPFlow(source, destination) (tun.Port, error), matching
upstream's PreMatch/JudgeFlow flow-routing model. Rewrites
icmpRouterHandler accordingly, extracting a tun.Port from the
router's PreMatchResult instead of a tun.DirectRouteDestination.
Several APIs the tailscale endpoint depended on were removed or
reshaped upstream since hiddify's fork diverged:

- adapter.DirectRouteOutbound (session-based PrepareConnection/
  NewDirectRouteConnection) is gone, replaced by adapter.FlowOutbound
  (tun.Port + PreMatchFlow). Endpoint now backs its ICMP flow routing
  with sing-tun's ping.Port instead of the removed
  ping.ConnectDestination/ConnectGVisor helpers.
- port.go's JudgeFlow/WritePackets implementation depended on
  wgEngine.InputPackets/SetReturnPath, which were never actually
  implemented anywhere in this tailscale fork (dead code). Replaced
  with a JudgeFlow that delegates to adapter.JudgeFlow after checking
  Tailscale's ACL filter, for the gVisor ICMPForwarder's
  traffic-from-peers path; the never-functional whole-packet
  TCP/UDP forwarding via wgEngine is dropped.
- OutboundWithPreferredRoutes.PreferredAddress/PreferredDomain gained
  a *adapter.InboundContext parameter.
- adapter.TailscaleEndpoint gained a Logout method, implemented via
  the fork's client/local.Client.Logout.
- netns.SetControlFunc was removed; only the Android protect-func
  path has a replacement (netns.SetAndroidProtectFunc, split into
  netns_android.go/netns_stub.go since it's Android-build-tagged in
  the fork). The non-Android auto-redirect-mark control path has no
  replacement and is dropped (documented inline).
- tsnet.Server.PeerDNSQueryHandler was removed with no replacement
  hook; peer DNS queries no longer route through dnsRouter (dead
  code left in place, documented, pending a new hook upstream).
- LocalBackend.SetExternalSSHHostKeys (tailssh) was removed; peer
  status no longer reports the custom SSH server's host key.
tun.NewICMPForwarder dropped its context/timeout parameters in favor
of (stack, handler, logger), matching the cloudflare and tailscale
ICMP forwarder fixes.
…ed up)

protocol/wireguard.RegisterOutbound existed but had no call site in
include/registry.go, so configs using it always hit upstream's
deliberate "WireGuard outbound is deprecated... use WireGuard
endpoint instead" stub registered under the same "wireguard" type
name. Registers it under a new "wireguard_legacy" type instead of
overriding upstream's stub, so existing deprecation messaging for
"wireguard" stays intact and adopting the legacy outbound is an
explicit opt-in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant