MCPcopy Create free account
hub / github.com/cryptonomex/graphene / send_hello_message

Method send_hello_message

libraries/net/node.cpp:4189–4230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4187 } // accept_loop()
4188
4189 void node_impl::send_hello_message(const peer_connection_ptr& peer)
4190 {
4191 VERIFY_CORRECT_THREAD();
4192 peer->negotiation_status = peer_connection::connection_negotiation_status::hello_sent;
4193
4194 fc::sha256::encoder shared_secret_encoder;
4195 fc::sha512 shared_secret = peer->get_shared_secret();
4196 shared_secret_encoder.write(shared_secret.data(), sizeof(shared_secret));
4197 fc::ecc::compact_signature signature = _node_configuration.private_key.sign_compact(shared_secret_encoder.result());
4198
4199 // in the hello messsage, we send three things:
4200 // ip address
4201 // outbound port
4202 // inbound port
4203 // The peer we're connecting to will assume we're firewalled if the
4204 // ip address and outbound port we send don't match the values it sees on its remote endpoint
4205 //
4206 // if we know that we're behind a NAT that will allow incoming connections because our firewall
4207 // detection figured it out, send those values instead.
4208
4209 fc::ip::endpoint local_endpoint(peer->get_socket().local_endpoint());
4210 uint16_t listening_port = _node_configuration.accept_incoming_connections ? _actual_listening_endpoint.port() : 0;
4211
4212 if (_is_firewalled == firewalled_state::not_firewalled &&
4213 _publicly_visible_listening_endpoint)
4214 {
4215 local_endpoint = *_publicly_visible_listening_endpoint;
4216 listening_port = _publicly_visible_listening_endpoint->port();
4217 }
4218
4219 hello_message hello(_user_agent_string,
4220 core_protocol_version,
4221 local_endpoint.get_address(),
4222 listening_port,
4223 local_endpoint.port(),
4224 _node_public_key,
4225 signature,
4226 _chain_id,
4227 generate_hello_user_data());
4228
4229 peer->send_message(message(hello));
4230 }
4231
4232 void node_impl::connect_to_task(peer_connection_ptr new_peer,
4233 const fc::ip::endpoint& remote_endpoint)

Callers

nothing calls this directly

Calls 3

messageClass · 0.50
get_shared_secretMethod · 0.45
send_messageMethod · 0.45

Tested by

no test coverage detected