-\versionid $Id: config.but,v 1.45 2002/12/18 11:39:25 simon Exp $
+\versionid $Id: config.but,v 1.46 2002/12/18 12:18:54 simon Exp $
\C{config} Configuring PuTTY
This excludes both of the above ranges at once.
+Connections to the local host (the host name \c{localhost}, and any
+loopback IP address) are never proxied, even if the proxy exclude
+list does not explicitly contain them. It is very unlikely that this
+behaviour would ever cause problems, but if it does you can change
+it by enabling \q{Consider proxying local host connections}.
+
\S{config-proxy-auth} Username and password
\cfg{winhelp-topic}{proxy.auth}
SockAddr sk_namelookup(char *host, char **canonicalname);
void sk_getaddr(SockAddr addr, char *buf, int buflen);
+int sk_hostname_is_local(char *name);
+int sk_address_is_local(SockAddr addr);
enum { ADDRTYPE_IPV4, ADDRTYPE_IPV6 };
int sk_addrtype(SockAddr addr);
void sk_addrcopy(SockAddr addr, char *buf);
int hostip_len, hostname_len;
char * exclude_list;
+ /*
+ * Check the host name and IP against the hard-coded
+ * representations of `localhost'.
+ */
+ if (!cfg.even_proxy_localhost &&
+ (sk_hostname_is_local(hostname) || sk_address_is_local(addr)))
+ return 0; /* do not proxy */
+
/* we want a string representation of the IP address for comparisons */
sk_getaddr(addr, hostip, 64);
int tcp_nodelay;
/* Proxy options */
char proxy_exclude_list[512];
+ int even_proxy_localhost;
enum { PROXY_NONE, PROXY_HTTP, PROXY_SOCKS, PROXY_TELNET } proxy_type;
char proxy_host[512];
int proxy_port;
/* proxy settings */
write_setting_s(sesskey, "ProxyExcludeList", cfg->proxy_exclude_list);
+ write_setting_i(sesskey, "ProxyLocalhost", cfg->even_proxy_localhost);
write_setting_i(sesskey, "ProxyType", cfg->proxy_type);
write_setting_s(sesskey, "ProxyHost", cfg->proxy_host);
write_setting_i(sesskey, "ProxyPort", cfg->proxy_port);
/* proxy settings */
gpps(sesskey, "ProxyExcludeList", "", cfg->proxy_exclude_list,
sizeof(cfg->proxy_exclude_list));
+ gppi(sesskey, "ProxyLocalhost", 0, &cfg->even_proxy_localhost);
gppi(sesskey, "ProxyType", PROXY_NONE, &i); cfg->proxy_type = i;
gpps(sesskey, "ProxyHost", "proxy", cfg->proxy_host,
sizeof(cfg->proxy_host));
#endif
}
+int sk_hostname_is_local(char *name)
+{
+ return !strcmp(name, "localhost");
+}
+
+int sk_address_is_local(SockAddr addr)
+{
+#ifdef IPV6
+ if (addr->family == AF_INET) {
+#endif
+ struct in_addr a;
+ a.s_addr = htonl(addr->address);
+ return ipv4_is_loopback(a);
+#ifdef IPV6
+ } else {
+ FIXME; /* someone who can compile for IPV6 had better do this bit */
+ }
+#endif
+}
+
int sk_addrtype(SockAddr addr)
{
return (addr->family == AF_INET ? ADDRTYPE_IPV4 : ADDRTYPE_IPV6);
IDC_PROXYPORTEDIT,
IDC_PROXYEXCLUDESTATIC,
IDC_PROXYEXCLUDEEDIT,
+ IDC_PROXYLOCALHOST,
IDC_PROXYUSERSTATIC,
IDC_PROXYUSEREDIT,
IDC_PROXYPASSSTATIC,
return "JI(`',`proxy.main')";
case IDC_PROXYEXCLUDESTATIC:
case IDC_PROXYEXCLUDEEDIT:
+ case IDC_PROXYLOCALHOST:
return "JI(`',`proxy.exclude')";
case IDC_PROXYUSERSTATIC:
case IDC_PROXYUSEREDIT:
SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
+ CheckDlgButton(hwnd, IDC_PROXYLOCALHOST, cfg.even_proxy_localhost);
SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
multiedit(&cp,
"&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
IDC_PROXYEXCLUDEEDIT, 100, NULL);
+ checkbox(&cp, "Consider pro&xying local host connections",
+ IDC_PROXYLOCALHOST);
staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
IDC_PROXYUSEREDIT, 60);
staticpassedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
}
break;
+ case IDC_PROXYLOCALHOST:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED)
+ cfg.even_proxy_localhost =
+ IsDlgButtonChecked(hwnd, IDC_PROXYLOCALHOST);
+ break;
case IDC_PROXYTYPENONE:
case IDC_PROXYTYPEHTTP:
case IDC_PROXYTYPESOCKS:
#endif
}
+int sk_hostname_is_local(char *name)
+{
+ return !strcmp(name, "localhost");
+}
+
+int sk_address_is_local(SockAddr addr)
+{
+#ifdef IPV6
+ if (addr->family == AF_INET) {
+#endif
+ struct in_addr a;
+ a.s_addr = htonl(addr->address);
+ return ipv4_is_loopback(a);
+#ifdef IPV6
+ } else {
+ FIXME; /* someone who can compile for IPV6 had better do this bit */
+ }
+#endif
+}
+
int sk_addrtype(SockAddr addr)
{
return (addr->family == AF_INET ? ADDRTYPE_IPV4 : ADDRTYPE_IPV6);