mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
main: use x/net/http2 directly and add option to disable http2
This commit is contained in:
parent
24c40fe484
commit
4349f7d75e
3 changed files with 19 additions and 1 deletions
|
@ -33,9 +33,14 @@ import (
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Web WebConfig `yaml:"web"`
|
Web WebConfig `yaml:"web"`
|
||||||
|
Matrix MatrixConfig `yaml:"matrix"`
|
||||||
Logging zeroconfig.Config `yaml:"logging"`
|
Logging zeroconfig.Config `yaml:"logging"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MatrixConfig struct {
|
||||||
|
DisableHTTP2 bool `yaml:"disable_http2"`
|
||||||
|
}
|
||||||
|
|
||||||
type WebConfig struct {
|
type WebConfig struct {
|
||||||
ListenAddress string `yaml:"listen_address"`
|
ListenAddress string `yaml:"listen_address"`
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
|
@ -59,6 +64,9 @@ func makeDefaultConfig() Config {
|
||||||
Web: WebConfig{
|
Web: WebConfig{
|
||||||
ListenAddress: "localhost:29325",
|
ListenAddress: "localhost:29325",
|
||||||
},
|
},
|
||||||
|
Matrix: MatrixConfig{
|
||||||
|
DisableHTTP2: false,
|
||||||
|
},
|
||||||
Logging: zeroconfig.Config{
|
Logging: zeroconfig.Config{
|
||||||
MinLevel: ptr.Ptr(zerolog.DebugLevel),
|
MinLevel: ptr.Ptr(zerolog.DebugLevel),
|
||||||
Writers: []zeroconfig.WriterConfig{{
|
Writers: []zeroconfig.WriterConfig{{
|
||||||
|
|
|
@ -36,6 +36,7 @@ import (
|
||||||
"go.mau.fi/util/dbutil"
|
"go.mau.fi/util/dbutil"
|
||||||
"go.mau.fi/util/exerrors"
|
"go.mau.fi/util/exerrors"
|
||||||
"go.mau.fi/util/exzerolog"
|
"go.mau.fi/util/exzerolog"
|
||||||
|
"golang.org/x/net/http2"
|
||||||
|
|
||||||
"go.mau.fi/gomuks/pkg/hicli"
|
"go.mau.fi/gomuks/pkg/hicli"
|
||||||
)
|
)
|
||||||
|
@ -176,6 +177,15 @@ func (gmx *Gomuks) StartClient() {
|
||||||
[]byte("meow"),
|
[]byte("meow"),
|
||||||
hicli.JSONEventHandler(gmx.OnEvent).HandleEvent,
|
hicli.JSONEventHandler(gmx.OnEvent).HandleEvent,
|
||||||
)
|
)
|
||||||
|
httpClient := gmx.Client.Client.Client
|
||||||
|
httpClient.Transport.(*http.Transport).ForceAttemptHTTP2 = false
|
||||||
|
if !gmx.Config.Matrix.DisableHTTP2 {
|
||||||
|
_, err = http2.ConfigureTransports(httpClient.Transport.(*http.Transport))
|
||||||
|
if err != nil {
|
||||||
|
gmx.Log.WithLevel(zerolog.FatalLevel).Err(err).Msg("Failed to configure HTTP/2")
|
||||||
|
os.Exit(13)
|
||||||
|
}
|
||||||
|
}
|
||||||
userID, err := gmx.Client.DB.Account.GetFirstUserID(ctx)
|
userID, err := gmx.Client.DB.Account.GetFirstUserID(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gmx.Log.WithLevel(zerolog.FatalLevel).Err(err).Msg("Failed to get first user ID")
|
gmx.Log.WithLevel(zerolog.FatalLevel).Err(err).Msg("Failed to get first user ID")
|
||||||
|
|
|
@ -103,7 +103,7 @@ func New(rawDB, cryptoDB *dbutil.Database, log zerolog.Logger, pickleKey []byte,
|
||||||
// Default settings from http.DefaultTransport
|
// Default settings from http.DefaultTransport
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
ForceAttemptHTTP2: true,
|
ForceAttemptHTTP2: true,
|
||||||
MaxIdleConns: 100,
|
MaxIdleConns: 5,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 90 * time.Second,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
|
Loading…
Add table
Reference in a new issue