Implement peer discovery protocol

Closes #104

DEFAULT_PORTS now a coin property
A Peer object maintains peer information
Revamp LocalRPC "peers" call to show a lot more information
Have lib/jsonrpc.py take care of handling request timeouts
Save and restore peers to a file
Loosen JSON RPC rules so we work with electrum-server and beancurd which don't follow the spec.
Handle incoming server.add_peer requests
Send server.add_peer registrations if peer doesn't have us or correct ports
Verify peers at regular intervals, forget stale peers, verify new peers or those with updated ports
If connecting via one port fails, try the other
Add socks.py for SOCKS4 and SOCKS5 proxying, so Tor servers can now be reached by TCP and SSL
Put full licence boilerplate in lib/ files
Disable IRC advertising on testnet
Serve a Tor banner file if it seems like a connection came from your tor proxy (see ENVIONMENT.rst)
Retry tor proxy hourly, and peers that are about to turn stale
Report more onion peers to a connection that seems to be combing from your tor proxy
Only report good peers to server.peers.subscribe; always report self if valid
Handle peers on the wrong network robustly
Default to 127.0.0.1 rather than localhost for Python <= 3.5.2 compatibility
Put peer name in logs of connections to it
Update docs
This commit is contained in:
Neil Booth
2017-01-27 08:22:37 +09:00
parent 0b0a3a8f5b
commit 1bb8a9d5a4
4 changed files with 57 additions and 17 deletions
+16 -13
View File
@@ -62,10 +62,10 @@ The following commands are available:
Sessions are put into groups, primarily as an anti-DoS measure.
Initially all connections made within a period of time are put in
the same group. High bandwidth usage by a member of a group
deprioritizes itself, and all members of its group to a lesser
deprioritizes that session, and all members of its group to a lesser
extent. Low-priority sessions have their requests served after
higher priority sessions. ElectrumX will start delaying responses
to a sessions if it becomes sufficiently deprioritized.
to a session if it becomes sufficiently deprioritized.
* **sessions**
@@ -125,7 +125,7 @@ The following commands are available:
ElectrumX initiates the socket close process for the passed
sessions. Whilst most connections close quickly, it can take
several minutes for Python to close some SSL connections down.
several minutes for Python to shut some SSL connections down.
* **log**
@@ -153,22 +153,25 @@ The following commands are available:
Returns a list of peer electrum servers. This command takes no arguments.
Currently this is data gleaned from an IRC session.
Currently peer data is obtained via a peer discovery protocol; it
used to be taken from IRC.
* **daemon_url**
This command takes an option argument that is interpreted
identically to the **DAEMON_URL** environment variable. If default
value of the argument is the **DAEMON_URL** environment variable.
This command takes an optional argument that is interpreted
identically to the **DAEMON_URL** environment variable. If omitted,
the default argument value is the process's **DAEMON_URL**
environment variable.
The command replaces the daemon's URL at run-time, and rotates to the
first in the list.
This command replaces the daemon's URL at run-time, and also
forecefully rotates to the first URL in the list.
For example, in case ElectrumX has rotated to a secondary daemon and
you want to revert to the first after fixing the issue, call this
command without an argument.
For example, in case ElectrumX has previously failed over to a
secondary daemon and you want to revert to the primary having
resolved the connectivity issue, invoking this command without an
argument will have that effect.
* **reorg**
Force a block chain reorg. This command takes an optional
argument - the number of blocks to reorg - that defaults to 3.
argument - the number of blocks to reorg - which defaults to 3.