X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=proxy.c;h=3104ef0d8922f8dfd33028b8e1b989d4a5608252;hb=222c134b5f4f5397f2a15d36813286edeb3cff5e;hp=8a146231036be4c51d7ba77319cb667160ab16af;hpb=808df44e54192d5d41b8ce988d064566027a53bc;p=PuTTY.git diff --git a/proxy.c b/proxy.c index 8a146231..3104ef0d 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,24 +249,26 @@ 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, const 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]; @@ -372,7 +362,7 @@ static int proxy_for_destination (SockAddr addr, const char *hostname, return 1; } -SockAddr name_lookup(char *host, int port, char **canonicalname, +SockAddr name_lookup(const char *host, int port, char **canonicalname, Conf *conf, int addressfamily) { if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE && @@ -385,7 +375,7 @@ SockAddr name_lookup(char *host, int port, char **canonicalname, return sk_namelookup(host, canonicalname, addressfamily); } -Socket new_connection(SockAddr addr, char *hostname, +Socket new_connection(SockAddr addr, const char *hostname, int port, int privport, int oobinline, int nodelay, int keepalive, Plug plug, Conf *conf) @@ -397,10 +387,9 @@ 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 + sk_proxy_socket_error, + NULL, /* peer_info */ }; static const struct plug_function_table plug_fn_table = { @@ -500,8 +489,8 @@ Socket new_connection(SockAddr addr, char *hostname, return sk_new(addr, port, privport, oobinline, nodelay, keepalive, plug); } -Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only, - Conf *conf, int addressfamily) +Socket new_listener(const char *srcaddr, int port, Plug plug, + int local_host_only, Conf *conf, int addressfamily) { /* TODO: SOCKS (and potentially others) support inbound * TODO: connections via the proxy. support them. @@ -617,7 +606,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) { @@ -819,7 +809,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) { @@ -958,7 +949,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) { @@ -1496,7 +1488,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) {