struct connection *c = request->connection;
struct host_addrs *resolved = &request->resolved_host_addrs;
- bool needs_dns = host_addrs_need_dns(resolved, verbose);
- vdbg("needs.dns = %s", bool_str(needs_dns));
-
- if (!needs_dns) {
- resolve_default_route(&resolved->end[LEFT_END],
- &resolved->end[RIGHT_END],
- resolved->afi,
- verbose);
- resolve_default_route(&resolved->end[RIGHT_END],
- &resolved->end[LEFT_END],
- resolved->afi,
- verbose);
+ unsigned need_dns = (route_addrs_need_dns(&resolved->end[LEFT_END]) +
+ route_addrs_need_dns(&resolved->end[RIGHT_END]));
+ if (need_dns > 0) {
+ vdbg("connection has unresolved DNS; scheduling CHECK_DDNS");
+ schedule_connection_check_ddns(c, verbose);
}
+ /*
+ * Even when need DNS, try to resolve routes. Connection can
+ * still orient provided one of the addresses is known.
+ *
+ * Should skip end when it has unresolved DNS?
+ */
+ resolve_default_route(&resolved->end[LEFT_END],
+ &resolved->end[RIGHT_END],
+ resolved->afi,
+ verbose);
+ resolve_default_route(&resolved->end[RIGHT_END],
+ &resolved->end[LEFT_END],
+ resolved->afi,
+ verbose);
+
build_connection_host_and_proposals_from_resolve(c, resolved, verbose);
/*
- * When possible, try to orient the connection.
+ * Always try to orient; should skip when both ends have
+ * unresolved DNS?
*/
vassert(!oriented(c));
- if (needs_dns) {
- vdbg("unresolved connection can't orient; scheduling CHECK_DDNS");
- schedule_connection_check_ddns(c, verbose);
- } else if (!orient(c, verbose)) {
- vdbg("connection did not orient, scheduling CHECK_DDNS");
- schedule_connection_check_ddns(c, verbose);
- } else if (verbose.debug) {
- vdbg("connection oriented, re-checking DB");
- connection_db_check(verbose.logger, HERE);
+ if (orient(c, verbose)) {
+ if (verbose.debug) {
+ vdbg("connection oriented; rechecking DB");
+ connection_db_check(verbose.logger, HERE);
+ }
}
request->callback(c, resolved, verbose);