1. 12 2月, 2018 1 次提交
    • F
      p2p, p2p/discover: misc connectivity improvements (#16069) · 9123eceb
      Felix Lange 提交于
      * p2p: add DialRatio for configuration of inbound vs. dialed connections
      
      * p2p: add connection flags to PeerInfo
      
      * p2p/netutil: add SameNet, DistinctNetSet
      
      * p2p/discover: improve revalidation and seeding
      
      This changes node revalidation to be periodic instead of on-demand. This
      should prevent issues where dead nodes get stuck in closer buckets
      because no other node will ever come along to replace them.
      
      Every 5 seconds (on average), the last node in a random bucket is
      checked and moved to the front of the bucket if it is still responding.
      If revalidation fails, the last node is replaced by an entry of the
      'replacement list' containing recently-seen nodes.
      
      Most close buckets are removed because it's very unlikely we'll ever
      encounter a node that would fall into any of those buckets.
      
      Table seeding is also improved: we now require a few minutes of table
      membership before considering a node as a potential seed node. This
      should make it less likely to store short-lived nodes as potential
      seeds.
      
      * p2p/discover: fix nits in UDP transport
      
      We would skip sending neighbors replies if there were fewer than
      maxNeighbors results and CheckRelayIP returned an error for the last
      one. While here, also resolve a TODO about pong reply tokens.
      9123eceb
  2. 22 1月, 2018 1 次提交
    • F
      p2p, p2p/discover, p2p/discv5: implement UDP port sharing (#15200) · 92580d69
      Felföldi Zsolt 提交于
      This commit affects p2p/discv5 "topic discovery" by running it on
      the same UDP port where the old discovery works. This is realized
      by giving an "unhandled" packet channel to the old v4 discovery
      packet handler where all invalid packets are sent. These packets
      are then processed by v5. v5 packets are always invalid when
      interpreted by v4 and vice versa. This is ensured by adding one
      to the first byte of the packet hash in v5 packets.
      
      DiscoveryV5Bootnodes is also changed to point to new bootnodes
      that are implementing the changed packet format with modified
      hash. Existing and new v5 bootnodes are both running on different
      ports ATM.
      92580d69
  3. 07 1月, 2017 1 次提交
  4. 15 12月, 2016 1 次提交
  5. 23 11月, 2016 3 次提交
    • F
      p2p, p2p/discover, p2p/discv5: add IP network restriction feature · a47341cf
      Felix Lange 提交于
      The p2p packages can now be configured to restrict all communication to
      a certain subset of IP networks. This feature is meant to be used for
      private networks.
      a47341cf
    • F
      p2p/discover, p2p/discv5: prevent relay of invalid IPs and low ports · a98d1d67
      Felix Lange 提交于
      The discovery DHT contains a number of hosts with LAN and loopback IPs.
      These get relayed because some implementations do not perform any checks
      on the IP.
      
      go-ethereum already prevented relay in most cases because it verifies
      that the host actually exists before adding it to the local table. But
      this verification causes other issues. We have received several reports
      where people's VPSs got shut down by hosting providers because sending
      packets to random LAN hosts is indistinguishable from a slow port scan.
      
      The new check prevents sending random packets to LAN by discarding LAN
      IPs sent by Internet hosts (and loopback IPs from LAN and Internet
      hosts). The new check also blacklists almost all currently registered
      special-purpose networks assigned by IANA to avoid inciting random
      responses from services in the LAN.
      
      As another precaution against abuse of the DHT, ports below 1024 are now
      considered invalid.
      a98d1d67
    • F
      p2p/discover, p2p/discv5: use netutil.IsTemporaryError · ba2884f3
      Felix Lange 提交于
      ba2884f3
  6. 15 4月, 2016 1 次提交
  7. 22 2月, 2016 1 次提交
  8. 19 2月, 2016 1 次提交
  9. 23 1月, 2016 1 次提交
    • F
      p2p/discover: fix Windows-specific issue for larger-than-buffer packets · 2871781f
      Felix Lange 提交于
      On Windows, UDPConn.ReadFrom returns an error for packets larger
      than the receive buffer. The error is not marked temporary, causing
      our loop to exit when the first oversized packet arrived. The fix
      is to treat this particular error as temporary.
      
      Fixes: #1579, #2087
      Updates: #2082
      2871781f
  10. 18 12月, 2015 2 次提交
  11. 27 11月, 2015 1 次提交
  12. 30 9月, 2015 1 次提交
  13. 11 8月, 2015 2 次提交
    • F
      p2p/discover: fix UDP reply packet timeout handling · 590c99a9
      Felix Lange 提交于
      If the timeout fired (even just nanoseconds) before the deadline of the
      next pending reply, the timer was not rescheduled. The timer would've
      been rescheduled anyway once the next packet was sent, but there were
      cases where no next packet could ever be sent due to the locking issue
      fixed in the previous commit.
      
      As timing-related bugs go, this issue had been present for a long time
      and I could never reproduce it. The test added in this commit did
      reproduce the issue on about one out of 15 runs.
      590c99a9
    • F
      p2p/discover: unlock the table during ping replacement · 01ed3fa1
      Felix Lange 提交于
      Table.mutex was being held while waiting for a reply packet, which
      effectively made many parts of the whole stack block on that packet,
      including the net_peerCount RPC call.
      01ed3fa1
  14. 24 7月, 2015 1 次提交
  15. 23 7月, 2015 1 次提交
  16. 07 7月, 2015 1 次提交
  17. 10 6月, 2015 1 次提交
  18. 14 5月, 2015 3 次提交
  19. 12 5月, 2015 2 次提交
  20. 06 5月, 2015 1 次提交
    • F
      p2p/discover: new distance metric based on sha3(id) · 2adcc31b
      Felix Lange 提交于
      The previous metric was pubkey1^pubkey2, as specified in the Kademlia
      paper. We missed that EC public keys are not uniformly distributed.
      Using the hash of the public keys addresses that. It also makes it
      a bit harder to generate node IDs that are close to a particular node.
      2adcc31b
  21. 30 4月, 2015 2 次提交
  22. 24 4月, 2015 3 次提交
  23. 01 4月, 2015 1 次提交
    • F
      p2p/discover: implement node bonding · de7af720
      Felix Lange 提交于
      This a fix for an attack vector where the discovery protocol could be
      used to amplify traffic in a DDOS attack. A malicious actor would send a
      findnode request with the IP address and UDP port of the target as the
      source address. The recipient of the findnode packet would then send a
      neighbors packet (which is 16x the size of findnode) to the victim.
      
      Our solution is to require a 'bond' with the sender of findnode. If no
      bond exists, the findnode packet is not processed. A bond between nodes
      α and β is created when α replies to a ping from β.
      
      This (initial) version of the bonding implementation might still be
      vulnerable against replay attacks during the expiration time window.
      We will add stricter source address validation later.
      de7af720
  24. 13 2月, 2015 1 次提交
  25. 09 2月, 2015 1 次提交
  26. 07 2月, 2015 1 次提交
  27. 06 2月, 2015 2 次提交