1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
putty-source/proxy
Simon Tatham b7bf2aec74 Reorganise proxy system into coroutines.
Previously, the proxy negotiation functions were written as explicit
state machines, with ps->state being manually set to a sequence of
positive integer values which would be tested by if statements in the
next call to the same negotiation function.

That's not how this code base likes to do things! We have a coroutine
system to allow those state machines to be implicit rather than
explicit, so that we can use ordinary control flow statements like
while loops. Reorganised each proxy negotiation function into a
coroutine-based system like that.

While I'm at it, I've also moved each proxy negotiator out into its
own source file, to make proxy.c less overcrowded and monolithic. And
_that_ gave me the opportunity to define each negotiator as an
implementation of a trait rather than as a single function - which
means now each one can define its own local variables and have its own
cleanup function, instead of all of them having to share the variables
inside the main ProxySocket struct.

In the new coroutine system, negotiators don't have to worry about the
mechanics of actually sending data down the underlying Socket any
more. The negotiator coroutine just appends to a bufchain (via a
provided bufchain_sink), and after every call to the coroutine,
central code in proxy.c transfers the data to the Socket itself. This
avoids a lot of intermediate allocations within the negotiators, which
previously kept having to make temporary strbufs or arrays in order to
have something to point an sk_write() at; now they can just put
formatted data directly into the output bufchain via the marshal.h
interface.

In this version of the code, I've also moved most of the SOCKS5 CHAP
implementation from cproxy.c into socks5.c, so that it can sit in the
same coroutine as the rest of the proxy negotiation control flow.
That's because calling a sub-coroutine (co-subroutine?) is awkward to
set up (though it is _possible_ - we do SSH-2 kex that way), and
there's no real need to bother in this case, since the only thing that
really needs to go in cproxy.c is the actual cryptography plus a flag
to tell socks5.c whether to offer CHAP authentication in the first
place.
2021-11-19 15:09:17 +00:00
..
cproxy.c Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00
http.c Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00
interactor.c Fix Plink's handling of interactor_announce() blank lines. 2021-11-06 14:48:26 +00:00
nocproxy.c Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00
noproxy.c Pass an Interactor to new_connection(). 2021-10-30 18:19:56 +01:00
nosshproxy.c Pass an Interactor to new_connection(). 2021-10-30 18:19:56 +01:00
pproxy.c Move proxy-related source files into a subdirectory. 2021-10-30 17:29:24 +01:00
proxy.c Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00
proxy.h Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00
socks4.c Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00
socks5.c Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00
socks.h Pull out SOCKS protocol constants into a header. 2021-11-19 15:09:17 +00:00
sshproxy.c New Seat query, has_mixed_input_stream(). 2021-11-06 14:48:26 +00:00
telnet.c Reorganise proxy system into coroutines. 2021-11-19 15:09:17 +00:00