Commit Graph

65 Commits

Author SHA1 Message Date
Neil Booth
35dd1f6199 Remove IRC support 2017-11-27 15:05:42 +09:00
Neil Booth
72fce87088 Put server_features() on the environment object
Fixes #302
2017-11-16 20:14:49 +00:00
Neil Booth
81947d796b Enhance PEER_DISCOVERY environment variable
It is now tri-state - ON, OFF or SELF.

Fixes #287
2017-10-11 13:54:13 +09:00
Neil Booth
3e376a79eb Rename lib/env to lib/env_base 2017-09-28 08:57:44 +08:00
Neil Booth
ae03ea6cb6 Add env object for wallet engine
Split out common Env parts to a base class.
2017-09-21 18:16:37 +08:00
Luke Childs
0e6b59eb92 Add ALLOW_ROOT option (#268)
* Add ALLOW_ROOT option

* Document ALLOW_ROOT option

* Update controller.py

* Update ENVIRONMENT.rst
2017-09-20 08:14:06 +08:00
Neil Booth
131344715a Minor environment variable improvements
- COIN and NET strip surrounding whitespace
- new environment variable RPC_HOST, similar to HOST, but
  for RPC.  Permits fine-grained control of which addresses
  the RPC server listens on.
- HOST and RPC_HOST strip surrounding whitespace from hostnames
  and IP addresses
- tests and documentation updated to match
2017-09-09 22:00:54 +09:00
Neil Booth
3cc5b5ea43 Make COIN env variable mandatory.
- make a clean split between the  Cash and Segwit flavours of bitcoin
  by giving them their own COIN names.  They can then both have a NET
  of mainnet.
- The previous Bitcoin COIN names no longer exist, and the env var is
  now mandatory, so everyone will need to set COIN and NET appropriately
  for their flavour of bitcoin and mainnet or testnet.
2017-09-07 13:53:44 +09:00
Neil Booth
a978ca6df7 Permit HOST to be a comma-separated list.
Update documentation to match.
2017-09-06 20:19:59 +09:00
Neil Booth
137236712f Add EVENT_LOOP_POLICY environment variable
Based on #215 by JustinTArthur.

- Accept EVENT_LOOP_POLICY of uvloop
- Move initilisation from electrumx_server to controller
- SocksProxy now requires a loop
- Update tests
2017-08-26 14:03:02 +09:00
sam
5b475751f1 Correct 'seessions' (sessions) (#220) 2017-08-13 07:29:20 +07:00
Neil Booth
d216d5111b Prepare 1.0.9 2017-04-09 14:20:17 +09:00
Neil Booth
8a2821d542 Reject invalid hostnames in Env 2017-04-09 14:15:10 +09:00
Neil Booth
f3de91180e Add tests for server/env.py 2017-04-06 07:27:48 +09:00
Neil Booth
a94d320e5d New feature: force peer discovery via proxy
Set FORCE_PROXY to non-empty to force peer discovery to go
through the proxy.  See docs/ENVIRONMENT.rst

Wait for an attempt at proxy discovery to be made before beginning
peer discovery.
2017-04-02 15:06:29 +09:00
Neil Booth
178de6c396 Tighten restrictions on HOST
- private IP not allowed if intending for public use
- localhost not allowed
2017-04-02 10:58:55 +09:00
Neil Booth
321315ace0 Fix typo 2017-04-01 15:17:17 +09:00
Neil Booth
9abc1dc11e REPORT_HOST no longer defaults to HOST
Cleanup of identity handling.  It is now possible to specify
a Tor identity and no clearnet identity.
2017-04-01 12:03:53 +09:00
Neil Booth
594b66236f Prepare 1.0.5 2017-03-28 12:30:06 +09:00
Neil Booth
e4947cb9ef Sanitize the maximum number of sessions
Reduce the maximum number of sessions to permit if running with
a tight rlimit, to avoid hitting open file limits.  Log when
doing so.

Closes #158
2017-03-25 13:28:42 +09:00
Neil Booth
84c201f665 Improve diagnostic 2017-03-25 11:35:56 +09:00
Neil Booth
5f56689e9c Don't permit common invalid REPORT_HOST values 2017-03-21 22:17:01 +09:00
Neil Booth
39bcdb1b6a Require Python 3.5.3
3.5.2 has various socket and API issues affecting peer discovery

Closes #135
2017-03-01 07:23:11 +09:00
Neil Booth
5662f1fa88 Add facility to disable peer discovery
and/or self announcement.
2017-02-19 19:02:01 +09:00
Neil Booth
151da40d5b 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
2017-02-18 12:43:45 +09:00
Neil Booth
b23b19473c Sanity check on basic IRC reported settings
Closes #110
2017-01-31 07:58:19 +09:00
Neil Booth
06c8eda161 Preparations for peer discovery
DEFAULT_PORTS is a now a coin property.
Other miscellaneous updates to get things closer
2017-01-29 06:47:43 +09:00
Neil Booth
551c04a3bc Remove all uses of "except:" 2017-01-25 20:28:19 +09:00
Neil Booth
05a6da1920 Move peer management to peers.py from irc
It's cleaner and will be useful for peer-to-peer comms later
2017-01-22 23:34:44 +09:00
Neil Booth
15051124af Make flushes and reorgs async
Apart from the flush on shutdown and the flush when caught up,
neither of which matter, this makes flushes asynchronous.

Also, block processing for reorgs is now asynchronous.

This also removes the FORCE_REORG debug envvar; I want to
put that into the RPC interface.

Closes #102
2017-01-09 16:15:17 +09:00
Neil Booth
dcc2c92bd6 Rename NETWORK envvar to NET
For consistency with lib/coins.py

SegWit testnet needs its own NET
2017-01-08 10:07:58 +09:00
Neil Booth
91ca5fc14a Split out history into its own DB. 2017-01-07 11:51:12 +09:00
Neil Booth
2b2909f1c4 Move to hashX
The hashX of a script is the first 11 bytes of its sha256 hash.

Closes #72.
2017-01-07 11:51:01 +09:00
Neil Booth
e2f4847632 New env var MAX_SESSIONS
When the number of sessions reaches MAX_SESSIONS, which defaults
to 1,000, turn off TCP and SSL listening sockets to prevent new
connections.  When the session count falls below a low watermark,
currently 90% of MAX_SESSIONS, the listening sockets will be re-opened.
Helps prevent DoS and limit open file usage.

Bug fix: do not start serving paused connections until the buffer
socket is sufficiently drained.  Also, loop.
2016-12-13 22:47:03 +09:00
Neil Booth
3d2824218b Close stale sessions
New envvar SESSION_TIMEOUT
A session with no activity is cut off after this time
Fixes #56
2016-12-03 13:06:20 +09:00
Shane Moore
0edff0056d Add Tor-specific port options for IRC 2016-12-01 03:21:52 -08:00
Shane Moore
95c848a720 Add IRC option to publish Tor address 2016-11-30 23:50:20 -08:00
Neil Booth
b65bcda504 Add per-session bandwidth limits 2016-11-29 22:19:12 +09:00
Neil Booth
5053101cee LOG_SESSIONS should use self.integer 2016-11-29 19:32:11 +09:00
Neil Booth
c08ade5861 Add session logging facility
Move session logging code to protocol.py from electrum_rpc.py
Use it for periodic logging controlled by envvar LOG_SESSIONS
For each session, track sent transaction stats and show that
per-session instead of errors
2016-11-29 08:00:54 +09:00
Neil Booth
4e26e0fe96 Bump default value of MAX_SEND to 1m bytes.
Otherwise historic large txs could not be served to clients.
2016-11-26 15:22:42 +09:00
Neil Booth
292073f2c7 Log large requests and reject them 2016-11-26 09:32:29 +09:00
Neil Booth
de4930b96d Introduce MAX_HIST environment variable. 2016-11-24 23:30:40 +09:00
Neil Booth
640360c809 Add feature to simulate reorgs for debugging 2016-11-23 09:52:30 +09:00
Neil Booth
8970205e6c Remove obsolete debugging feature 2016-11-23 09:16:41 +09:00
Neil Booth
87cdd2709d Implement daemon failover
Daemon URLs can be comma-separated in the DAEMON_URL env var.
Surrounding whitespace is stripped.
http:// is preprended if missing.
The coin's default port is supplied if missing.
A trailing / is supplied if missing.
Closes #33
2016-11-20 20:52:54 +09:00
Neil Booth
0b52376f23 Add subscription limits 2016-11-19 10:51:16 +09:00
Neil Booth
66c493dbf4 Make the default reorg_limit a coin property 2016-11-18 19:21:38 +09:00
Neil Booth
cc2db4a62c Bump HIST_MB default to 300MB 2016-11-16 06:39:39 +09:00
Johann Bauer
d45321927e Add optional option to anonymise logs (remove IP addresses) 2016-11-13 23:56:16 +01:00