Add facility to disable peer discovery
and/or self announcement.
This commit is contained in:
parent
86f6a148b9
commit
5662f1fa88
@ -215,8 +215,8 @@ raise them.
|
|||||||
functioning Electrum clients by default will send pings roughly
|
functioning Electrum clients by default will send pings roughly
|
||||||
every 60 seconds.
|
every 60 seconds.
|
||||||
|
|
||||||
TOR
|
PEER DISCOVERY
|
||||||
---
|
--------------
|
||||||
|
|
||||||
In response to the `server.peers.subscribe` RPC call, ElectrumX will
|
In response to the `server.peers.subscribe` RPC call, ElectrumX will
|
||||||
only return peer servers that is has recently connected to and
|
only return peer servers that is has recently connected to and
|
||||||
@ -229,12 +229,36 @@ peers it will fall back to a hard-coded list.
|
|||||||
To give incoming clients a full range of onion servers you will need
|
To give incoming clients a full range of onion servers you will need
|
||||||
to be running a Tor proxy for ElectrumX to use.
|
to be running a Tor proxy for ElectrumX to use.
|
||||||
|
|
||||||
|
ElectrumX will perform peer-discovery by default and announce itself
|
||||||
|
to other peers. If your server is private you may wish to disable
|
||||||
|
some of this.
|
||||||
|
|
||||||
|
* **PEER_DISCOVERY**
|
||||||
|
|
||||||
|
If not defined, or non-empty, ElectrumX will occasionally connect to
|
||||||
|
and verify its network of peer servers. Set to empty to disable
|
||||||
|
peer discovery.
|
||||||
|
|
||||||
|
* **PEER_ANNOUNCE**
|
||||||
|
|
||||||
|
Set this environemnt variable to empty to disable announcing itself.
|
||||||
|
If not defined, or non-empty, ElectrumX will announce itself to
|
||||||
|
peers.
|
||||||
|
|
||||||
|
If peer discovery is disabled this environment variable has no
|
||||||
|
effect, because ElectrumX only announces itself to peers when doing
|
||||||
|
peer discovery if it notices it is not present in the peer's
|
||||||
|
returned list.
|
||||||
|
|
||||||
* **TOR_PROXY_HOST**
|
* **TOR_PROXY_HOST**
|
||||||
|
|
||||||
The host where the Tor proxy is running. Defaults to *127.0.0.1*.
|
The host where your Tor proxy is running. Defaults to *127.0.0.1*.
|
||||||
If you use a hostname here rather than an IP address, you must have
|
If you use a hostname here rather than an IP address, you must have
|
||||||
Python version >= 3.5.3, Python 3.5.2 will **not** work.
|
Python version >= 3.5.3, Python 3.5.2 will **not** work.
|
||||||
|
|
||||||
|
If you are not running a Tor proxy just leave this environment
|
||||||
|
variable undefined.
|
||||||
|
|
||||||
* **TOR_PROXY_PORT**
|
* **TOR_PROXY_PORT**
|
||||||
|
|
||||||
The port on which the Tor proxy is running. If not set, ElectrumX
|
The port on which the Tor proxy is running. If not set, ElectrumX
|
||||||
|
|||||||
@ -48,7 +48,9 @@ class Env(LoggedClass):
|
|||||||
self.banner_file)
|
self.banner_file)
|
||||||
self.anon_logs = self.default('ANON_LOGS', False)
|
self.anon_logs = self.default('ANON_LOGS', False)
|
||||||
self.log_sessions = self.integer('LOG_SESSIONS', 3600)
|
self.log_sessions = self.integer('LOG_SESSIONS', 3600)
|
||||||
# Tor proxy
|
# Peer discovery
|
||||||
|
self.peer_discovery = bool(self.default('PEER_DISCOVERY', True))
|
||||||
|
self.peer_announce = bool(self.default('PEER_ANNOUNCE', True))
|
||||||
# Python 3.5.3 - revert back to localhost?
|
# Python 3.5.3 - revert back to localhost?
|
||||||
self.tor_proxy_host = self.default('TOR_PROXY_HOST', '127.0.0.1')
|
self.tor_proxy_host = self.default('TOR_PROXY_HOST', '127.0.0.1')
|
||||||
self.tor_proxy_port = self.integer('TOR_PROXY_PORT', None)
|
self.tor_proxy_port = self.integer('TOR_PROXY_PORT', None)
|
||||||
|
|||||||
@ -112,13 +112,16 @@ class PeerSession(JSONSession):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.peer_mgr.add_peers(peers)
|
self.peer_mgr.add_peers(peers)
|
||||||
|
|
||||||
|
if not self.peer_mgr.env.peer_announce:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Announce ourself if not present
|
||||||
my = self.peer_mgr.myself
|
my = self.peer_mgr.myself
|
||||||
for peer in my.matches(peers):
|
for peer in my.matches(peers):
|
||||||
if peer.tcp_port == my.tcp_port and peer.ssl_port == my.ssl_port:
|
if peer.tcp_port == my.tcp_port and peer.ssl_port == my.ssl_port:
|
||||||
return
|
return
|
||||||
|
self.log_info('registering ourself with server.add_peer')
|
||||||
# Announce ourself if not present
|
|
||||||
self.log_info('registering with server.add_peer')
|
|
||||||
self.send_request(self.on_add_peer, 'server.add_peer', [my.features])
|
self.send_request(self.on_add_peer, 'server.add_peer', [my.features])
|
||||||
|
|
||||||
def on_add_peer(self, result, error):
|
def on_add_peer(self, result, error):
|
||||||
@ -407,6 +410,11 @@ class PeerManager(util.LoggedClass):
|
|||||||
3) Retrying old peers at regular intervals.
|
3) Retrying old peers at regular intervals.
|
||||||
'''
|
'''
|
||||||
self.connect_to_irc()
|
self.connect_to_irc()
|
||||||
|
if not self.env.peer_discovery:
|
||||||
|
self.logger.info('peer discovery is disabled')
|
||||||
|
return
|
||||||
|
|
||||||
|
self.logger.info('beginning peer discovery')
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
timeout = self.loop.call_later(WAKEUP_SECS,
|
timeout = self.loop.call_later(WAKEUP_SECS,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user