mirror of
https://github.com/coder/coder.git
synced 2025-07-23 21:32:07 +00:00
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:
@ -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)
|
||||
|
Reference in New Issue
Block a user