2 * Network proxy abstraction in PuTTY
\r
4 * A proxy layer, if necessary, wedges itself between the
\r
5 * network code and the higher level backend.
\r
7 * Supported proxies: HTTP CONNECT, generic telnet, SOCKS 4 & 5
\r
10 #ifndef PUTTY_PROXY_H
\r
11 #define PUTTY_PROXY_H
\r
13 #define PROXY_ERROR_GENERAL 8000
\r
14 #define PROXY_ERROR_UNEXPECTED 8001
\r
16 typedef struct ProxySocket ProxySocket;
\r
18 struct ProxySocket {
\r
23 SockAddr *remote_addr;
\r
26 bufchain pending_output_data;
\r
27 bufchain pending_oob_output_data;
\r
28 bufchain pending_input_data;
\r
31 #define PROXY_STATE_NEW -1
\r
32 #define PROXY_STATE_ACTIVE 0
\r
34 int state; /* proxy states greater than 0 are implementation
\r
35 * dependent, but represent various stages/states
\r
36 * of the initialization/setup/negotiation with the
\r
39 bool freeze; /* should we freeze the underlying socket when
\r
40 * we are done with the proxy negotiation? this
\r
41 * simply caches the value of sk_set_frozen calls.
\r
44 #define PROXY_CHANGE_NEW -1
\r
45 #define PROXY_CHANGE_CLOSING 0
\r
46 #define PROXY_CHANGE_SENT 1
\r
47 #define PROXY_CHANGE_RECEIVE 2
\r
48 #define PROXY_CHANGE_ACCEPTING 3
\r
50 /* something has changed (a call from the sub socket
\r
51 * layer into our Proxy Plug layer, or we were just
\r
52 * created, etc), so the proxy layer needs to handle
\r
53 * this change (the type of which is the second argument)
\r
54 * and further the proxy negotiation process.
\r
57 int (*negotiate) (ProxySocket * /* this */, int /* change type */);
\r
59 /* current arguments of plug handlers
\r
60 * (for use by proxy's negotiate function)
\r
64 const char *closing_error_msg;
\r
65 int closing_error_code;
\r
66 bool closing_calling_back;
\r
69 bool receive_urgent;
\r
70 const char *receive_data;
\r
74 accept_fn_t accepting_constructor;
\r
75 accept_ctx_t accepting_ctx;
\r
77 /* configuration, used to look up proxy settings */
\r
80 /* CHAP transient data */
\r
81 int chap_num_attributes;
\r
82 int chap_num_attributes_processed;
\r
83 int chap_current_attribute;
\r
84 int chap_current_datalen;
\r
90 extern void proxy_activate (ProxySocket *);
\r
92 extern int proxy_http_negotiate (ProxySocket *, int);
\r
93 extern int proxy_telnet_negotiate (ProxySocket *, int);
\r
94 extern int proxy_socks4_negotiate (ProxySocket *, int);
\r
95 extern int proxy_socks5_negotiate (ProxySocket *, int);
\r
98 * This may be reused by local-command proxies on individual
\r
101 char *format_telnet_command(SockAddr *addr, int port, Conf *conf);
\r
104 * These are implemented in cproxy.c or nocproxy.c, depending on
\r
105 * whether encrypted proxy authentication is available.
\r
107 extern void proxy_socks5_offerencryptedauth(BinarySink *);
\r
108 extern int proxy_socks5_handlechap (ProxySocket *);
\r
109 extern int proxy_socks5_selectchap(ProxySocket *);
\r