#!/usr/bin/env python
import os
import re

def xor(a,b):
    return (not b and a) or (not a and b) or False

ipre = re.compile('^IP')
masterre = re.compile('master_ip')
ipnumber = re.compile('([0-9]{1,3}(\.[0-9]{1,3}){3})')

for file in os.listdir('.'):
    if file[0:5] == "proxy" or file[0:5] == "CNode":
        conf = open( file + '/wleiden.conf', 'r')
        for line in conf.readlines():
            a =  ipre.search(line)
            b =  masterre.search(line)
            if (xor(a,b)):
                result = ipnumber.search(line).groups()[0]
                print '%s|%s' % ( result,file)
        conf.close()

