| 791 | } |
| 792 | |
| 793 | struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect) |
| 794 | { |
| 795 | struct pubkey outkey; |
| 796 | struct oneshot *timeout; |
| 797 | |
| 798 | /* This shouldn't happen: lightningd should not give invalid ids! */ |
| 799 | if (!pubkey_from_node_id(&outkey, &connect->id)) { |
| 800 | status_broken("Connection out to invalid id %s", |
| 801 | fmt_node_id(tmpctx, &connect->id)); |
| 802 | return io_close(conn); |
| 803 | } |
| 804 | |
| 805 | /* If they don't complete handshake in reasonable time, hang up */ |
| 806 | timeout = new_reltimer(&connect->daemon->timers, conn, |
| 807 | time_from_sec(connect->daemon->timeout_secs), |
| 808 | conn_timeout, conn); |
| 809 | status_peer_debug(&connect->id, "Connected out, starting crypto"); |
| 810 | |
| 811 | connect->connstate = "Cryptographic handshake"; |
| 812 | return initiator_handshake(conn, &connect->daemon->mykey, &outkey, |
| 813 | &connect->addrs[connect->addrnum], |
| 814 | timeout, NORMAL_SOCKET, handshake_out_success, connect); |
| 815 | } |
| 816 | |
| 817 | /*~ When we've exhausted all addresses without success, we come here. |
| 818 | * |
no test coverage detected