Add experimental support for HTTP/3 (#8)

* Wait for service in integration tests instead of watching for a string

* Add http3 experimental support
This commit is contained in:
2023-03-18 20:38:18 +01:00
committed by Daniel Carrillo
parent de78dcdf52
commit 19c72f94a5
9 changed files with 213 additions and 42 deletions

View File

@ -29,6 +29,7 @@ type settings struct {
TrustedHeader string
TrustedPortHeader string
EnableSecureHeaders bool
EnableHTTP3 bool
Server serverSettings
version bool
}
@ -89,6 +90,12 @@ func Setup(args []string) (output string, err error) {
false,
"Add sane security-related headers to every response",
)
flags.BoolVar(
&App.EnableHTTP3,
"enable-http3",
false,
"Enable HTTP/3 protocol. HTTP/3 requires --tls-bind set, as HTTP/3 starts as a TLS connection that then gets upgraded to UDP. The UDP port is the same as the one used for the TLS server.",
)
err = flags.Parse(args)
if err != nil {
@ -111,6 +118,10 @@ func Setup(args []string) (output string, err error) {
return "", fmt.Errorf("in order to use TLS, the -tls-crt and -tls-key flags are mandatory")
}
if App.EnableHTTP3 && App.TLSAddress == "" {
return "", fmt.Errorf("in order to use HTTP3, the -tls-bind is mandatory")
}
if App.TemplatePath != "" {
info, err := os.Stat(App.TemplatePath)
if os.IsNotExist(err) {

View File

@ -41,6 +41,11 @@ func TestParseMandatoryFlags(t *testing.T) {
"-tls-key", "/key-path",
},
},
{
[]string{
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path", "-enable-http3",
},
},
{
[]string{
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path", "-bind", ":8000",