Skip to content

WireGuard/AmneziaWG: missing random-trailers option breaks handshake against RandomTrailers-enabled servers #2422

Description

@zzeygarnik

Summary

WireGuard/AmneziaWG handshakes fail against a server running AmneziaWG v1.5 (v3.1+) with RandomTrailers enabled, because FlClash's outbound wrapper never forwards a random-trailers option into the UAPI config, even though the pinned core already supports it.

Details

  • FlClash version tested: v0.8.97
  • Core: chen08209/Clash.Meta@70f0570, pinning github.com/metacubex/amneziawg-go v0.0.0-20260816073447-736a78668832
  • Server: AmneziaWG 1.5, RandomTrailers = on

That pinned amneziawg-go does implement random_trailers in its UAPI (device/uapi.go:530), but adapter/outbound/wireguard.go in both the pinned commit and the current FlClash branch HEAD never writes random_trailers= into the UAPI config — there's no RandomTrailers field on the WireGuard outbound option struct at all.

Effect: with trailers on, the server appends fastrandn(udpWindow - packetSize) random bytes to every handshake response (device/send.go, sendHandshakeResponse). The client-side engine's DeterminePacketTypeAndPadding (device/receive.go ~line 604) only accepts a handshake response when size == padding+MessageSize, since randomTrailers is never set to true on the client. So every handshake response from a RandomTrailers-enabled server gets silently dropped as malformed, even though the initial handshake (client → server) succeeds and the server correctly learns the peer.

Symptom from the server side: peer's endpoint gets learned, sent/received byte counters climb, but latest handshake never appears — because the client never accepts the response and never sends a data packet under the new keypair.

Upstream fix already exists

MetaCubeX/mihomo@Alpha already has this: adapter/outbound/wireguard.go:139

```go
RandomTrailers bool proxy:"random-trailers,omitempty" // AmneziaWG v3.1+
```

emitted as random_trailers=1 in the UAPI config it builds.

Ask

Please sync FlClash's Clash.Meta core (or just this option) with MetaCubeX/mihomo@Alpha's WireGuard outbound, so amnezia-wg-option.random-trailers: true in a proxy profile actually reaches the engine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions