mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 12:54:01 +03:00
Remove timeattack module
This commit is contained in:
+5
-18
@@ -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
|
||||
|
||||
+18
-24
@@ -10,18 +10,15 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Debug bool `json:"debug"`
|
||||
Secret mtglib.Secret `json:"secret"`
|
||||
BindTo TypeHostPort `json:"bind-to"`
|
||||
TCPBuffer TypeBytes `json:"tcp-buffer"`
|
||||
PreferIP TypePreferIP `json:"prefer-ip"`
|
||||
DomainFrontingPort TypePort `json:"domain-fronting-port"`
|
||||
Concurrency uint `json:"concurrency"`
|
||||
Defense struct {
|
||||
Time struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
AllowSkewness TypeDuration `json:"allow-skewness"`
|
||||
} `json:"time"`
|
||||
Debug bool `json:"debug"`
|
||||
Secret mtglib.Secret `json:"secret"`
|
||||
BindTo TypeHostPort `json:"bind-to"`
|
||||
TCPBuffer TypeBytes `json:"tcp-buffer"`
|
||||
PreferIP TypePreferIP `json:"prefer-ip"`
|
||||
DomainFrontingPort TypePort `json:"domain-fronting-port"`
|
||||
TolerateTimeSkewness TypeDuration `json:"tolerate-time-skewness"`
|
||||
Concurrency uint `json:"concurrency"`
|
||||
Defense struct {
|
||||
AntiReplay struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
MaxSize TypeBytes `json:"max-size"`
|
||||
@@ -85,18 +82,15 @@ func (c *Config) String() string {
|
||||
}
|
||||
|
||||
type configRaw struct {
|
||||
Debug bool `toml:"debug" json:"debug,omitempty"`
|
||||
Secret string `toml:"secret" json:"secret"`
|
||||
BindTo string `toml:"bind-to" json:"bind-to"`
|
||||
TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"`
|
||||
PreferIP string `toml:"prefer-ip" json:"prefer-ip,omitempty"`
|
||||
DomainFrontingPort uint `toml:"domain-fronting-port" json:"domain-fronting-port,omitempty"`
|
||||
Concurrency uint `toml:"concurrency" json:"concurrency,omitempty"`
|
||||
Defense struct {
|
||||
Time struct {
|
||||
Enabled bool `toml:"enabled" json:"enabled,omitempty"`
|
||||
AllowSkewness string `toml:"allow-skewness" json:"allow-skewness,omitempty"`
|
||||
} `toml:"time" json:"time,omitempty"`
|
||||
Debug bool `toml:"debug" json:"debug,omitempty"`
|
||||
Secret string `toml:"secret" json:"secret"`
|
||||
BindTo string `toml:"bind-to" json:"bind-to"`
|
||||
TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"`
|
||||
PreferIP string `toml:"prefer-ip" json:"prefer-ip,omitempty"`
|
||||
DomainFrontingPort uint `toml:"domain-fronting-port" json:"domain-fronting-port,omitempty"`
|
||||
TolerateTimeSkewness string `toml:"tolerate-time-skewness" json:"tolerate-time-skewness,omitempty"`
|
||||
Concurrency uint `toml:"concurrency" json:"concurrency,omitempty"`
|
||||
Defense struct {
|
||||
AntiReplay struct {
|
||||
Enabled bool `toml:"enabled" json:"enabled,omitempty"`
|
||||
MaxSize string `toml:"max-size" json:"max-size,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user