mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 11:44:02 +03:00
Add support of proxy protocol
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/9seconds/mtg/v2/antireplay"
|
||||
"github.com/9seconds/mtg/v2/events"
|
||||
"github.com/9seconds/mtg/v2/internal/config"
|
||||
"github.com/9seconds/mtg/v2/internal/proxyprotocol"
|
||||
"github.com/9seconds/mtg/v2/internal/utils"
|
||||
"github.com/9seconds/mtg/v2/ipblocklist"
|
||||
"github.com/9seconds/mtg/v2/ipblocklist/files"
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
"github.com/9seconds/mtg/v2/mtglib"
|
||||
"github.com/9seconds/mtg/v2/network"
|
||||
"github.com/9seconds/mtg/v2/stats"
|
||||
"github.com/pires/go-proxyproto"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/yl2chen/cidranger"
|
||||
)
|
||||
@@ -275,6 +277,14 @@ func runProxy(conf *config.Config, version string) error { //nolint: funlen
|
||||
return fmt.Errorf("cannot start proxy: %w", err)
|
||||
}
|
||||
|
||||
if conf.ProxyProtocolListener.Get(false) {
|
||||
listener = &proxyprotocol.ListenerAdapter{
|
||||
Listener: proxyproto.Listener{
|
||||
Listener: listener,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
ctx := utils.RootContext()
|
||||
|
||||
go proxy.Serve(listener) //nolint: errcheck
|
||||
|
||||
Reference in New Issue
Block a user