Skip to content
Snippets Groups Projects
Commit 4787c5f0 authored by Manuela Kuhn's avatar Manuela Kuhn
Browse files

Enable multple host in whitelist of DataReceiver

parent 969042c0
No related branches found
No related tags found
No related merge requests found
......@@ -264,9 +264,24 @@ class dataTransfer():
# Receive data only from whitelisted nodes
if whitelist:
self.auth = ThreadAuthenticator(self.context)
self.auth.start()
self.auth.allow(whitelist)
if type(whitelist) == list:
self.auth = ThreadAuthenticator(self.context)
self.auth.start()
for host in whitelist:
try:
if host == "localhost":
ip = [socket.gethostbyname(host)]
else:
hostname, tmp, ip = socket.gethostbyaddr(host)
self.log.debug("Allowing host " + host + " (" + str(ip[0]) + ")")
self.auth.allow(ip[0])
except:
self.log.error("Error was: ", exc_info=True)
raise AuthenticationFailed("Could not get IP of host " + host)
else:
raise FormatError("Whitelist has to be a list of IPs")
socketIdToConnect = self.streamStarted or self.queryNextStarted
......
......@@ -17,8 +17,7 @@ logfileSize = 104857600 ; #100 MB
#
# List of hosts allowed to receive data from
whitelist = "131.169.185.121"
#whitelist = "localhost" "zitpcx19282.desy.de" "zitpcx22614" "lsdma-lab04"
whitelist = ["localhost", "zitpcx19282.desy.de", "zitpcx22614", "lsdma-lab04"]
# Where incoming data will be stored to
targetDir = /space/projects/zeromq-data-transfer/data/zmq_target
......
......@@ -6,6 +6,7 @@ import argparse
import logging
import os
import ConfigParser
import json
BASE_PATH = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.realpath ( __file__ ) )))
......@@ -37,7 +38,7 @@ def argumentParsing():
logfileName = config.get('asection', 'logfileName')
logfileSize = config.get('asection', 'logfileSize')
whitelist = config.get('asection', 'whitelist')
whitelist = json.loads(config.get('asection', 'whitelist'))
targetDir = config.get('asection', 'targetDir')
......@@ -115,6 +116,8 @@ class DataReceiver:
self.whitelist = arguments.whitelist
self.log.info("Configured whitelist: " + str(self.whitelist))
self.targetDir = os.path.normpath(arguments.targetDir)
self.dataIp = arguments.dataStreamIp
self.dataPort = arguments.dataStreamPort
......
......@@ -13,10 +13,11 @@ socket.zap_domain = b'global'
socket.bind("tcp://" + ip + ":%s" % port)
auth = ThreadAuthenticator(context)
#whitelist = "131.169.185.121"
whitelist = "131.169.185.34"
auth.start()
auth.allow(whitelist)
whitelist = ["131.169.185.34", "131.169.185.121"]
for host in whitelist:
auth.allow(host)
while True:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment