Skip to content

Commit 8770bf0

Browse files
committed
fix: [IPAddress] catch empty config error
1 parent 4d8db3f commit 8770bf0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bin/IPAddress.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
This module is consuming the global channel.
88
9-
It first performs a regex to find IP addresses and then matches those IPs to
9+
It first performs a regex to find IP addresses and then matches those IPs to
1010
some configured ip ranges.
1111
1212
The list of IP ranges are expected to be in CIDR format (e.g. 192.168.0.0/16)
@@ -16,6 +16,7 @@
1616

1717
import time
1818
import re
19+
import sys
1920
from pubsublogger import publisher
2021
from packages import Paste
2122
from Helper import Process
@@ -60,8 +61,12 @@ def search_ip(message):
6061
p = Process(config_section)
6162

6263
ip_networks = []
63-
for network in p.config.get("IP", "networks").split(","):
64-
ip_networks.append(IPv4Network(network))
64+
try:
65+
for network in p.config.get("IP", "networks").split(","):
66+
ip_networks.append(IPv4Network(network))
67+
except:
68+
print('Please provide a list of valid IP addresses')
69+
sys.exit(0)
6570

6671

6772
# Sent to the logging a description of the module
@@ -78,4 +83,3 @@ def search_ip(message):
7883

7984
# Do something with the message from the queue
8085
search_ip(message)
81-

0 commit comments

Comments
 (0)