mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
tailcfg: break DERPNode.DERPTestPort into DERPPort & InsecureForTests
The DERPTestPort int meant two things before: which port to use, and whether to disable TLS verification. Users would like to set the port without disabling TLS, so break it into two options. Updates #1264 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
92077ae78c
commit
7e7c4c1bbe
@ -410,9 +410,7 @@ func (c *Client) dialRegion(ctx context.Context, reg *tailcfg.DERPRegion) (net.C
|
|||||||
func (c *Client) tlsClient(nc net.Conn, node *tailcfg.DERPNode) *tls.Conn {
|
func (c *Client) tlsClient(nc net.Conn, node *tailcfg.DERPNode) *tls.Conn {
|
||||||
tlsConf := tlsdial.Config(c.tlsServerName(node), c.TLSConfig)
|
tlsConf := tlsdial.Config(c.tlsServerName(node), c.TLSConfig)
|
||||||
if node != nil {
|
if node != nil {
|
||||||
if node.DERPTestPort != 0 {
|
tlsConf.InsecureSkipVerify = node.InsecureForTests
|
||||||
tlsConf.InsecureSkipVerify = true
|
|
||||||
}
|
|
||||||
if node.CertName != "" {
|
if node.CertName != "" {
|
||||||
tlsdial.SetConfigExpectedCert(tlsConf, node.CertName)
|
tlsdial.SetConfigExpectedCert(tlsConf, node.CertName)
|
||||||
}
|
}
|
||||||
@ -511,8 +509,8 @@ type res struct {
|
|||||||
dst = n.HostName
|
dst = n.HostName
|
||||||
}
|
}
|
||||||
port := "443"
|
port := "443"
|
||||||
if n.DERPTestPort != 0 {
|
if n.DERPPort != 0 {
|
||||||
port = fmt.Sprint(n.DERPTestPort)
|
port = fmt.Sprint(n.DERPPort)
|
||||||
}
|
}
|
||||||
c, err := c.dialContext(ctx, proto, net.JoinHostPort(dst, port))
|
c, err := c.dialContext(ctx, proto, net.JoinHostPort(dst, port))
|
||||||
select {
|
select {
|
||||||
|
@ -130,10 +130,15 @@ type DERPNode struct {
|
|||||||
// server.
|
// server.
|
||||||
STUNOnly bool `json:",omitempty"`
|
STUNOnly bool `json:",omitempty"`
|
||||||
|
|
||||||
// DERPTestPort is used in tests to override the port, instead
|
// DERPPort optionally provides an alternate TLS port number
|
||||||
// of using the default port of 443. If non-zero, TLS
|
// for the DERP HTTPS server.
|
||||||
// verification is skipped.
|
//
|
||||||
DERPTestPort int `json:",omitempty"`
|
// If zero, 443 is used.
|
||||||
|
DERPPort int `json:",omitempty"`
|
||||||
|
|
||||||
|
// InsecureForTests is used by unit tests to disable TLS verification.
|
||||||
|
// It should not be set by users.
|
||||||
|
InsecureForTests bool `json:",omitempty"`
|
||||||
|
|
||||||
// STUNTestIP is used in tests to override the STUN server's IP.
|
// STUNTestIP is used in tests to override the STUN server's IP.
|
||||||
// If empty, it's assumed to be the same as the DERP server.
|
// If empty, it's assumed to be the same as the DERP server.
|
||||||
|
@ -327,16 +327,17 @@ func (src *DERPNode) Clone() *DERPNode {
|
|||||||
// A compilation failure here means this code must be regenerated, with command:
|
// A compilation failure here means this code must be regenerated, with command:
|
||||||
// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Login,DNSConfig,DNSResolver,RegisterResponse,DERPRegion,DERPMap,DERPNode
|
// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Login,DNSConfig,DNSResolver,RegisterResponse,DERPRegion,DERPMap,DERPNode
|
||||||
var _DERPNodeNeedsRegeneration = DERPNode(struct {
|
var _DERPNodeNeedsRegeneration = DERPNode(struct {
|
||||||
Name string
|
Name string
|
||||||
RegionID int
|
RegionID int
|
||||||
HostName string
|
HostName string
|
||||||
CertName string
|
CertName string
|
||||||
IPv4 string
|
IPv4 string
|
||||||
IPv6 string
|
IPv6 string
|
||||||
STUNPort int
|
STUNPort int
|
||||||
STUNOnly bool
|
STUNOnly bool
|
||||||
DERPTestPort int
|
DERPPort int
|
||||||
STUNTestIP string
|
InsecureForTests bool
|
||||||
|
STUNTestIP string
|
||||||
}{})
|
}{})
|
||||||
|
|
||||||
// Clone duplicates src into dst and reports whether it succeeded.
|
// Clone duplicates src into dst and reports whether it succeeded.
|
||||||
|
@ -145,14 +145,15 @@ func RunDERPAndSTUN(t testing.TB, logf logger.Logf, ipAddress string) (derpMap *
|
|||||||
RegionCode: "test",
|
RegionCode: "test",
|
||||||
Nodes: []*tailcfg.DERPNode{
|
Nodes: []*tailcfg.DERPNode{
|
||||||
{
|
{
|
||||||
Name: "t1",
|
Name: "t1",
|
||||||
RegionID: 1,
|
RegionID: 1,
|
||||||
HostName: ipAddress,
|
HostName: ipAddress,
|
||||||
IPv4: ipAddress,
|
IPv4: ipAddress,
|
||||||
IPv6: "none",
|
IPv6: "none",
|
||||||
STUNPort: stunAddr.Port,
|
STUNPort: stunAddr.Port,
|
||||||
DERPTestPort: httpsrv.Listener.Addr().(*net.TCPAddr).Port,
|
DERPPort: httpsrv.Listener.Addr().(*net.TCPAddr).Port,
|
||||||
STUNTestIP: stunAddr.IP.String(),
|
InsecureForTests: true,
|
||||||
|
STUNTestIP: stunAddr.IP.String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -95,14 +95,15 @@ func runDERPAndStun(t *testing.T, logf logger.Logf, l nettype.PacketListener, st
|
|||||||
RegionCode: "test",
|
RegionCode: "test",
|
||||||
Nodes: []*tailcfg.DERPNode{
|
Nodes: []*tailcfg.DERPNode{
|
||||||
{
|
{
|
||||||
Name: "t1",
|
Name: "t1",
|
||||||
RegionID: 1,
|
RegionID: 1,
|
||||||
HostName: "test-node.unused",
|
HostName: "test-node.unused",
|
||||||
IPv4: "127.0.0.1",
|
IPv4: "127.0.0.1",
|
||||||
IPv6: "none",
|
IPv6: "none",
|
||||||
STUNPort: stunAddr.Port,
|
STUNPort: stunAddr.Port,
|
||||||
DERPTestPort: httpsrv.Listener.Addr().(*net.TCPAddr).Port,
|
DERPPort: httpsrv.Listener.Addr().(*net.TCPAddr).Port,
|
||||||
STUNTestIP: stunIP.String(),
|
InsecureForTests: true,
|
||||||
|
STUNTestIP: stunIP.String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user