Be consistent with uppercase DERP
This commit is contained in:
parent
23cde8445f
commit
607c1eb316
2 changed files with 15 additions and 15 deletions
12
app.go
12
app.go
|
@ -144,7 +144,7 @@ type Headscale struct {
|
|||
privateKey *key.MachinePrivate
|
||||
|
||||
DERPMap *tailcfg.DERPMap
|
||||
EmbeddedDerpServer *EmbeddedDerpServer
|
||||
EmbeddedDERPServer *EmbeddedDERPServer
|
||||
|
||||
aclPolicy *ACLPolicy
|
||||
aclRules []tailcfg.FilterRule
|
||||
|
@ -242,11 +242,11 @@ func NewHeadscale(cfg Config) (*Headscale, error) {
|
|||
}
|
||||
|
||||
if cfg.DERP.EmbeddedDERP {
|
||||
embeddedDerpServer, err := app.NewEmbeddedDerpServer()
|
||||
embeddedDERPServer, err := app.NewEmbeddedDERPServer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
app.EmbeddedDerpServer = embeddedDerpServer
|
||||
app.EmbeddedDERPServer = embeddedDERPServer
|
||||
|
||||
// If we are using the embedded DERP, there is no reason to use Tailscale's DERP infrastructure
|
||||
serverURL, err := url.Parse(app.cfg.ServerURL)
|
||||
|
@ -496,9 +496,9 @@ func (h *Headscale) createRouter(grpcMux *runtime.ServeMux) *gin.Engine {
|
|||
router.GET("/swagger/v1/openapiv2.json", SwaggerAPIv1)
|
||||
|
||||
if h.cfg.DERP.EmbeddedDERP {
|
||||
router.Any("/derp", h.EmbeddedDerpHandler)
|
||||
router.Any("/derp/probe", h.EmbeddedDerpProbeHandler)
|
||||
router.Any("/bootstrap-dns", h.EmbeddedDerpBootstrapDNSHandler)
|
||||
router.Any("/derp", h.EmbeddedDERPHandler)
|
||||
router.Any("/derp/probe", h.EmbeddedDERPProbeHandler)
|
||||
router.Any("/bootstrap-dns", h.EmbeddedDERPBootstrapDNSHandler)
|
||||
}
|
||||
|
||||
api := router.Group("/api")
|
||||
|
|
|
@ -28,17 +28,17 @@ var (
|
|||
bootstrapDNS = "derp.tailscale.com"
|
||||
)
|
||||
|
||||
type EmbeddedDerpServer struct {
|
||||
tailscaleDerp *derp.Server
|
||||
type EmbeddedDERPServer struct {
|
||||
tailscaleDERP *derp.Server
|
||||
}
|
||||
|
||||
func (h *Headscale) NewEmbeddedDerpServer() (*EmbeddedDerpServer, error) {
|
||||
func (h *Headscale) NewEmbeddedDERPServer() (*EmbeddedDERPServer, error) {
|
||||
s := derp.NewServer(key.NodePrivate(*h.privateKey), log.Info().Msgf)
|
||||
return &EmbeddedDerpServer{s}, nil
|
||||
return &EmbeddedDERPServer{s}, nil
|
||||
|
||||
}
|
||||
|
||||
func (h *Headscale) EmbeddedDerpHandler(ctx *gin.Context) {
|
||||
func (h *Headscale) EmbeddedDERPHandler(ctx *gin.Context) {
|
||||
up := strings.ToLower(ctx.Request.Header.Get("Upgrade"))
|
||||
if up != "websocket" && up != "derp" {
|
||||
if up != "" {
|
||||
|
@ -75,12 +75,12 @@ func (h *Headscale) EmbeddedDerpHandler(ctx *gin.Context) {
|
|||
pubKey.UntypedHexString())
|
||||
}
|
||||
|
||||
h.EmbeddedDerpServer.tailscaleDerp.Accept(netConn, conn, netConn.RemoteAddr().String())
|
||||
h.EmbeddedDERPServer.tailscaleDERP.Accept(netConn, conn, netConn.RemoteAddr().String())
|
||||
}
|
||||
|
||||
// EmbeddedDerpProbeHandler is the endpoint that js/wasm clients hit to measure
|
||||
// EmbeddedDERPProbeHandler is the endpoint that js/wasm clients hit to measure
|
||||
// DERP latency, since they can't do UDP STUN queries.
|
||||
func (h *Headscale) EmbeddedDerpProbeHandler(ctx *gin.Context) {
|
||||
func (h *Headscale) EmbeddedDERPProbeHandler(ctx *gin.Context) {
|
||||
switch ctx.Request.Method {
|
||||
case "HEAD", "GET":
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
|
@ -89,7 +89,7 @@ func (h *Headscale) EmbeddedDerpProbeHandler(ctx *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Headscale) EmbeddedDerpBootstrapDNSHandler(ctx *gin.Context) {
|
||||
func (h *Headscale) EmbeddedDERPBootstrapDNSHandler(ctx *gin.Context) {
|
||||
ctx.Header("Content-Type", "application/json")
|
||||
j, _ := dnsCache.Load().([]byte)
|
||||
// Bootstrap DNS requests occur cross-regions,
|
||||
|
|
Loading…
Reference in a new issue