Commits

Ivan Vučica committed 4cdf5f2 Merge

Merge

Comments (0)

Files changed (1)

 import xmpp, xmpp.protocol
 import os, select
 import sys
+import os.path
 
 import base64
 
 						break
 				return	
 
+def onUp():
+	if os.path.isfile("on-up.sh"):
+		os.system("bash ./on-up.sh")
+
+
+def onDown():
+	if os.path.isfile("on-down.sh"):
+		os.system("bash ./on-down.sh")
+
 def setupTUNTAP():
 	tuntapDevice = "tap2"
 	if len(sys.argv) >= 2:
 
 	os.system("ifconfig " + tuntapDevice + " inet " + ipAddress);
 
+	onUp()
+
 	return (tuntapFD, tuntapDevice, ipAddress)
 
 def setupXMPP():
 				if ioe.args[0] in (errno.EAGAIN, errno.EINTR):
 					continue
 				else:
+					print "tun/tap device went down"
+					onDown()
+					
 					raise Exception("tun/tap device went down")
 
 		else:
+			onDown()
 			raise Exception("Unknown socket type: %s" % repr(socketlist[each]))
 
 
-
 def main():
 	global tuntapFD, tuntapDevice, ipAddress, jid, client
 
 		try: mainLoopStep(socketlist)
 		except KeyboardInterrupt:
 			# finish whatever needed
+			onDown()
 			break