Remove timeattack module

This commit is contained in:
9seconds
2021-04-08 14:58:14 +03:00
parent 0652f322fa
commit e2073f0585
13 changed files with 108 additions and 247 deletions
+5 -18
View File
@@ -12,7 +12,6 @@ import (
"github.com/9seconds/mtg/v2/logger"
"github.com/9seconds/mtg/v2/mtglib"
"github.com/9seconds/mtg/v2/stats"
"github.com/9seconds/mtg/v2/timeattack"
"github.com/rs/zerolog"
)
@@ -41,12 +40,11 @@ func (c *Proxy) Execute() error {
ctx := utils.RootContext()
opts := mtglib.ProxyOpts{
Logger: logger.NewZeroLogger(zerolog.New(os.Stdout).With().Timestamp().Logger()),
Network: c.Network,
AntiReplayCache: antireplay.NewNoop(),
IPBlocklist: ipblocklist.NewNoop(),
TimeAttackDetector: timeattack.NewNoop(),
EventStream: events.NewNoopStream(),
Logger: logger.NewZeroLogger(zerolog.New(os.Stdout).With().Timestamp().Logger()),
Network: c.Network,
AntiReplayCache: antireplay.NewNoop(),
IPBlocklist: ipblocklist.NewNoop(),
EventStream: events.NewNoopStream(),
Secret: c.Config.Secret,
BufferSize: c.Config.TCPBuffer.Value(mtglib.DefaultBufferSize),
@@ -58,7 +56,6 @@ func (c *Proxy) Execute() error {
opts.Logger.BindStr("configuration", c.Config.String()).Debug("configuration")
c.setupAntiReplayCache(&opts)
c.setupTimeAttackDetector(&opts)
if err := c.setupIPBlocklist(&opts); err != nil {
return fmt.Errorf("cannot setup ipblocklist: %w", err)
@@ -98,16 +95,6 @@ func (c *Proxy) setupAntiReplayCache(opts *mtglib.ProxyOpts) {
)
}
func (c *Proxy) setupTimeAttackDetector(opts *mtglib.ProxyOpts) {
if !c.Config.Defense.Time.Enabled {
return
}
opts.TimeAttackDetector = timeattack.NewDetector(
c.Config.Defense.Time.AllowSkewness.Value(timeattack.DefaultDuration),
)
}
func (c *Proxy) setupIPBlocklist(opts *mtglib.ProxyOpts) error {
if !c.Config.Defense.Blocklist.Enabled {
return nil