mirror of https://github.com/voidlizard/hbs2
merged PR#4dMi3uox8r whitelist-config-option
This commit is contained in:
parent
5ab9b80fd3
commit
76eb115d03
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
(fixme-set "workflow" "test" "4dMi3uox8r")
|
|
@ -92,6 +92,7 @@ data PeerListenKey
|
||||||
data PeerRpcKey
|
data PeerRpcKey
|
||||||
data PeerKeyFileKey
|
data PeerKeyFileKey
|
||||||
data PeerBlackListKey
|
data PeerBlackListKey
|
||||||
|
data PeerWhiteListKey
|
||||||
data PeerStorageKey
|
data PeerStorageKey
|
||||||
data PeerAcceptAnnounceKey
|
data PeerAcceptAnnounceKey
|
||||||
data PeerTraceKey
|
data PeerTraceKey
|
||||||
|
@ -124,6 +125,9 @@ instance HasCfgKey PeerStorageKey (Maybe String) where
|
||||||
instance HasCfgKey PeerBlackListKey (Set String) where
|
instance HasCfgKey PeerBlackListKey (Set String) where
|
||||||
key = "blacklist"
|
key = "blacklist"
|
||||||
|
|
||||||
|
instance HasCfgKey PeerWhiteListKey (Set String) where
|
||||||
|
key = "whitelist"
|
||||||
|
|
||||||
instance HasCfgKey PeerAcceptAnnounceKey AcceptAnnounce where
|
instance HasCfgKey PeerAcceptAnnounceKey AcceptAnnounce where
|
||||||
key = "accept-block-announce"
|
key = "accept-block-announce"
|
||||||
|
|
||||||
|
@ -432,10 +436,12 @@ runPeer opts = Exception.handle myException $ do
|
||||||
setLogging @TRACE tracePrefix
|
setLogging @TRACE tracePrefix
|
||||||
|
|
||||||
let bls = cfgValue @PeerBlackListKey conf :: Set String
|
let bls = cfgValue @PeerBlackListKey conf :: Set String
|
||||||
|
let whs = cfgValue @PeerWhiteListKey conf :: Set String
|
||||||
let blkeys = Set.fromList
|
let toKeys xs = Set.fromList
|
||||||
$ catMaybes [ fromStringMay x | x <- Set.toList bls
|
$ catMaybes [ fromStringMay x | x <- Set.toList xs
|
||||||
] :: Set (PubKey 'Sign UDP)
|
] :: Set (PubKey 'Sign UDP)
|
||||||
|
let blkeys = toKeys bls
|
||||||
|
let wlkeys = toKeys (whs `Set.difference` bls)
|
||||||
|
|
||||||
let accptAnn = cfgValue @PeerAcceptAnnounceKey conf :: AcceptAnnounce
|
let accptAnn = cfgValue @PeerAcceptAnnounceKey conf :: AcceptAnnounce
|
||||||
|
|
||||||
|
@ -444,7 +450,9 @@ runPeer opts = Exception.handle myException $ do
|
||||||
-- FIXME: move-peerBanned-somewhere
|
-- FIXME: move-peerBanned-somewhere
|
||||||
let peerBanned p d = do
|
let peerBanned p d = do
|
||||||
let k = view peerSignKey d
|
let k = view peerSignKey d
|
||||||
pure $ k `Set.member` blkeys
|
let blacklisted = k `Set.member` blkeys
|
||||||
|
let whitelisted = Set.null wlkeys || (k `Set.member` wlkeys)
|
||||||
|
pure $ blacklisted || not whitelisted
|
||||||
|
|
||||||
let acceptAnnounce p d = do
|
let acceptAnnounce p d = do
|
||||||
case accptAnn of
|
case accptAnn of
|
||||||
|
|
Loading…
Reference in New Issue