Skip to content

Commit

Permalink
[Fixed] Getting Public IP, added fail-over
Browse files Browse the repository at this point in the history
  • Loading branch information
ruped24 authored May 30, 2020
1 parent ba6082e commit c506b34
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion toriptables2.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def restart_tor():
except URLError:
sleep(5)
print(" [\033[93m?\033[0m] Still waiting for IP address...")
except ValueError:
break
print
if not my_public_ip:
my_public_ip = getoutput('wget -qO - v4.ifconfig.co')
my_public_ip = getoutput('wget -qO - ifconfig.me')
if not my_public_ip:
exit(" \033[91m[!]\033[0m Can't get public ip address!")
print(" {0}".format("[\033[92m+\033[0m] Your IP is \033[92m%s\033[0m" % my_public_ip))
Expand Down

1 comment on commit c506b34

@ruped24
Copy link
Owner Author

@ruped24 ruped24 commented on c506b34 May 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Solved]
Added: L74 catches ValueError from json.load()
Added: L75 breaks out of the loop on caught L74 ValueError exception.
Changed: L78 fetch my_public_ip via. wget IP endpoint.

Please sign in to comment.