mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-25 02:55:29 +00:00
1e61084898
* handle control protocol through websocket The necessary behaviour is already in place, but the wasm build only issued GETs, and the handler was not invoked. * get DERP-over-websocket working for wasm clients * Prepare for testing builtin websocket-over-DERP Still needs some way to assert that clients are connected through websockets, rather than the TCP hijacking version of DERP. * integration tests: properly differentiate between DERP transports * do not touch unrelated code * linter fixes * integration testing: unexport common implementation of derp server scenario * fixup! integration testing: unexport common implementation of derp server scenario * dockertestutil/logs: remove unhelpful comment * update changelog --------- Co-authored-by: Csaba Sarkadi <sarkadicsa@tutanota.de>
31 lines
757 B
Go
31 lines
757 B
Go
package util
|
|
|
|
import (
|
|
"cmp"
|
|
"context"
|
|
"net"
|
|
"net/netip"
|
|
)
|
|
|
|
func GrpcSocketDialer(ctx context.Context, addr string) (net.Conn, error) {
|
|
var d net.Dialer
|
|
|
|
return d.DialContext(ctx, "unix", addr)
|
|
}
|
|
|
|
// TODO(kradalby): Remove after go 1.24, will be in stdlib.
|
|
// Compare returns an integer comparing two prefixes.
|
|
// The result will be 0 if p == p2, -1 if p < p2, and +1 if p > p2.
|
|
// Prefixes sort first by validity (invalid before valid), then
|
|
// address family (IPv4 before IPv6), then prefix length, then
|
|
// address.
|
|
func ComparePrefix(p, p2 netip.Prefix) int {
|
|
if c := cmp.Compare(p.Addr().BitLen(), p2.Addr().BitLen()); c != 0 {
|
|
return c
|
|
}
|
|
if c := cmp.Compare(p.Bits(), p2.Bits()); c != 0 {
|
|
return c
|
|
}
|
|
return p.Addr().Compare(p2.Addr())
|
|
}
|