diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2026-03-07 18:33:02 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@tailscale.com> | 2026-03-07 18:33:02 +0000 |
| commit | 7b081a98bdbce817a2b3e7929d6a8c7f1c551b35 (patch) | |
| tree | 5598f046f24c82fd16f8cca1379e380da1d06e92 /disco/disco.go | |
| parent | e400d5aa7b22ef131d2b05a1df89177f87dd3922 (diff) | |
| download | tailscale-dctp1.tar.xz tailscale-dctp1.zip | |
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Diffstat (limited to 'disco/disco.go')
| -rw-r--r-- | disco/disco.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/disco/disco.go b/disco/disco.go index 8f667b262..fef30f3e3 100644 --- a/disco/disco.go +++ b/disco/disco.go @@ -57,6 +57,10 @@ const v0 = byte(0) var errShort = errors.New("short message") +// ParseHook, if non-nil, is called for unknown message types. +// If it returns (nil, nil), Parse returns the default "unknown type" error. +var ParseHook func(t MessageType, ver uint8, p []byte) (Message, error) + // LooksLikeDiscoWrapper reports whether p looks like it's a packet // containing an encrypted disco message. func LooksLikeDiscoWrapper(p []byte) bool { @@ -104,6 +108,11 @@ func Parse(p []byte) (Message, error) { case TypeAllocateUDPRelayEndpointResponse: return parseAllocateUDPRelayEndpointResponse(ver, p) default: + if ParseHook != nil { + if m, err := ParseHook(t, ver, p); m != nil || err != nil { + return m, err + } + } return nil, fmt.Errorf("unknown message type 0x%02x", byte(t)) } } |
