From 607c1eb3163999fb310170a5ee67a83c634e8196 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Fri, 4 Mar 2022 11:31:41 +0100 Subject: [PATCH] Be consistent with uppercase DERP --- app.go | 12 ++++++------ derp_embedded.go | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app.go b/app.go index 3115b99..eb3b8ad 100644 --- a/app.go +++ b/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") diff --git a/derp_embedded.go b/derp_embedded.go index 0631fff..1d4fb0b 100644 --- a/derp_embedded.go +++ b/derp_embedded.go @@ -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,