Skip to content

Commit

Permalink
fix: [IPAddress] catch empty config error
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Feb 3, 2020
1 parent 4d8db3f commit 8770bf0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bin/IPAddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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.
The list of IP ranges are expected to be in CIDR format (e.g. 192.168.0.0/16)
Expand All @@ -16,6 +16,7 @@

import time
import re
import sys
from pubsublogger import publisher
from packages import Paste
from Helper import Process
Expand Down Expand Up @@ -60,8 +61,12 @@ def search_ip(message):
p = Process(config_section)

ip_networks = []
for network in p.config.get("IP", "networks").split(","):
ip_networks.append(IPv4Network(network))
try:
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
Expand All @@ -78,4 +83,3 @@ def search_ip(message):

# Do something with the message from the queue
search_ip(message)

0 comments on commit 8770bf0

Please sign in to comment.