We've always had the back-end code unconditionally print 'Looking up
host' before calling name_lookup. But name_lookup doesn't always do an
actual lookup - in cases where the connection will be proxied and
we're configured to let the proxy do the DNS for us, it just calls
sk_nonamelookup to return a dummy SockAddr with the unresolved name
still in it. It's better to print a message that varies depending on
whether we're _really_ doing DNS or not, e.g. so that people can tell
the difference between DNS failure and proxy misconfiguration.
Hence, those log messages are now generated inside name_lookup(),
which takes a couple of extra parameters for the purpose - a frontend
pointer to pass to logevent(), and a reason string so that it can say
what the hostname it's (optionally) looking up is going to be used
for. (The latter is intended for possible use in logging subsidiary
lookups for port forwarding, though the moment I haven't changed
the current setup where those connection setups aren't logged in
detail - we just pass NULL in that situation.)
Socket new_listener(const char *srcaddr, int port, Plug plug,
int local_host_only, Conf *conf, int addressfamily);
SockAddr name_lookup(const char *host, int port, char **canonicalname,
Socket new_listener(const char *srcaddr, int port, Plug plug,
int local_host_only, Conf *conf, int addressfamily);
SockAddr name_lookup(const char *host, int port, char **canonicalname,
- Conf *conf, int addressfamily);
+ Conf *conf, int addressfamily, void *frontend_for_logging,
+ const char *lookup_reason_for_logging);
int proxy_for_destination (SockAddr addr, const char *hostname, int port,
Conf *conf);
int proxy_for_destination (SockAddr addr, const char *hostname, int port,
Conf *conf);
/*
* Try to find host.
*/
/*
* Try to find host.
*/
- addr = name_lookup(hostname, port, &dummy_realhost, conf, addressfamily);
+ addr = name_lookup(hostname, port, &dummy_realhost, conf, addressfamily,
+ NULL, NULL);
if ((err = sk_addr_error(addr)) != NULL) {
char *err_ret = dupstr(err);
sk_addr_free(addr);
if ((err = sk_addr_error(addr)) != NULL) {
char *err_ret = dupstr(err);
sk_addr_free(addr);
}
SockAddr name_lookup(const char *host, int port, char **canonicalname,
}
SockAddr name_lookup(const char *host, int port, char **canonicalname,
- Conf *conf, int addressfamily)
+ Conf *conf, int addressfamily, void *frontend,
+ const char *reason)
if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE &&
do_proxy_dns(conf) &&
proxy_for_destination(NULL, host, port, conf)) {
if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE &&
do_proxy_dns(conf) &&
proxy_for_destination(NULL, host, port, conf)) {
+
+ if (frontend) {
+ logmsg = dupprintf("Leaving host lookup to proxy of \"%s\""
+ " (for %s)", host, reason);
+ logevent(frontend, logmsg);
+ sfree(logmsg);
+ }
+
*canonicalname = dupstr(host);
return sk_nonamelookup(host);
*canonicalname = dupstr(host);
return sk_nonamelookup(host);
+ } else {
+ if (frontend) {
+ logmsg = dupprintf("Looking up host \"%s\"%s for %s", host,
+ (addressfamily == ADDRTYPE_IPV4 ? " (IPv4)" :
+ addressfamily == ADDRTYPE_IPV6 ? " (IPv6)" :
+ ""), reason);
+ logevent(frontend, logmsg);
+ sfree(logmsg);
+ }
+
+ return sk_namelookup(host, canonicalname, addressfamily);
-
- return sk_namelookup(host, canonicalname, addressfamily);
}
Socket new_connection(SockAddr addr, const char *hostname,
}
Socket new_connection(SockAddr addr, const char *hostname,
/*
* Try to find host.
*/
/*
* Try to find host.
*/
- {
- char *buf;
- buf = dupprintf("Looking up host \"%s\"%s", host,
- (addressfamily == ADDRTYPE_IPV4 ? " (IPv4)" :
- (addressfamily == ADDRTYPE_IPV6 ? " (IPv6)" :
- "")));
- logevent(raw->frontend, buf);
- sfree(buf);
- }
- addr = name_lookup(host, port, realhost, conf, addressfamily);
+ addr = name_lookup(host, port, realhost, conf, addressfamily,
+ raw->frontend, "main connection");
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
/*
* Try to find host.
*/
/*
* Try to find host.
*/
- {
- char *buf;
- buf = dupprintf("Looking up host \"%s\"%s", host,
- (addressfamily == ADDRTYPE_IPV4 ? " (IPv4)" :
- (addressfamily == ADDRTYPE_IPV6 ? " (IPv6)" :
- "")));
- logevent(rlogin->frontend, buf);
- sfree(buf);
- }
- addr = name_lookup(host, port, realhost, conf, addressfamily);
+ addr = name_lookup(host, port, realhost, conf, addressfamily,
+ rlogin->frontend, "rlogin connection");
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
* Try to find host.
*/
addressfamily = conf_get_int(ssh->conf, CONF_addressfamily);
* Try to find host.
*/
addressfamily = conf_get_int(ssh->conf, CONF_addressfamily);
- logeventf(ssh, "Looking up host \"%s\"%s", host,
- (addressfamily == ADDRTYPE_IPV4 ? " (IPv4)" :
- (addressfamily == ADDRTYPE_IPV6 ? " (IPv6)" : "")));
- addr = name_lookup(host, port, realhost, ssh->conf, addressfamily);
+ addr = name_lookup(host, port, realhost, ssh->conf, addressfamily,
+ ssh->frontend, "SSH connection");
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
/*
* Try to find host.
*/
/*
* Try to find host.
*/
- {
- char *buf;
- addressfamily = conf_get_int(telnet->conf, CONF_addressfamily);
- buf = dupprintf("Looking up host \"%s\"%s", host,
- (addressfamily == ADDRTYPE_IPV4 ? " (IPv4)" :
- (addressfamily == ADDRTYPE_IPV6 ? " (IPv6)" :
- "")));
- logevent(telnet->frontend, buf);
- sfree(buf);
- }
- addr = name_lookup(host, port, realhost, telnet->conf, addressfamily);
+ addressfamily = conf_get_int(telnet->conf, CONF_addressfamily);
+ addr = name_lookup(host, port, realhost, telnet->conf, addressfamily,
+ telnet->frontend, "Telnet connection");
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
return err;
disp->port = 6000 + disp->displaynum;
disp->addr = name_lookup(disp->hostname, disp->port,
disp->port = 6000 + disp->displaynum;
disp->addr = name_lookup(disp->hostname, disp->port,
- &disp->realhost, conf, ADDRTYPE_UNSPEC);
+ &disp->realhost, conf, ADDRTYPE_UNSPEC,
+ NULL, NULL);
if ((err = sk_addr_error(disp->addr)) != NULL) {
sk_addr_free(disp->addr);
if ((err = sk_addr_error(disp->addr)) != NULL) {
sk_addr_free(disp->addr);