feat: allow DERP headers to be set (#6572)

* feat: allow DERP headers to be set

* chore: remove custom flag

* Clone DERP header on client create

* Adjust to use interface to cast headers

---------

Co-authored-by: Kyle Carberry <kyle@carberry.com>
This commit is contained in:
Josh Vawdrey
2023-03-21 18:43:20 +00:00
committed by GitHub
co-authored by Kyle Carberry
parent d8aee26776
commit 97f77c4507
4 changed files with 30 additions and 11 deletions
+7 -2
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net"
"net/http"
"net/netip"
"reflect"
"strconv"
@@ -50,8 +51,9 @@ func init() {
}
type Options struct {
Addresses []netip.Prefix
DERPMap *tailcfg.DERPMap
Addresses []netip.Prefix
DERPMap *tailcfg.DERPMap
DERPHeader *http.Header
// BlockEndpoints specifies whether P2P endpoints are blocked.
// If so, only DERPs can establish connections.
@@ -159,6 +161,9 @@ func NewConn(options *Options) (conn *Conn, err error) {
if !ok {
return nil, xerrors.New("get wireguard internals")
}
if options.DERPHeader != nil {
magicConn.SetDERPHeader(options.DERPHeader.Clone())
}
// Update the keys for the magic connection!
err = magicConn.SetPrivateKey(nodePrivateKey)