mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-23 06:37:15 +00:00
fix: [IPAddress] catch empty config error
This commit is contained in:
parent
4d8db3fcc4
commit
8770bf05d7
1 changed files with 8 additions and 4 deletions
|
@ -6,7 +6,7 @@ The IP Module
|
||||||
|
|
||||||
This module is consuming the global channel.
|
This module is consuming the global channel.
|
||||||
|
|
||||||
It first performs a regex to find IP addresses and then matches those IPs to
|
It first performs a regex to find IP addresses and then matches those IPs to
|
||||||
some configured ip ranges.
|
some configured ip ranges.
|
||||||
|
|
||||||
The list of IP ranges are expected to be in CIDR format (e.g. 192.168.0.0/16)
|
The list of IP ranges are expected to be in CIDR format (e.g. 192.168.0.0/16)
|
||||||
|
@ -16,6 +16,7 @@ and should be defined in the config.cfg file, under the [IP] section
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from pubsublogger import publisher
|
from pubsublogger import publisher
|
||||||
from packages import Paste
|
from packages import Paste
|
||||||
from Helper import Process
|
from Helper import Process
|
||||||
|
@ -60,8 +61,12 @@ if __name__ == '__main__':
|
||||||
p = Process(config_section)
|
p = Process(config_section)
|
||||||
|
|
||||||
ip_networks = []
|
ip_networks = []
|
||||||
for network in p.config.get("IP", "networks").split(","):
|
try:
|
||||||
ip_networks.append(IPv4Network(network))
|
for network in p.config.get("IP", "networks").split(","):
|
||||||
|
ip_networks.append(IPv4Network(network))
|
||||||
|
except:
|
||||||
|
print('Please provide a list of valid IP addresses')
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
# Sent to the logging a description of the module
|
# Sent to the logging a description of the module
|
||||||
|
@ -78,4 +83,3 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Do something with the message from the queue
|
# Do something with the message from the queue
|
||||||
search_ip(message)
|
search_ip(message)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue