Commit Graph

132 Commits

Author SHA1 Message Date
Peter Šurda 23b9555929
Add TLS version debug info 2017-05-07 20:15:57 +02:00
Peter Šurda 913b401dd0
PendingDownloadQueue updates
- track pending hashId more accurately
- add timeout and a cleanup so that the download queues don't
get stuck and memory is freed
- randomise download order (only works for inv commands with
more than 1 entry)
2017-03-20 01:22:37 +01:00
Peter Šurda 1af49a0165
Download tracking refactoring
- replace PendingDownload singleton dict with a Queue
- total memory and CPU requirements should be reduced
- get rid of somObjectsOfWhichThisRemoteNodeIsAlearedyAware. It has very
little practicle effect and only uses memory
2017-03-19 22:08:00 +01:00
Peter Šurda 0529fe2313
Known node count updates
- if too many nodes, only delete oldest nodes in bootstrap provider
  mode, in normal mode ignore new nodes as it used to before
- in bootstrap provider mode, penalise nodes announced by others by 1
  day instead of 3 hours
2017-03-11 12:14:40 +01:00
Peter Šurda 3ac67e5da7
Connection error reporting changes
- fewer tracebacks
- more standardised reports including errno
2017-03-09 11:26:44 +01:00
Peter Šurda e7506b2ac0
Fix tracking of already attempted connections
- it didn't delete the entries correctly, resulting in outgoing syn
  sender deadlocking
2017-02-28 09:43:09 +01:00
Peter Šurda d9d2deee25
Typo in last commit 2017-02-27 23:35:48 +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 a6dbb1e37e
Less timestamp penalty for inbound connections
- was over 2 days, but PyBM will only spread those with more recent than
  3 hours. So it's now set to 2 hours
2017-02-22 16:18:08 +01:00
Peter Šurda e9899743ef
Typos, formatting, obsolete imports 2017-02-22 15:09:36 +01:00
Peter Šurda 6062277d60
Rename to
- it was causing problems with py2app because the source of python's own
  CongigParser is also
2017-02-22 09:34:54 +01:00
Peter Šurda ea9f10a8bb
Simplify and fix list of addresses to send
- it didn't always send the maximum possible amount
- it probably was slow
2017-02-20 22:32:49 +01:00
Peter Šurda 6c907e2046
Windows socket typo 2017-02-17 21:14:39 +01:00
Peter Šurda f94b2d2d4b
Windows compatibility fixes
- there is no errno.WSAEAGAIN, only errno.WSAEWOULDBLOCK
2017-02-14 01:38:58 +01:00
Peter Šurda b0539f5cb4
SSL handshake fewer errors
- don't unnecessarily raise exceptions if SSL handshake fails
2017-02-08 20:49:14 +01:00
Peter Šurda 59f3a2fbe7
Reduce cyclic dependencies
- rearranged code to reduce cyclic dependencies
- doCleanShutdown is separated in
- shared queues are separated in
- some default values were moved to
- knownnodes partially moved to
2017-02-08 13:41:56 +01:00
Peter Šurda 2c72b337c1
Typos and formatting 2017-02-07 20:09:11 +01:00
Peter Šurda 07722fb606
Node negotiation error handling
- complete the version and SSL handshake first, and only then feed
  errors into the stream and close connection
- this allows more accurate error handling on both sides
- also the timeOffset error trigger is now more accurate, but requires
  more nodes to upgrade
2017-02-07 19:38:52 +01:00
Peter Šurda 8515f9a9fc
Set SSL socket to blocking
- otherwise the error handling gets too complicated
2017-02-07 16:42:02 +01:00
Peter Šurda 413419c858
Timeout handling and ping
- timeouts after the connection is established will trigger a ping
- previously they were handled as unrecoverable errors
2017-02-07 16:06:24 +01:00
Peter Šurda 15c620dcc2
SSL socket blocking error handling 2017-02-07 13:00:24 +01:00
Peter Šurda ddc0ca5ede
Retry for certain non-blocking operations
- sometimes on read, EWOULDBLOCK is returned. It should retry. A timeout
  is handled separately
2017-02-06 19:41:25 +01:00
Peter Šurda 61770ba89a
Typo 2017-02-06 19:34:38 +01:00
Peter Šurda f6bdad18a3
Improved stream handling
- version command sends list of all participating streams
- biginv sends lists of hosts for all streams the peer wants (plus
  immediate children)
- objects will spread to all peers that advertise the associated stream
- please note these are just network subsystem adjustments, streams
  aren't actually usable yet
2017-02-06 17:47:05 +01:00
Peter Šurda 23fcf2cdec
SSL handshake python version compatibility
- error handling should now work with < 2.7.9
2017-02-03 10:05:35 +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 01a9124b7d
Less verbose SSL handshake reporting
- if SSL handshake fails, we don't need to stack trace because we know
  where it's happening. Only report the error string.
2017-01-19 19:52:54 +01:00
Peter Šurda 5ae1327edc
Download/upload shutdown fixes
- Missing renamed to PendingDownload
- PendingDownload now only retries 3 times rather than 6 to dowload an
- Added PendingUpload, replacing invQueueSize
- PendingUpload has both the "len" method (number of objects not
  uploaded) as well as "progress" method, which is a float from 0
  (nothing done) to 1 (all uploaded) which considers not only objects
  but also how many nodes they are uploaded to
- PendingUpload tracks when the object is successfully uploaded to the
  remote node instead of just adding an arbitrary time after they have
  been send the corresponding "inv"
- Network status tab's "Objects to be synced" shows the sum of
  PendingUpload and PendingDownload sizes
2017-01-19 19:48:12 +01:00
Peter Šurda ca8550a206
Don't send requests for 0 objects 2017-01-16 23:37:25 +01:00
Peter Šurda 749bb628c0
Typo 2017-01-16 23:37:03 +01:00
Peter Šurda d652dc864d
Downloading fixes
- able to request more objects with one command
- fixes to logic and error handling
2017-01-16 19:36:58 +01:00
Peter Šurda ca6bc9981c
Better tracking in downloading objects
- remember what was requested from which node
- remember if it was received
- re-request object if we haven't received any new object for more than
  a minute
2017-01-16 15:17:23 +01:00
Peter Šurda dbe15d0b99
Objects to be downloaded fixes
- tries to avoid calling senddata it it would block receiveDataThread,
  allowing fore more asynchronous operation
- request objects in chunks of 100 (CPU performance optimisation)
2017-01-15 19:50:28 +01:00
Peter Šurda f079ff5b99
Refactor objects to be downloaded
- moved logic into a Missing singleton
- shouldn't try to download duplicates anymore, only requests a hash
  once every 5 minutes and not from the same host
- removed obsoleted variables
- the "Objects to be synced" in the Network tab should now be correct
- removed some checks which aren't necessary anymore in my opinion
- fix missing self in Throttle (thanks
2017-01-15 19:21:24 +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 689d697a40
Refactor bandwidth limit and speed calculator
- also fixes potential deadlocks
2017-01-14 23:21:00 +01:00
Peter Šurda 02a7c59de8
OpenSSL 1.1.0 compatibility fixes
- part 2, continued from previous commit
2017-01-14 17:50:49 +01:00
Peter Šurda fa2f87743e
SSL handshake fix
- SSL handshake would often fail, because verack packet was being sent
  at the same time as the do_handshake was executed in a different
  thread. This makes it so that do_handshake waits until verack is done
- also minor modifications in SSLContext initialisation
2017-01-14 13:22:46 +01:00
Peter Šurda ff8deebf60
Keep track of network protocol status 2017-01-12 19:18:56 +01:00
Peter Šurda bd520a340f
Trustedpeer fix and more refactoring
- fixed trustedPeer (thanks to anonymous bug reporter)
- moved trustedPeer and Peer into
2017-01-12 06:58:35 +01:00
Peter Šurda 5ceb920bd6
TLS tuning
- allow TLS > 1.0 with python >= 2.7.9
- tune ssl_context with python >= 2.7.9
2017-01-11 20:47:27 +01:00
Peter Šurda c738d93056
Assorted fixes
- was complaining, this fixes most easily fixable errors
2017-01-11 18:13:00 +01:00
Peter Šurda ac348e4e6b
Fixes and refactoring
- fixes errors introduced in the earlier refactoring
- more variables moved to
- path finding functions moved to
- remembers IPv6 network unreachable (in the future can be used to skip
  IPv6 for a while)
2017-01-11 17:00:00 +01:00
Peter Šurda 8bcfe80ad0
Refactoring of config parser and
- 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 into
- moved some global variables from into
- moved some protocol-specific functions from into
2017-01-11 14:27:19 +01:00
Peter Šurda e84b19613e
Inventory refactoring
- minor refactoring, made it into singleton instead of a shared global
  variable. This makes it a little bit cleaner and moves the class into
a separate file
- removed duplicate inventory locking
- renamed to (this is the code that
  ensures only one instance of PyBitmessage runs at the same time)
2017-01-10 21:15:35 +01:00
Peter Šurda 4f543e14c1
TLS handshake fix
- TLS handshake in python is apparently always asynchronous, so it needs
  proper handling of SSLWantReadError and SSLWantWriteError
- also adds a timeout and a proper shutdown if handshake fails
2017-01-07 23:42:07 +01:00
Peter Šurda 7ca6576dfc
Connection indicator for hidden service
- the number of connections as well as connection indicator was broken
  when running as a hidden service. This is a workaround
2016-11-16 19:36:50 +01:00
Peter Šurda 5cea1e04d1
SSL disconnect fix
- sometimes SSL connections unnecessarily disconnected on non-fatal
  errors. This should fix that. This is however a short term solution
  because of migrating to asyncore which has its own error handling
2016-11-16 15:18:09 +01:00
Peter Šurda 40090a9a12
Notify in UI if time offset wrong
- if your time is off by more than an hour, you won't be able to
  establish a connection to the network. This patch adds a UI
  notification so that the user can understand why he can't connect.
2016-10-23 10:12:49 +02:00