Skip to content

Commit

Permalink
feat(caddy): remove experimental HTTP/3 switch and adapt v2.6 json api
Browse files Browse the repository at this point in the history
Caddy v2.6.0 enables HTTP/3 by default

caddyserver/caddy#4707
  • Loading branch information
xiayesuifeng committed Sep 23, 2022
1 parent 8363993 commit fff3529
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 58 deletions.
6 changes: 4 additions & 2 deletions experiments/caddyManager/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ func (m *Manager) convertToCaddyConfig() (config *Config) {
serverName := map[int]string{app.HTTPSPort: m.HTTPSServerName}

servers[m.HTTPSServerName] = newServer(fmt.Sprintf(":%d", app.HTTPSPort))
servers[m.HTTPSServerName].ExperimentalHTTP3 = m.caddyConf.General.ExperimentalHttp3
servers[m.HTTPSServerName].AllowH2C = m.caddyConf.General.AllowH2C

if m.caddyConf.General.AllowH2C {
servers[m.HTTPSServerName].Protocols = []string{"h1", "h2", "h2c", "h3"}
}

wildcardDomainsApp, normalApp := filterWildcardDomainsApp(m.caddyConf.TLS.WildcardDomains, m.app)

Expand Down
22 changes: 5 additions & 17 deletions experiments/caddyutil/caddyconfig/caddyconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
)

const (
HTTPPortKey = "general/httpPort"
HTTPSPortKey = "general/httpsPort"
ExperimentalHttp3Key = "general/experimentalHttp3"
AllowH2CKey = "general/allowH2C"
HTTPPortKey = "general/httpPort"
HTTPSPortKey = "general/httpsPort"
AllowH2CKey = "general/allowH2C"

TLSKey = "tls"

Expand All @@ -28,8 +27,7 @@ type General struct {
HTTPPort int `json:"HTTPPort"`
HTTPSPort int `json:"HTTPSPort"`

ExperimentalHttp3 bool `json:"experimentalHttp3"`
AllowH2C bool `json:"allowH2C"`
AllowH2C bool `json:"allowH2C"`
}

type TLS struct {
Expand Down Expand Up @@ -76,11 +74,6 @@ func GetConfiguration() *Configuration {
caddy.General.HTTPSPort = httpsPort
}

experimentalHttp3, err := strconv.ParseBool(string(storage.Get(module, ExperimentalHttp3Key, []byte("false"))))
if err == nil {
caddy.General.ExperimentalHttp3 = experimentalHttp3
}

allowH2C, err := strconv.ParseBool(string(storage.Get(module, AllowH2CKey, []byte("false"))))
if err == nil {
caddy.General.AllowH2C = allowH2C
Expand Down Expand Up @@ -112,12 +105,7 @@ func SetConfiguration(configuration *Configuration) error {
}
}

err := storage.Set(module, ExperimentalHttp3Key, []byte(strconv.FormatBool(configuration.General.ExperimentalHttp3)))
if err != nil {
return err
}

err = storage.Set(module, AllowH2CKey, []byte(strconv.FormatBool(configuration.General.AllowH2C)))
err := storage.Set(module, AllowH2CKey, []byte(strconv.FormatBool(configuration.General.AllowH2C)))
if err != nil {
return err
}
Expand Down
34 changes: 18 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module gitlab.com/xiayesuifeng/gopanel

require (
github.com/caddyserver/caddy/v2 v2.5.3-0.20220803170451-1960a0dc117d
github.com/caddyserver/caddy/v2 v2.6.2-0.20220922150918-eead00f54a4b
github.com/coreos/go-systemd/v22 v22.3.2
github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19
github.com/gin-gonic/gin v1.7.7
Expand All @@ -22,12 +22,11 @@ require (
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220722194653-14703f21b580 // indirect
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/caddyserver/certmagic v0.16.2 // indirect
github.com/caddyserver/certmagic v0.17.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/dgraph-io/badger v1.6.2 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.0.4-0.20200906165740-41ebdbffecfd // indirect
Expand All @@ -43,12 +42,14 @@ require (
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/cel-go v0.12.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.10.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
Expand All @@ -64,20 +65,18 @@ require (
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lib/pq v1.10.4 // indirect
github.com/libdns/libdns v0.2.1 // indirect
github.com/lucas-clemente/quic-go v0.28.1 // indirect
github.com/lucas-clemente/quic-go v0.28.2-0.20220813150001-9957668d4301 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/marten-seemann/qpack v0.2.1 // indirect
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect
github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1 // indirect
github.com/marten-seemann/qtls-go1-19 v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mholt/acmez v1.0.4 // indirect
github.com/micromdm/scep/v2 v2.1.0 // indirect
github.com/miekg/dns v1.1.46 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
Expand All @@ -91,16 +90,18 @@ require (
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rs/xid v1.2.1 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/slackhq/nebula v1.5.2 // indirect
github.com/smallstep/certificates v0.21.0 // indirect
github.com/smallstep/cli v0.21.0 // indirect
github.com/smallstep/nosql v0.4.0 // indirect
github.com/smallstep/truststore v0.11.0 // indirect
github.com/smallstep/truststore v0.12.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v1.1.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/tailscale/tscert v0.0.0-20220316030059-54bbcb9f74e2 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
Expand All @@ -114,13 +115,14 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220812165438-1d4ff48094d1 // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b // indirect
golang.org/x/tools v0.1.7 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.46.0 // indirect
Expand Down

0 comments on commit fff3529

Please sign in to comment.