mirror of
https://github.com/juanfont/headscale.git
synced 2026-04-23 00:58:43 +02:00
TS2021: Add Noise upgrade handler
We have more code that we should, as Tailscale has a nice AcceptHTTP() method that should be able to use. However Gin is doing something different. We should have a look later on.
This commit is contained in:
8
app.go
8
app.go
@@ -152,6 +152,8 @@ type Headscale struct {
|
||||
privateKey *key.MachinePrivate
|
||||
noisePrivateKey *key.MachinePrivate
|
||||
|
||||
router *gin.Engine
|
||||
|
||||
DERPMap *tailcfg.DERPMap
|
||||
DERPServer *DERPServer
|
||||
|
||||
@@ -476,6 +478,8 @@ func (h *Headscale) createRouter(grpcMux *runtime.ServeMux) *gin.Engine {
|
||||
"/health",
|
||||
func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"healthy": "ok"}) },
|
||||
)
|
||||
|
||||
router.POST("/ts2021", h.NoiseUpgradeHandler)
|
||||
router.GET("/key", h.KeyHandler)
|
||||
router.GET("/register", h.RegisterWebAPI)
|
||||
router.POST("/machine/:id/map", h.PollNetMapHandler)
|
||||
@@ -671,11 +675,11 @@ func (h *Headscale) Serve() error {
|
||||
// HTTP setup
|
||||
//
|
||||
|
||||
router := h.createRouter(grpcGatewayMux)
|
||||
h.router = h.createRouter(grpcGatewayMux)
|
||||
|
||||
httpServer := &http.Server{
|
||||
Addr: h.cfg.Addr,
|
||||
Handler: router,
|
||||
Handler: h.router,
|
||||
ReadTimeout: HTTPReadTimeout,
|
||||
// Go does not handle timeouts in HTTP very well, and there is
|
||||
// no good way to handle streaming timeouts, therefore we need to
|
||||
|
||||
Reference in New Issue
Block a user