mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-03 11:53:41 +02:00
implement whitelist option in blacklist
This commit is contained in:
parent
4f27307c70
commit
20168a9329
6 changed files with 18 additions and 7 deletions
|
|
@ -238,6 +238,8 @@ func GetConfig(flags *pflag.FlagSet) (*config.Config, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.Ship.Blacklist.SetWhitelist(cfg.Ship.BlacklistIsWhitelist)
|
||||||
|
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ ship:
|
||||||
# blacklist all action from a contract
|
# blacklist all action from a contract
|
||||||
# evilcontract: ["*"]
|
# evilcontract: ["*"]
|
||||||
|
|
||||||
|
# blacklist_is_whitelist: true
|
||||||
|
|
||||||
# Telegram notifications
|
# Telegram notifications
|
||||||
#telegram:
|
#telegram:
|
||||||
# id: "123456789:GPdmGPBWvpgHPxlergJLavus-PoAURTjMWP"
|
# id: "123456789:GPdmGPBWvpgHPxlergJLavus-PoAURTjMWP"
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ func NewBuilder() *Builder {
|
||||||
"ship.max_messages_in_flight": "max-msg-in-flight",
|
"ship.max_messages_in_flight": "max-msg-in-flight",
|
||||||
"ship.chain": "chain",
|
"ship.chain": "chain",
|
||||||
"ship.blacklist": "blacklist",
|
"ship.blacklist": "blacklist",
|
||||||
|
"ship.blacklist_is_whitelist": "blacklist-is-whitelist",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ func TestBuilder(t *testing.T) {
|
||||||
"eosio": {"noop"},
|
"eosio": {"noop"},
|
||||||
"contract": {"skip1", "skip2"},
|
"contract": {"skip1", "skip2"},
|
||||||
}),
|
}),
|
||||||
|
BlacklistIsWhitelist: true,
|
||||||
},
|
},
|
||||||
Telegram: TelegramConfig{
|
Telegram: TelegramConfig{
|
||||||
Id: "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw",
|
Id: "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw",
|
||||||
|
|
@ -68,6 +69,7 @@ ship:
|
||||||
contract:
|
contract:
|
||||||
- skip1
|
- skip1
|
||||||
- skip2
|
- skip2
|
||||||
|
blacklist_is_whitelist: true
|
||||||
telegram:
|
telegram:
|
||||||
id: "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw"
|
id: "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw"
|
||||||
channel: -123456789
|
channel: -123456789
|
||||||
|
|
@ -186,6 +188,7 @@ func TestBuilder_Flags(t *testing.T) {
|
||||||
require.NoError(t, flags.Set("max-msg-in-flight", "98"))
|
require.NoError(t, flags.Set("max-msg-in-flight", "98"))
|
||||||
require.NoError(t, flags.Set("chain", "wax"))
|
require.NoError(t, flags.Set("chain", "wax"))
|
||||||
require.NoError(t, flags.Set("blacklist", "contract:action1,contract:action2,contract2:action1"))
|
require.NoError(t, flags.Set("blacklist", "contract:action1,contract:action2,contract2:action1"))
|
||||||
|
require.NoError(t, flags.Set("blacklist-is-whitelist", "true"))
|
||||||
|
|
||||||
cfg, err := NewBuilder().
|
cfg, err := NewBuilder().
|
||||||
SetSource(bytes.NewReader([]byte(``))).
|
SetSource(bytes.NewReader([]byte(``))).
|
||||||
|
|
@ -211,6 +214,7 @@ func TestBuilder_Flags(t *testing.T) {
|
||||||
"contract": {"action1", "action2"},
|
"contract": {"action1", "action2"},
|
||||||
"contract2": {"action1"},
|
"contract2": {"action1"},
|
||||||
}),
|
}),
|
||||||
|
BlacklistIsWhitelist: true,
|
||||||
},
|
},
|
||||||
Telegram: TelegramConfig{
|
Telegram: TelegramConfig{
|
||||||
Id: "72983126312982618",
|
Id: "72983126312982618",
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ func GetFlags() *pflag.FlagSet {
|
||||||
flags.String("chain", "", "ChainID used in channel namespace, can be any string (default from api)")
|
flags.String("chain", "", "ChainID used in channel namespace, can be any string (default from api)")
|
||||||
|
|
||||||
flags.StringSlice("blacklist", []string{}, "Define a list of 'contract:action' pairs that will be blacklisted (thalos will not process those actions)")
|
flags.StringSlice("blacklist", []string{}, "Define a list of 'contract:action' pairs that will be blacklisted (thalos will not process those actions)")
|
||||||
|
flags.Bool("blacklist-is-whitelist", false, "Thalos will treat the blacklist as a whitelist")
|
||||||
|
|
||||||
return &flags
|
return &flags
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,14 @@ type TelegramConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShipConfig struct {
|
type ShipConfig struct {
|
||||||
Url string `yaml:"url" mapstructure:"url"`
|
Url string `yaml:"url" mapstructure:"url"`
|
||||||
IrreversibleOnly bool `yaml:"irreversible_only" mapstructure:"irreversible_only"`
|
IrreversibleOnly bool `yaml:"irreversible_only" mapstructure:"irreversible_only"`
|
||||||
MaxMessagesInFlight uint32 `yaml:"max_messages_in_flight" mapstructure:"max_messages_in_flight"`
|
MaxMessagesInFlight uint32 `yaml:"max_messages_in_flight" mapstructure:"max_messages_in_flight"`
|
||||||
StartBlockNum uint32 `yaml:"start_block_num" mapstructure:"start_block_num"`
|
StartBlockNum uint32 `yaml:"start_block_num" mapstructure:"start_block_num"`
|
||||||
EndBlockNum uint32 `yaml:"end_block_num" mapstructure:"end_block_num"`
|
EndBlockNum uint32 `yaml:"end_block_num" mapstructure:"end_block_num"`
|
||||||
Chain string `yaml:"chain" mapstructure:"chain"`
|
Chain string `yaml:"chain" mapstructure:"chain"`
|
||||||
Blacklist types.Blacklist `yaml:"blacklist" mapstructure:"blacklist"`
|
Blacklist types.Blacklist `yaml:"blacklist" mapstructure:"blacklist"`
|
||||||
|
BlacklistIsWhitelist bool `yaml:"blacklist_is_whitelist" mapstructure:"blacklist_is_whitelist"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue