X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=proxy.c;h=bb89a176ae80f3b523fea6ea72b910e2632c30eb;hb=3e22c99c9a3c28e042f2dc3a50fadf95e7c277e7;hp=0b6d9d5828c8d3fd93a0c9893cea4ec07f07f0f7;hpb=a1f3b7a358adaa7c2a98359cd0373aa823eeb14b;p=PuTTY.git diff --git a/proxy.c b/proxy.c index 0b6d9d58..bb89a176 100644 --- a/proxy.c +++ b/proxy.c @@ -65,6 +65,9 @@ void proxy_activate (Proxy_Socket p) */ if (p->pending_flush) sk_flush(p->sub_socket); + /* if we have a pending EOF to send, send it */ + if (p->pending_eof) sk_write_eof(p->sub_socket); + /* if the backend wanted the socket unfrozen, try to unfreeze. * our set_frozen handler will flush buffered receive data before * unfreezing the actual underlying socket. @@ -117,6 +120,17 @@ static int sk_proxy_write_oob (Socket s, const char *data, int len) return sk_write_oob(ps->sub_socket, data, len); } +static void sk_proxy_write_eof (Socket s) +{ + Proxy_Socket ps = (Proxy_Socket) s; + + if (ps->state != PROXY_STATE_ACTIVE) { + ps->pending_eof = 1; + return; + } + sk_write_eof(ps->sub_socket); +} + static void sk_proxy_flush (Socket s) { Proxy_Socket ps = (Proxy_Socket) s; @@ -271,6 +285,15 @@ static int proxy_for_destination (SockAddr addr, char *hostname, int port, 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'. @@ -372,6 +395,7 @@ Socket new_connection(SockAddr addr, char *hostname, sk_proxy_close, sk_proxy_write, sk_proxy_write_oob, + sk_proxy_write_eof, sk_proxy_flush, sk_proxy_set_private_ptr, sk_proxy_get_private_ptr, @@ -412,6 +436,7 @@ Socket new_connection(SockAddr addr, char *hostname, ret->error = NULL; ret->pending_flush = 0; + ret->pending_eof = 0; ret->freeze = 0; bufchain_init(&ret->pending_input_data); @@ -725,8 +750,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;