mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 20:42:48 -05:00
Move port-forwarding setup out of ssh.c.
The tree234 storing currently active port forwardings - both local and remote - now lives in portfwd.c, as does the complicated function that updates it based on a Conf listing the new set of desired forwardings. Local port forwardings are passed to ssh.c via the same route as before - once the listening port receives a connection and portfwd.c knows where it should be directed to (in particular, after the SOCKS exchange, if any), it calls ssh_send_port_open. Remote forwardings are now initiated by calling ssh_rportfwd_alloc, which adds an entry to the rportfwds tree (which _is_ still in ssh.c, and still confusingly sorted by a different criterion depending on SSH protocol version) and sends out the appropriate protocol request. ssh_rportfwd_remove cancels one again, sending a protocol request too. Those functions look enough like ssh_{alloc,remove}_sharing_rportfwd that I've merged those into the new pair as well - now allocating an rportfwd allows you to specify either a destination host/port or a sharing context, and returns a handy pointer you can use to cancel the forwarding later.
This commit is contained in:
33
ssh.h
33
ssh.h
@ -149,10 +149,6 @@ void ssh_connshare_log(Ssh ssh, int event, const char *logtext,
|
||||
const char *ds_err, const char *us_err);
|
||||
unsigned ssh_alloc_sharing_channel(Ssh ssh, ssh_sharing_connstate *connstate);
|
||||
void ssh_delete_sharing_channel(Ssh ssh, unsigned localid);
|
||||
int ssh_alloc_sharing_rportfwd(Ssh ssh, const char *shost, int sport,
|
||||
ssh_sharing_connstate *connstate);
|
||||
void ssh_remove_sharing_rportfwd(Ssh ssh, const char *shost, int sport,
|
||||
ssh_sharing_connstate *connstate);
|
||||
void ssh_sharing_queue_global_request(
|
||||
Ssh ssh, ssh_sharing_connstate *connstate);
|
||||
struct X11FakeAuth *ssh_sharing_add_x11_display(
|
||||
@ -175,6 +171,23 @@ void share_setup_x11_channel(ssh_sharing_connstate *cs, share_channel *chan,
|
||||
int protomajor, int protominor,
|
||||
const void *initial_data, int initial_len);
|
||||
|
||||
struct ssh_rportfwd;
|
||||
struct ssh_rportfwd *ssh_rportfwd_alloc(
|
||||
Ssh ssh, const char *shost, int sport, const char *dhost, int dport,
|
||||
int addressfamily, const char *log_description, PortFwdRecord *pfr,
|
||||
ssh_sharing_connstate *share_ctx);
|
||||
void ssh_rportfwd_remove(Ssh ssh, struct ssh_rportfwd *rpf);
|
||||
|
||||
/* Exports from portfwd.c */
|
||||
PortFwdManager *portfwdmgr_new(Ssh ssh);
|
||||
void portfwdmgr_free(PortFwdManager *mgr);
|
||||
void portfwdmgr_config(PortFwdManager *mgr, Conf *conf);
|
||||
void portfwdmgr_close(PortFwdManager *mgr, PortFwdRecord *pfr);
|
||||
void portfwdmgr_close_all(PortFwdManager *mgr);
|
||||
char *portfwdmgr_connect(PortFwdManager *mgr, Channel **chan_ret,
|
||||
char *hostname, int port, SshChannel *c,
|
||||
int addressfamily);
|
||||
|
||||
Frontend *ssh_get_frontend(Ssh ssh);
|
||||
|
||||
#define SSH_CIPHER_IDEA 1
|
||||
@ -718,22 +731,10 @@ void random_add_heavynoise(void *noise, int length);
|
||||
|
||||
void logevent(Frontend *, const char *);
|
||||
|
||||
struct PortForwarding;
|
||||
|
||||
/* Allocate and register a new channel for port forwarding */
|
||||
SshChannel *ssh_send_port_open(Ssh ssh, const char *hostname, int port,
|
||||
const char *org, Channel *chan);
|
||||
|
||||
/* Exports from portfwd.c */
|
||||
extern char *pfd_connect(Channel **chan_ret, char *hostname, int port,
|
||||
SshChannel *c, Conf *conf, int addressfamily);
|
||||
struct PortListener;
|
||||
/* desthost == NULL indicates dynamic (SOCKS) port forwarding */
|
||||
extern char *pfl_listen(char *desthost, int destport, char *srcaddr,
|
||||
int port, Ssh ssh, Conf *conf,
|
||||
struct PortListener **pl, int address_family);
|
||||
extern void pfl_terminate(struct PortListener *);
|
||||
|
||||
/* Exports from x11fwd.c */
|
||||
enum {
|
||||
X11_TRANS_IPV4 = 0, X11_TRANS_IPV6 = 6, X11_TRANS_UNIX = 256
|
||||
|
Reference in New Issue
Block a user