Skip to content

Commit

Permalink
Include user's actual IP address in the "not authorized" error.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarks-net committed Jan 17, 2010
1 parent 47c6b48 commit 0e86ca8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dtella/common/core.py
Expand Up @@ -1637,6 +1637,10 @@ def receivedInitResponse(self, src_ipp, myip, code, pc, nd=None):
ad = Ad().setRawIPPort(ipp)
self.main.state.refreshPeer(ad, age)

# Add my own IP to the list, even if it's banned.
src_ad = Ad().setRawIPPort(src_ipp)
self.main.addMyIPReport(src_ad, my_ad)

if code != CODE_IP_OK:
if not p.bad_code:
p.bad_code = True
Expand All @@ -1651,10 +1655,6 @@ def receivedInitResponse(self, src_ipp, myip, code, pc, nd=None):
self.checkStatus()
return

# Add my own IP to the list
src_ad = Ad().setRawIPPort(src_ipp)
self.main.addMyIPReport(src_ad, my_ad)

# Add the node who sent this packet to the cache
self.main.state.refreshPeer(src_ad, 0)

Expand Down Expand Up @@ -4175,8 +4175,14 @@ def cb(result):
self.shutdown(reconnect='max')

elif result == 'foreign_ip':
try:
my_ip = Ad().setRawIPPort(self.selectMyIP()).getTextIP()
except ValueError:
my_ip = "?"

self.showLoginStatus(
"Your IP address is not authorized to use this network.")
"Your IP address (%s) is not authorized to use "
"this network." % my_ip)
self.shutdown(reconnect='max')

elif result == 'dead_port':
Expand Down

0 comments on commit 0e86ca8

Please sign in to comment.