mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-16 04:24:56 +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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ ship:
|
|||
# blacklist all action from a contract
|
||||
# evilcontract: ["*"]
|
||||
|
||||
# blacklist_is_whitelist: true
|
||||
|
||||
# Telegram notifications
|
||||
#telegram:
|
||||
# id: "123456789:GPdmGPBWvpgHPxlergJLavus-PoAURTjMWP"
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ func NewBuilder() *Builder {
|
|||
"ship.max_messages_in_flight": "max-msg-in-flight",
|
||||
"ship.chain": "chain",
|
||||
"ship.blacklist": "blacklist",
|
||||
"ship.blacklist_is_whitelist": "blacklist-is-whitelist",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ func TestBuilder(t *testing.T) {
|
|||
"eosio": {"noop"},
|
||||
"contract": {"skip1", "skip2"},
|
||||
}),
|
||||
BlacklistIsWhitelist: true,
|
||||
},
|
||||
Telegram: TelegramConfig{
|
||||
Id: "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw",
|
||||
|
|
@ -68,6 +69,7 @@ ship:
|
|||
contract:
|
||||
- skip1
|
||||
- skip2
|
||||
blacklist_is_whitelist: true
|
||||
telegram:
|
||||
id: "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw"
|
||||
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("chain", "wax"))
|
||||
require.NoError(t, flags.Set("blacklist", "contract:action1,contract:action2,contract2:action1"))
|
||||
require.NoError(t, flags.Set("blacklist-is-whitelist", "true"))
|
||||
|
||||
cfg, err := NewBuilder().
|
||||
SetSource(bytes.NewReader([]byte(``))).
|
||||
|
|
@ -211,6 +214,7 @@ func TestBuilder_Flags(t *testing.T) {
|
|||
"contract": {"action1", "action2"},
|
||||
"contract2": {"action1"},
|
||||
}),
|
||||
BlacklistIsWhitelist: true,
|
||||
},
|
||||
Telegram: TelegramConfig{
|
||||
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.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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ type TelegramConfig struct {
|
|||
}
|
||||
|
||||
type ShipConfig struct {
|
||||
Url string `yaml:"url" mapstructure:"url"`
|
||||
IrreversibleOnly bool `yaml:"irreversible_only" mapstructure:"irreversible_only"`
|
||||
MaxMessagesInFlight uint32 `yaml:"max_messages_in_flight" mapstructure:"max_messages_in_flight"`
|
||||
StartBlockNum uint32 `yaml:"start_block_num" mapstructure:"start_block_num"`
|
||||
EndBlockNum uint32 `yaml:"end_block_num" mapstructure:"end_block_num"`
|
||||
Chain string `yaml:"chain" mapstructure:"chain"`
|
||||
Blacklist types.Blacklist `yaml:"blacklist" mapstructure:"blacklist"`
|
||||
Url string `yaml:"url" mapstructure:"url"`
|
||||
IrreversibleOnly bool `yaml:"irreversible_only" mapstructure:"irreversible_only"`
|
||||
MaxMessagesInFlight uint32 `yaml:"max_messages_in_flight" mapstructure:"max_messages_in_flight"`
|
||||
StartBlockNum uint32 `yaml:"start_block_num" mapstructure:"start_block_num"`
|
||||
EndBlockNum uint32 `yaml:"end_block_num" mapstructure:"end_block_num"`
|
||||
Chain string `yaml:"chain" mapstructure:"chain"`
|
||||
Blacklist types.Blacklist `yaml:"blacklist" mapstructure:"blacklist"`
|
||||
BlacklistIsWhitelist bool `yaml:"blacklist_is_whitelist" mapstructure:"blacklist_is_whitelist"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue