|
|
@ -199,15 +199,15 @@ class mmPlayer( object ): |
|
|
|
is_player = True; |
|
|
|
|
|
|
|
def getIpAsString( self ): |
|
|
|
""" Get the client's IPv6 address, in a pretty format. """ |
|
|
|
""" Get the client's IPv4 or IPv6 address, in a pretty format. """ |
|
|
|
ip = self.player_obj.address; |
|
|
|
if max( ip[:10] ) == 0 and ip[10:12] == (255, 255): |
|
|
|
return "%d.%d.%d.%d" % tuple( ip[12:] ); |
|
|
|
# colon-separated string: |
|
|
|
ipstr = ':'.join([ ("%02x%02x" % (int(ip[idx]), int(ip[idx+1]))) |
|
|
|
ipstr = ':'.join([ ("%x" % ((int(ip[idx])<<8) | int(ip[idx+1]))) |
|
|
|
for idx in range(0, len(ip), 2) ]); |
|
|
|
# 0000:0000:0000 -> :: |
|
|
|
return re.sub( "((^|:)(0000:)+)", '::', ipstr ); |
|
|
|
# 0:0:0 -> :: |
|
|
|
return re.sub( "((^|:)(0:)+)", '::', ipstr, 1 ); |
|
|
|
|
|
|
|
ipaddress = property( getIpAsString ); |
|
|
|
|
|
|
|