diff --git a/Recipe b/Recipe index f0183b88..c76b14f7 100644 --- a/Recipe +++ b/Recipe @@ -253,7 +253,7 @@ NONSSH = telnet raw rlogin ldisc pinger SSH = ssh sshcrc sshdes sshmd5 sshrsa sshrand sshsha sshblowf + sshdh sshcrcda sshpubk sshzlib sshdss x11fwd portfwd + sshaes sshccp sshsh256 sshsh512 sshbn wildcard pinger ssharcf - + sshgssc pgssapi sshshare sshecc aqsync marshal + + sshgssc pgssapi sshshare sshecc aqsync marshal nullplug WINSSH = SSH winnoise wincapi winpgntc wingss winshare winnps winnpc + winhsock errsock UXSSH = SSH uxnoise uxagentc uxgss uxshare @@ -344,7 +344,7 @@ psftp : [U] psftp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC uxnogtk pageant : [X] uxpgnt uxagentc aqsync pageant sshrsa sshpubk sshdes sshbn + sshmd5 version tree234 misc sshaes sshsha sshdss sshsh256 sshsh512 + sshecc CONF uxsignal nocproxy nogss be_none x11fwd ux_x11 uxcons - + gtkask gtkmisc UXMISC + + gtkask gtkmisc nullplug UXMISC ptermapp : [XT] GTKTERM uxmisc misc ldisc settings uxpty uxsel BE_NONE uxstore + uxsignal CHARSET uxpterm version time xpmpterm xpmptcfg diff --git a/network.h b/network.h index 438d6013..9914ce34 100644 --- a/network.h +++ b/network.h @@ -207,6 +207,11 @@ char *get_hostname(void); */ Socket new_error_socket(const char *errmsg, Plug plug); +/* + * Trivial plug that does absolutely nothing. Found in nullplug.c. + */ +extern Plug nullplug; + /* ---------------------------------------------------------------------- * Functions defined outside the network code, which have to be * declared in this header file rather than the main putty.h because diff --git a/nullplug.c b/nullplug.c new file mode 100644 index 00000000..afc1aa38 --- /dev/null +++ b/nullplug.c @@ -0,0 +1,42 @@ +/* + * nullplug.c: provide a null implementation of the Plug vtable which + * ignores all calls. Occasionally useful in cases where we want to + * make a network connection just to see if it works, but not do + * anything with it afterwards except close it again. + */ + +#include "putty.h" + +static void nullplug_socket_log(Plug plug, int type, SockAddr addr, int port, + const char *error_msg, int error_code) +{ +} + +static void nullplug_closing(Plug plug, const char *error_msg, int error_code, + int calling_back) +{ +} + +static void nullplug_receive(Plug plug, int urgent, char *data, int len) +{ +} + +static void nullplug_sent(Plug plug, int bufsize) +{ +} + +static const Plug_vtable nullplug_plugvt = { + nullplug_socket_log, + nullplug_closing, + nullplug_receive, + nullplug_sent, + NULL +}; + +static const Plug_vtable *nullplug_plugvt_ptr = &nullplug_plugvt; + +/* + * There's a singleton instance of nullplug, because it's not + * interesting enough to worry about making more than one of them. + */ +Plug nullplug = &nullplug_plugvt_ptr; diff --git a/sshshare.c b/sshshare.c index aa2313e1..862d871a 100644 --- a/sshshare.c +++ b/sshshare.c @@ -2031,39 +2031,17 @@ char *ssh_share_sockname(const char *host, int port, Conf *conf) return sockname; } -static void nullplug_socket_log(Plug plug, int type, SockAddr addr, int port, - const char *error_msg, int error_code) {} -static void nullplug_closing(Plug plug, const char *error_msg, int error_code, - int calling_back) {} -static void nullplug_receive(Plug plug, int urgent, char *data, int len) {} -static void nullplug_sent(Plug plug, int bufsize) {} - -static const Plug_vtable nullplug_plugvt = { - nullplug_socket_log, - nullplug_closing, - nullplug_receive, - nullplug_sent, - NULL -}; - -struct nullplug { - const Plug_vtable *plugvt; -}; - int ssh_share_test_for_upstream(const char *host, int port, Conf *conf) { char *sockname, *logtext, *ds_err, *us_err; int result; Socket sock; - struct nullplug np; - - np.plugvt = &nullplug_plugvt; sockname = ssh_share_sockname(host, port, conf); sock = NULL; logtext = ds_err = us_err = NULL; - result = platform_ssh_share(sockname, conf, &np.plugvt, (Plug)NULL, &sock, + result = platform_ssh_share(sockname, conf, nullplug, (Plug)NULL, &sock, &logtext, &ds_err, &us_err, FALSE, TRUE); sfree(logtext); diff --git a/x11fwd.c b/x11fwd.c index 45b959a7..493eca67 100644 --- a/x11fwd.c +++ b/x11fwd.c @@ -52,22 +52,6 @@ static int xdmseen_cmp(void *a, void *b) memcmp(sa->clientid, sb->clientid, sizeof(sa->clientid)); } -/* Do-nothing "plug" implementation, used by x11_setup_display() when it - * creates a trial connection (and then immediately closes it). - * XXX: bit out of place here, could in principle live in a platform- - * independent network.c or something */ -static void dummy_plug_log(Plug p, int type, SockAddr addr, int port, - const char *error_msg, int error_code) { } -static void dummy_plug_closing - (Plug p, const char *error_msg, int error_code, int calling_back) { } -static void dummy_plug_receive(Plug p, int urgent, char *data, int len) { } -static void dummy_plug_sent(Plug p, int bufsize) { } -static int dummy_plug_accepting(Plug p, accept_fn_t constructor, accept_ctx_t ctx) { return 1; } -static const Plug_vtable dummy_plug_vtable = { - dummy_plug_log, dummy_plug_closing, dummy_plug_receive, - dummy_plug_sent, dummy_plug_accepting -}; - struct X11FakeAuth *x11_invent_fake_auth(tree234 *authtree, int authtype) { struct X11FakeAuth *auth = snew(struct X11FakeAuth); @@ -306,8 +290,7 @@ struct X11Display *x11_setup_display(const char *display, Conf *conf) if (!err) { /* Create trial connection to see if there is a useful Unix-domain * socket */ - const Plug_vtable *dummy = &dummy_plug_vtable; - Socket s = sk_new(sk_addr_dup(ux), 0, 0, 0, 0, 0, &dummy); + Socket s = sk_new(sk_addr_dup(ux), 0, 0, 0, 0, 0, nullplug); err = sk_socket_error(s); sk_close(s); }