From dbfa51628178a6f1064f28d8a5aa8e12d45d7ac9 Mon Sep 17 00:00:00 2001 From: Sunny King Date: Sun, 4 Mar 2012 04:36:03 +0000 Subject: [PATCH] PPCoin: RPC command 'getinfo' shows ip address seen by peer --- src/bitcoinrpc.cpp | 5 +++-- src/main.cpp | 4 ++++ src/net.cpp | 3 ++- src/net.h | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 2678d28..2f76057 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -312,6 +312,7 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (fUseProxy ? addrProxy.ToStringIPPort() : string()))); + obj.push_back(Pair("ip", addrSeenByPeer.ToStringIP())); obj.push_back(Pair("generate", (bool)fGenerateBitcoins)); obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1))); obj.push_back(Pair("difficulty", (double)GetDifficulty())); @@ -1447,8 +1448,8 @@ Value walletpassphrase(const Array& params, bool fHelp) if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3)) throw runtime_error( "walletpassphrase [stakeonly]\n" - "Stores the wallet decryption key in memory for seconds." - "stakeonly is an optional true/false allowing only stake creation."); + "Stores the wallet decryption key in memory for seconds.\n" + "stakeonly is optional true/false allowing only stake creation."); if (fHelp) return true; if (!pwalletMain->IsCrypted()) diff --git a/src/main.cpp b/src/main.cpp index 9d9020c..60d0704 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1976,6 +1976,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return true; } + // ppcoin: record my external IP reported by peer + if (addrFrom.IsRoutable() && addrMe.IsRoutable()) + addrSeenByPeer = addrMe; + // Be shy and don't send version until we hear if (pfrom->fInbound) pfrom->PushVersion(); diff --git a/src/net.cpp b/src/net.cpp index 6ef6946..633d521 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2011 The Bitcoin developers -// Copyright (c) 2011 The PPCoin developers +// Copyright (c) 2011-2012 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -47,6 +47,7 @@ bool fClient = false; bool fAllowDNS = false; uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK); CAddress addrLocalHost("0.0.0.0", 0, false, nLocalServices); +CAddress addrSeenByPeer("0.0.0.0", 0, false, nLocalServices); static CNode* pnodeLocalHost = NULL; uint64 nLocalHostNonce = 0; array vnThreadsRunning; diff --git a/src/net.h b/src/net.h index 03da382..b120013 100644 --- a/src/net.h +++ b/src/net.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2012 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_NET_H @@ -76,6 +77,7 @@ extern bool fClient; extern bool fAllowDNS; extern uint64 nLocalServices; extern CAddress addrLocalHost; +extern CAddress addrSeenByPeer; extern uint64 nLocalHostNonce; extern boost::array vnThreadsRunning; -- 1.7.1