30 lines
878 B
SQL
30 lines
878 B
SQL
DROP DICTIONARY IF EXISTS mabase_prod.dict_iplocate_asn;
|
|
|
|
CREATE DICTIONARY IF NOT EXISTS mabase_prod.dict_iplocate_asn
|
|
(
|
|
network String,
|
|
asn UInt32,
|
|
country_code String,
|
|
name String,
|
|
org String,
|
|
domain String
|
|
)
|
|
PRIMARY KEY network
|
|
SOURCE(FILE(path '/var/lib/clickhouse/user_files/iplocate-ip-to-asn.csv' format 'CSVWithNames'))
|
|
LAYOUT(IP_TRIE())
|
|
LIFETIME(MIN 3600 MAX 7200);
|
|
|
|
|
|
|
|
-- Suppression si existe pour reconfiguration
|
|
DROP TABLE IF EXISTS mabase_prod.ref_bot_networks;
|
|
|
|
-- Table optimisée pour le filtrage binaire de CIDR
|
|
CREATE TABLE mabase_prod.ref_bot_networks (
|
|
network IPv6CIDR, -- Gère nativement '1.2.3.0/24' et '2001:db8::/32'
|
|
bot_name LowCardinality(String),
|
|
is_legitimate UInt8, -- 1 = Whitelist, 0 = Blacklist
|
|
last_update DateTime
|
|
) ENGINE = ReplacingMergeTree(last_update)
|
|
ORDER BY (network, bot_name)
|