| 580 | } |
| 581 | |
| 582 | struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect) |
| 583 | { |
| 584 | struct pubkey outkey; |
| 585 | struct oneshot *timeout; |
| 586 | |
| 587 | /* This shouldn't happen: lightningd should not give invalid ids! */ |
| 588 | if (!pubkey_from_node_id(&outkey, &connect->id)) { |
| 589 | status_broken("Connection out to invalid id %s", |
| 590 | type_to_string(tmpctx, struct node_id, |
| 591 | &connect->id)); |
| 592 | return io_close(conn); |
| 593 | } |
| 594 | |
| 595 | /* If they don't complete handshake in reasonable time, hang up */ |
| 596 | timeout = new_reltimer(&connect->daemon->timers, conn, |
| 597 | time_from_sec(connect->daemon->timeout_secs), |
| 598 | conn_timeout, conn); |
| 599 | status_peer_debug(&connect->id, "Connected out, starting crypto"); |
| 600 | |
| 601 | connect->connstate = "Cryptographic handshake"; |
| 602 | return initiator_handshake(conn, &connect->daemon->mykey, &outkey, |
| 603 | &connect->addrs[connect->addrnum], |
| 604 | timeout, handshake_out_success, connect); |
| 605 | } |
| 606 | |
| 607 | /*~ When we've exhausted all addresses without success, we come here. |
| 608 | * |
no test coverage detected