Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: Use local addr var in version handler. #1256

Merged

Commits on Sep 21, 2018

  1. peer: Add duplicate version message test.

    This adds a test to ensure duplicate version messages are rejected.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    25dfda9 View commit details
    Browse the repository at this point in the history
  2. peer: Rework version negotiation.

    This modifies the negotiation logic to ensure the callback has the
    opportunity to see the message before the peer is disconnected and
    improves the error handling when reading the remote version message.
    
    It also has the side effect of ensuring the protocol version is
    negotiated before sending reject messages with the exception of the
    first message not being a version message since negotiation is not
    possible in that case.
    
    This is being changed because it is useful for the server to see the
    message regardless in order to have the opportunity to things such as
    update the address manager and reject peers that don't have desired
    services.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    118f552 View commit details
    Browse the repository at this point in the history
  3. peer: Allow OnVersion callback to reject peer.

    This modifies the OnVersion callback to allow a reject message to be
    returned in which case the message will be sent to the peer and the peer
    will be disconnected.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    7b103e2 View commit details
    Browse the repository at this point in the history
  4. server: Reject outbound conns to non-full nodes.

    This modifies the server connection code to reject outbound peers that
    do not offer full node services.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    9151ebc View commit details
    Browse the repository at this point in the history
  5. peer: Improve net address service adverts.

    This modifies the peer code which deals with advertising service flags
    via the net address fields of the version message as follows:
    
    - For outgoing connections:
      - Set the local netaddress services to what the local peer supports
      - Set the remote netaddress services to 0 to indicate no services as
        they are still unknown
    - For incoming connections:
      - Set the local netaddress services to what the local peer supports
      - Set the remote netaddress services to the what was advertised by the
        remote peer in its version message
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    4d1e1db View commit details
    Browse the repository at this point in the history
  6. addrmgr: Expose method to update services.

    This exposes a new method named SetServices to the address manager which
    can be used to update the services for a known address.  This will be
    useful to keep known services up to date.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    1 Configuration menu
    Copy the full SHA
    24e2352 View commit details
    Browse the repository at this point in the history
  7. server: Update addrmgr services on outbound conns.

    This adds code to update the address manager services for a known
    address to the services advertised by peers when they are connected to
    via an outbound connection.  It is only done for outbound connections to
    help prevent malicious behavior from inbound connections.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    4b20d4f View commit details
    Browse the repository at this point in the history
  8. server: Use local inbound var in version handler.

    This modifies the OnVersion handler for server peers to use a local
    variable for the inbound status of the peer in order to avoid grabbing
    the mutex multiple times.
    
    While here, it also does some light cleanup.  There are no functional
    changes.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    d2c7892 View commit details
    Browse the repository at this point in the history
  9. server: Only advertise local addr when current.

    This changes the server peers OnVersion handler to only advertise the
    server as a viable target for inbound connections when the server
    believes it is close the best known tip.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    c8b9fab View commit details
    Browse the repository at this point in the history
  10. server: Use local addr var in version handler.

    This modifies the OnVersion handler for server peers to use a local
    variable for the remote address of the peer in order to avoid grabbing
    the mutex multiple times.
    
    There are no functional changes.
    
    Backported from Decred.
    davecgh committed Sep 21, 2018
    Configuration menu
    Copy the full SHA
    8c981e4 View commit details
    Browse the repository at this point in the history