Permalink
Browse files

generate ip subset file for sshuttle's '--exclude-from' argument

  • Loading branch information...
1 parent efc4578 commit 54a5bdbc58fcc0a3fc6a8449e3fb50a677b2f0b7 @tianyicui committed Apr 9, 2013
Showing with 8 additions and 0 deletions.
  1. +8 −0 chnroutes.py
View
@@ -184,6 +184,12 @@ def generate_android(metric):
print "Old school way to call up/down script from openvpn client. " \
"use the regular openvpn 2.1 method to add routes if it's possible"
+def generate_sshuttle():
+ results = fetch_ip_data()
+ file=open('chn-subnet','w')
+ for ip,_,mask in results:
+ file.write('%s/%d\n'%(ip,mask))
+ file.close()
def fetch_ip_data():
#fetch data from apnic
@@ -249,6 +255,8 @@ def fetch_ip_data():
generate_win(args.metric)
elif args.platform.lower() == 'android':
generate_android(args.metric)
+ elif args.platform.lower() == 'sshuttle':
+ generate_sshuttle()
else:
print>>sys.stderr, "Platform %s is not supported."%args.platform
exit(1)

0 comments on commit 54a5bdb

Please sign in to comment.