From 7ea63913b9eeea79873eba78d4f18185a4221745 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 3 Jan 2018 11:12:21 -0800 Subject: [PATCH] cmd/routed: alt-svc fix again --- cmd/routed/main.go | 2 ++ cmd/routed/server.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/routed/main.go b/cmd/routed/main.go index 355d733..323c561 100644 --- a/cmd/routed/main.go +++ b/cmd/routed/main.go @@ -87,6 +87,8 @@ func setupQuic(s *Server, scfg Config) { }, } + s.QuicServer = qs + for { ln.FatalErr(context.Background(), qs.ListenAndServe()) } diff --git a/cmd/routed/server.go b/cmd/routed/server.go index 2c9b72b..932b710 100644 --- a/cmd/routed/server.go +++ b/cmd/routed/server.go @@ -3,7 +3,6 @@ package main import ( "crypto/tls" "errors" - "fmt" "net" "net/http" "net/http/httputil" @@ -13,6 +12,7 @@ import ( "git.xeserv.us/xena/route/internal/tun2" proto "git.xeserv.us/xena/route/proto" "github.com/Xe/ln" + "github.com/lucas-clemente/quic-go/h2quic" "github.com/mtneug/pkg/ulid" kcp "github.com/xtaci/kcp-go" "golang.org/x/crypto/acme/autocert" @@ -32,6 +32,8 @@ type Server struct { db database.Storage ts *tun2.Server + QuicServer *h2quic.Server + *autocert.Manager } @@ -185,7 +187,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { rid := ulid.New().String() r.Header.Set("X-Request-Id", rid) w.Header().Set("X-Request-Id", rid) - w.Header().Add("Alt-Svc", fmt.Sprintf(`hq="%s"; ma=2592000`, s.cfg.QuicAddr)) + s.QuicServer.SetQuicHeaders(w.Header()) // http://www.gnuterrypratchett.com/ w.Header().Set("X-Clacks-Overhead", "GNU Ashlynn")