Skip to content

Commit

Permalink
修改IP获取方式
Browse files Browse the repository at this point in the history
  • Loading branch information
zyh001 authored Sep 17, 2018
1 parent 07c4d96 commit dd0922c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Config_Generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
import json
import urllib2
import commands
import socket

def getip():

try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 80))
myip = s.getsockname()[0]
finally:
s.close()
return myip

myip = urllib2.urlopen('http://ipconfig.me').read()
myip = myip.strip()
return str(myip)

def open_port(port):
cmd =[ "iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT",
Expand Down

0 comments on commit dd0922c

Please sign in to comment.