Adds two tests covering the fix in 0e4c8fc92: TestDialNodeUsingProxyPort exercises dialNodeUsingProxy directly via a stub CONNECT proxy, asserting the recorded target across four cases: HTTPS/HTTP default fallback and explicit DERPPort override for each. TestConnectThroughProxyHonorsDERPPort drives the full path end-to-end: a real derpserver on an ephemeral TLS port, a real CONNECT proxy that tunnels bytes bidirectionally, and a region client routed through it via feature.HookProxyFromEnvironment. Without the fix, Connect fails because the proxy is asked to dial :443. Signed-off-by: Martin Zihlmann <martizih@outlook.com>
37 lines
823 B
Go
37 lines
823 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package derphttp
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"net/url"
|
|
|
|
"tailscale.com/tailcfg"
|
|
)
|
|
|
|
func SetTestHookWatchLookConnectResult(f func(connectError error, wasSelfConnect bool) (keepRunning bool)) {
|
|
testHookWatchLookConnectResult = f
|
|
}
|
|
|
|
func (c *Client) DialNodeUsingProxy(ctx context.Context, n *tailcfg.DERPNode, proxyURL *url.URL) (net.Conn, error) {
|
|
return c.dialNodeUsingProxy(ctx, n, proxyURL)
|
|
}
|
|
|
|
// breakConnection breaks the connection, which should trigger a reconnect.
|
|
func (c *Client) BreakConnection(brokenClient *Client) {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
if c.client != brokenClient.client {
|
|
return
|
|
}
|
|
if c.netConn != nil {
|
|
c.netConn.Close()
|
|
c.netConn = nil
|
|
}
|
|
c.client = nil
|
|
}
|
|
|
|
var RetryInterval = &retryInterval
|