tshow hostnames - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 52d8ed16dea1336c3d7b8590408e7b377a8dfe78 DIR parent f828d43c00960e4e329aea1064526dbb480cf71c HTML Author: ThomasV <thomasv@gitorious> Date: Wed, 23 Nov 2011 13:16:36 +0300 show hostnames Diffstat: M server/electrum.php | 11 ++++++----- M server/server.py | 15 +++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) --- DIR diff --git a/server/electrum.php b/server/electrum.php t@@ -21,7 +21,7 @@ return $buf; } - $pass=''; + $pass = ''; $query = $_POST['q']; if( !$query ) { t@@ -31,14 +31,15 @@ echo "Server status:<br/>"; echo "Number of blocks: ". do_query( "('b','')" ) ."<br/>"; - echo "Current load: ". do_query( "('load',$pass)" ) ."<br/><br/>"; + echo "Current load: ". do_query( "('load','$pass')" ) ."<br/><br/>"; echo "List of active servers:<br/>\n"; $str = do_query( "('peers','')" ); - preg_match_all("/(\d+\.\d+\.\d+\.\d+)/",$str,$matches,PREG_SET_ORDER); +// preg_match_all("/\('(.*?)', '(\d+\.\d+\.\d+\.\d+)'\)/",$str,$matches,PREG_SET_ORDER); + preg_match_all("/\('(.*?)', '(.*?)'\)/", $str, $matches, PREG_SET_ORDER); echo "<ul>"; - foreach( $matches as $ip){ - echo "<li><a href=\"http://" . $ip[0] . "/electrum.php\">" . $ip[0] . "</a></li>"; + foreach( $matches as $m){ + echo "<li><a href=\"http://" . $m[2] . "/electrum.php\">" . $m[2]."</a> <small>[".$m[1]."]</small></li>"; } echo "</ul>"; DIR diff --git a/server/server.py b/server/server.py t@@ -22,7 +22,7 @@ Todo: """ -import time, socket, operator, thread, ast, sys +import time, socket, operator, thread, ast, sys,re import psycopg2, binascii import bitcoinrpc t@@ -435,8 +435,8 @@ def irc_thread(): try: s = socket.socket() s.connect(('irc.freenode.net', 6667)) - s.send('USER '+NICK+' '+NICK+' bla :'+NICK+'\n') - s.send('NICK '+NICK+'\n') + s.send('USER '+HOST+' '+NICK+' bla :'+NICK+'\n') + s.send('NICK '+NICK+'\n') s.send('JOIN #electrum\n') t = 0 while not stopping: t@@ -456,9 +456,12 @@ def irc_thread(): s.send('USERHOST %s\n'%item) elif '302' in line: # answer to /userhost k = line.index('302') - name = line[k+2].split('=')[0] - host = line[k+2].split('@')[1] - peer_list[name] = host + m = re.match( "^:(.*?)=\+~(.*?)@(.*?)$", line[k+2] ) + if m: + name = m.group(1) + host = m.group(2) + ip = m.group(3) + peer_list[name] = (ip,host) elif time.time() - t > 5*60: s.send('NAMES #electrum\n') t = time.time()