X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=proxy.c;h=e2201c643f80579e4b5dd3aa52310442ed53f469;hb=HEAD;hp=051beb7e9eaabb83a0b38f0704ff99dbd0ec8bdd;hpb=8b3c7d6d132c779e029629fcb9bd932f48fd45dc;p=PuTTY_svn.git diff --git a/proxy.c b/proxy.c index 051beb7e..e2201c64 100644 --- a/proxy.c +++ b/proxy.c @@ -142,18 +142,6 @@ static void sk_proxy_flush (Socket s) sk_flush(ps->sub_socket); } -static void sk_proxy_set_private_ptr (Socket s, void *ptr) -{ - Proxy_Socket ps = (Proxy_Socket) s; - sk_set_private_ptr(ps->sub_socket, ptr); -} - -static void * sk_proxy_get_private_ptr (Socket s) -{ - Proxy_Socket ps = (Proxy_Socket) s; - return sk_get_private_ptr(ps->sub_socket); -} - static void sk_proxy_set_frozen (Socket s, int is_frozen) { Proxy_Socket ps = (Proxy_Socket) s; @@ -261,30 +249,41 @@ static void plug_proxy_sent (Plug p, int bufsize) plug_sent(ps->plug, bufsize); } -static int plug_proxy_accepting (Plug p, OSSocket sock) +static int plug_proxy_accepting(Plug p, + accept_fn_t constructor, accept_ctx_t ctx) { Proxy_Plug pp = (Proxy_Plug) p; Proxy_Socket ps = pp->proxy_socket; if (ps->state != PROXY_STATE_ACTIVE) { - ps->accepting_sock = sock; + ps->accepting_constructor = constructor; + ps->accepting_ctx = ctx; return ps->negotiate(ps, PROXY_CHANGE_ACCEPTING); } - return plug_accepting(ps->plug, sock); + return plug_accepting(ps->plug, constructor, ctx); } /* * This function can accept a NULL pointer as `addr', in which case * it will only check the host name. */ -static int proxy_for_destination (SockAddr addr, char *hostname, int port, - Conf *conf) +int proxy_for_destination (SockAddr addr, const char *hostname, + int port, Conf *conf) { int s = 0, e = 0; char hostip[64]; int hostip_len, hostname_len; const char *exclude_list; + /* + * Special local connections such as Unix-domain sockets + * unconditionally cannot be proxied, even in proxy-localhost + * mode. There just isn't any way to ask any known proxy type for + * them. + */ + if (addr && sk_address_is_special_local(addr)) + return 0; /* do not proxy */ + /* * Check the host name and IP against the hard-coded * representations of `localhost'. @@ -388,8 +387,6 @@ Socket new_connection(SockAddr addr, char *hostname, sk_proxy_write_oob, sk_proxy_write_eof, sk_proxy_flush, - sk_proxy_set_private_ptr, - sk_proxy_get_private_ptr, sk_proxy_set_frozen, sk_proxy_socket_error }; @@ -464,6 +461,8 @@ Socket new_connection(SockAddr addr, char *hostname, conf_get_int(conf, CONF_addressfamily)); if (sk_addr_error(proxy_addr) != NULL) { ret->error = "Proxy error: Unable to resolve proxy host name"; + sfree(pplug); + sk_addr_free(proxy_addr); return (Socket)ret; } sfree(proxy_canonical_name); @@ -606,7 +605,8 @@ int proxy_http_negotiate (Proxy_Socket p, int change) * what should we do? close the socket with an appropriate * error message? */ - return plug_accepting(p->plug, p->accepting_sock); + return plug_accepting(p->plug, + p->accepting_constructor, p->accepting_ctx); } if (change == PROXY_CHANGE_RECEIVE) { @@ -741,8 +741,7 @@ int proxy_socks4_negotiate (Proxy_Socket p, int change) type = sk_addrtype(p->remote_addr); if (type == ADDRTYPE_IPV6) { - plug_closing(p->plug, "Proxy error: SOCKS version 4 does" - " not support IPv6", PROXY_ERROR_GENERAL, 0); + p->error = "Proxy error: SOCKS version 4 does not support IPv6"; return 1; } else if (type == ADDRTYPE_IPV4) { namelen = 0; @@ -809,7 +808,8 @@ int proxy_socks4_negotiate (Proxy_Socket p, int change) * what should we do? close the socket with an appropriate * error message? */ - return plug_accepting(p->plug, p->accepting_sock); + return plug_accepting(p->plug, + p->accepting_constructor, p->accepting_ctx); } if (change == PROXY_CHANGE_RECEIVE) { @@ -948,7 +948,8 @@ int proxy_socks5_negotiate (Proxy_Socket p, int change) * what should we do? close the socket with an appropriate * error message? */ - return plug_accepting(p->plug, p->accepting_sock); + return plug_accepting(p->plug, + p->accepting_constructor, p->accepting_ctx); } if (change == PROXY_CHANGE_RECEIVE) { @@ -1486,7 +1487,8 @@ int proxy_telnet_negotiate (Proxy_Socket p, int change) * what should we do? close the socket with an appropriate * error message? */ - return plug_accepting(p->plug, p->accepting_sock); + return plug_accepting(p->plug, + p->accepting_constructor, p->accepting_ctx); } if (change == PROXY_CHANGE_RECEIVE) {