Commit Graph

32 Commits

Author SHA1 Message Date
Peter Šurda 59e1739136
Revert duplicate IP treatment for bootstrap
- bootstrap provider mode shouldn't accept multiple connections from a
  single IP after all, it creates problems
2017-02-28 00:20:34 +01:00
Peter Šurda 339e375958
Bootstrap provider mode and minor knownNodes changes
- if knownNodes grows to 20000, instead of ignoring new nodes, forget
  the 1000 oldest ones
- drop connection after sendaddr if too many connections, even if it's
  an outbound one
- if maximum total connections are lower than maximum outbound
  connections, active bootstrap provider mode
- in this mode, check all addresses received before announcing them
- so basically it only annouces those addresses it successfully
  connected to
2017-02-27 23:31:12 +01:00
Peter Šurda 7ebe837eb0
Make some network parameters configurable
- maxtotalconnections = maximum number of total full connections
  (incoming + outgoing) the node will allow. Default 200 as it was.
- maxbootstrapconnections = number of additional (to total) connection
  that will act in bootstrap mode, closing after sending the list of
  addresses. Default 20 as it was.
- maxaddrperstreamsend = initial address list maximum size, per
  participating stream. Default 500. Child streams get half. The
  response is chunked into pieces of max. 1000 addresses as that's the
  protocol limit.
2017-02-26 17:46:02 +01:00
Peter Šurda 0fa0599cd4
IPv4 listen socket fix
- on OpenBSD, you can't have a socket that supports both IPv4 and IPv6.
  This allows handling for this error, and then it will try IPv4 only,
  just like for other similar errors.
2017-02-26 12:55:43 +01:00
Peter Šurda 191650f5a4
Typos
- previous commit contained typos
2017-02-26 12:52:28 +01:00
Peter Šurda b1b0c46555
Improve exception handling
- there were reports of errors in FreeBSD (I could only reproduce some)
  and Gentoo without IPv4 support (I don't have a VM for testing ready)
- adds an exception handler for double task_done in case sender thread
  has to close prematurely (I saw this triggered on FreeBSD 11)
- listening socket opening error handler was broken (triggered if you
  can't open a socket with both IPv4 and IPv6 support)
- error handler for socket.accept. Reported on FreeBSD 10.3
- fixes #854
2017-02-26 12:42:18 +01:00
Peter Šurda 6062277d60
Rename configparser.py to bmconfigparser.py
- it was causing problems with py2app because the source of python's own
  CongigParser is also configparser.py
2017-02-22 09:34:54 +01:00
Peter Šurda ba130e03e5
Network subsystem freezing fixes
- queues were too short
- some error handling was missing
- remove nonblocking repeats in receive data thread
- singleCleaner shouldn't wait unnecessarily
2017-02-02 15:52:32 +01:00
Peter Šurda 6d2a75bfc9
Transfer speed improvements
- send buffer to send multiple commands in one TCP packet
- recv/send operation size now based on bandwith limit
- send queue limited to 100 entries
- buffer getdata commands to fill send queue, instead of waiting for the
  data packet to arrive first (i.e. allow getdata to work asynchronously)
2017-01-15 15:08:03 +01:00
Peter Šurda ad75552b5c
Move shutdown from shared.py to state.py 2017-01-14 23:20:15 +01:00
Peter Šurda bd520a340f
Trustedpeer fix and more refactoring
- fixed trustedPeer (thanks to anonymous bug reporter)
- moved trustedPeer and Peer into state.py
2017-01-12 06:58:35 +01:00
Peter Šurda 8bcfe80ad0
Refactoring of config parser and shared.py
- got rid of shared config parser and made it into a singleton
- refactored safeConfigGetBoolean as a method of the config singleton
- refactored safeConfigGet as a method of the config singleton
- moved softwareVersion from shared.py into version.py
- moved some global variables from shared.py into state.py
- moved some protocol-specific functions from shared.py into protocol.py
2017-01-11 14:27:19 +01:00
Peter Šurda 0dd54e606d
Multiple connections on hidden service fix
- there was a bug which prevented multiple parallel connections on
  hidden service
2016-06-10 18:01:46 +02:00
Peter Šurda f242d409fd
Tor hidden service fixes
- will send the correct combination of hostname and port
- if proxyhostname is a hostname and an IP address, it will now allow
  multiple parallel connections for hidden service
2016-06-10 10:44:42 +02:00
Peter Šurda 1a40c29d22
Add Tor hidden service support
- PyBitmessage can now run as a hidden service on Tor
- three new variables in keys.dat: onionhostname, onionport, onionbindip
- you need to manually add a hidden service to tor
2016-06-07 21:59:48 +02:00
Peter Šurda 4c2ce7208c Sleep on invalid getdata
- postpone initial sleep until the first getdata is received
- also sleep when received a getdata request for an object that hasn't
been advertised to the other node yet
2016-05-02 15:00:24 +02:00
mailchuck d69c2e097f Cleaner shutdown
Addresses Bitmessage#549
2016-05-02 15:00:21 +02:00
mailchuck 231219a193 Improved logging
Fixes #118

- changed almost all "print" into logger
- threads have nicer names
- logger can have configuration in "logger.dat" in the same directory as
"keys.dat", and the logger will pick the one named "default" to replace
the "console" and "file" that are in PyBitmessage otherwise

Example file for logging to syslog:

[loggers]
keys = root,syslog

[logger_root]
level=NOTSET
handlers=syslog

[logger_syslog]
level=DEBUG
handlers=syslog
qualname=default

[handlers]
keys = syslog

[handler_syslog]
class = handlers.SysLogHandler
formatter = syslog
level = DEBUG
args=(('localhost', handlers.SYSLOG_UDP_PORT),
handlers.SysLogHandler.LOG_LOCAL7)

[formatters]
keys = syslog

[formatter_syslog]
format=%(asctime)s %(threadName)s %(filename)s@%(lineno)d %(message)s
datefmt=%b %d %H:%M:%S
2016-05-02 15:00:21 +02:00
Jonathan Warren c306062282 Bitmessage Protocol Version Three 2014-08-27 03:14:32 -04:00
Jonathan Warren 38d7db24ad Merge pull request #639 from bpeel/wip/trusted-peer
Add a 'trustedpeer' option to keys.dat
2014-04-30 17:42:28 -04:00
Neil Roberts 7da6ea958f Add support for IPv6
It will now listen on an IPv6 socket if possible or fall back to IPv4
if that doesn't work. It will no longer filter out all IPv6 addresses
and instead it will only filter out those that point to the local
network.

It looks like the DNS bootstrapping should just automatically work
because getaddrinfo already returns IPv6 addresses from the AAAA
record.

In order to convert from the ASCII representation of IPv6 addresses
and back we need inet_ntop and inet_pton. Python 2 doesn't currently
provide these for Windows so instead this patch provides a hot patch
to the socket module which wraps WSAStringToAddress and
WSAAddressToString using ctypes.
2014-03-12 01:48:48 +00:00
Neil Roberts 03263156de Add a 'trustedpeer' option to keys.dat
If this option is specified in keys.dat then Bitmessage will connect
to the host specified there instead of connecting to the hosts in the
list of known nodes. It will also stop listening for incoming
connections and the timing attack mitigation will be disabled.

The expected use case is for example where a user is running a daemon
on a dedicated machine in their local network and they occasionally
want to check for messages using a second instance of the client on
their laptop. In that case it would be much faster to catch up with
the messages by directly downloading from the dedicated machine over
the LAN. There is no need to connect to multiple peers or to do the
timing attack mitigation because the daemon is trusted.

The host is specified as hostname:port. Eg, ‘192.168.1.8:8444’.
2014-02-06 13:16:07 +00:00
Jonathan Warren 61389b64aa fix #590 2013-12-29 22:36:23 -05:00
Jonathan Warren c27494ace9 Further work to implement the Connect dialog on startup 2013-07-24 12:43:51 -04:00
Jonathan Warren 350e8d66c7 Prompt user to connect at first startup 2013-07-24 11:46:28 -04:00
David Nichols 27c0ac436c Updating code comments to reflect changes in listening for connections when using SOCKS. 2013-07-12 13:40:06 -05:00
David Nichols 97f0c56aa8 Adding configuration option to listen for connections when operating with a SOCKS proxy. 2013-07-12 13:03:09 -05:00
Linker Lin 4a84a30fc6 replace acquire lock by 'with' statement 2013-06-30 01:29:35 +08:00
Jonathan Warren c857f73d0b Continued moving code into individual modules 2013-06-24 15:51:01 -04:00
Jordan Hall fe8998ca3a Seperating out all peer networking classes and merging with upstream 2013-06-22 00:49:50 +01:00
Jordan Hall 27a8662f22 Seperating class_singleListener, class_receiveDataThread, class_sendDataThread 2013-06-21 23:29:04 +01:00
Jordan Hall ebc62b9edc Moving certain classes outside of bitmessagemain.py 2013-06-20 22:23:03 +01:00