Browse files

Hack for socialvpn support by default, also picks default interface f…

…or multicast
  • Loading branch information...
1 parent 9ec96e1 commit d826a972c5d7dd4a00d60169d9ed35c5e73159e9 @pstjuste committed Jun 25, 2012
Showing with 31 additions and 5 deletions.
  1. +2 −0 TODO
  2. +15 −2 src/litter.py
  3. +14 −3 src/litterrouter.py
View
2 TODO
@@ -0,0 +1,2 @@
+Need to fix time issue since computer time is off
+
View
17 src/litter.py
@@ -56,9 +56,20 @@ def init_mcast(intfs=[], port=PORT, addr=MCAST_ADDR):
s.bind(('', port))
- for intf in intfs:
+ if len(intfs) > 0:
+ for intf in intfs:
+ s.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP,
+ socket.inet_aton(addr) + socket.inet_aton(intf))
+ else:
+ # let the OS choose default interface for mcast
s.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP,
- socket.inet_aton(addr) + socket.inet_aton(intf))
+ socket.inet_aton(addr) + socket.inet_aton('0.0.0.0'))
+ # hack for socialvpn
+ try:
+ s.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP,
+ socket.inet_aton(addr) + socket.inet_aton('172.31.0.2'))
+ except Exception as ex:
+ logging.exception(ex)
return s
@@ -296,6 +307,8 @@ def main():
usage()
sys.exit()
+ name = raw_input("Please enter a user name: ")
+
queue = Queue.Queue(100)
mserver = MulticastServer(queue, devs)
View
17 src/litterrouter.py
@@ -45,10 +45,21 @@ def send(self, data, dest=None):
if dest == None and self.__dest == None and self.__intfs != None:
dest = (MCAST_ADDR, PORT)
- for intf in self.__intfs:
- self.__sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF,
- socket.inet_aton(intf))
+ if len(self.__intfs) > 0:
+ for intf in self.__intfs:
+ self.__sock.setsockopt(socket.SOL_IP,
+ socket.IP_MULTICAST_IF, socket.inet_aton(intf))
+ self.__sock.sendto(data, dest)
+ else:
+ # let OS determine default interface
self.__sock.sendto(data, dest)
+ # hack for socialvpn
+ try:
+ self.__sock.setsockopt(socket.SOL_IP,
+ socket.IP_MULTICAST_IF, socket.inet_aton('172.31.0.2'))
+ self.__sock.sendto(data, dest)
+ except Exception as ex:
+ logging.exception(ex)
elif dest == None and self.__dest != None:
dest = self.__dest

0 comments on commit d826a97

Please sign in to comment.