| 847 | } |
| 848 | |
| 849 | struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect) |
| 850 | { |
| 851 | struct pubkey outkey; |
| 852 | struct oneshot *timeout; |
| 853 | |
| 854 | /* This shouldn't happen: lightningd should not give invalid ids! */ |
| 855 | if (!pubkey_from_node_id(&outkey, &connect->id)) { |
| 856 | status_broken("Connection out to invalid id %s", |
| 857 | fmt_node_id(tmpctx, &connect->id)); |
| 858 | return io_close(conn); |
| 859 | } |
| 860 | |
| 861 | /* If they don't complete handshake in reasonable time, hang up */ |
| 862 | timeout = new_reltimer(&connect->daemon->timers, conn, |
| 863 | time_from_sec(connect->daemon->timeout_secs), |
| 864 | conn_timeout, conn); |
| 865 | status_peer_debug(&connect->id, "Connected out, starting crypto"); |
| 866 | |
| 867 | connect->connstate = "Cryptographic handshake"; |
| 868 | return initiator_handshake(conn, &connect->daemon->mykey, &outkey, |
| 869 | &connect->addrs[connect->addrnum], |
| 870 | timeout, NORMAL_SOCKET, handshake_out_success, connect); |
| 871 | } |
| 872 | |
| 873 | /*~ When we've exhausted all addresses without success, we come here. |
| 874 | * |
no test coverage detected