diff --git a/sys/config.py b/sys/config.py index 591cfba..8d75934 100644 --- a/sys/config.py +++ b/sys/config.py @@ -33,9 +33,9 @@ try: except: PIDFILE = 'pid' try: - IP = cp.get("General","IP") + LOCAL_IP = cp.get("General","LOCAL_IP") except: - IP = '127.0.0.1' + LOCAL_IP = '127.0.0.1' try: diff --git a/sys/util.py b/sys/util.py index afc741d..2fe0018 100644 --- a/sys/util.py +++ b/sys/util.py @@ -3,6 +3,7 @@ import select import socket import threading import random +import config from Queue import Queue, Empty MAGIC_PACKET = "" @@ -58,12 +59,17 @@ def get_local_ip(): s.bind(('', 8888)) s.setblocking(0) while True: - result = select.select([s],[],[]) + result = select.select([s],[],[],10) + if len(result[0])==0 : + print "Warning using default local ip" + queue.put([config.LOCAL_IP]) + break + msg, address = result[0][0].recvfrom(1024) msg = unicode(msg) if msg == MAGIC_PACKET: + queue.put(address) break - queue.put(address) queue = Queue() thread = threading.Thread(target=udp_listening_server)