dummy_plug_sent, dummy_plug_accepting
};
-struct X11Display *x11_setup_display(char *display, int authtype,
- const Config *cfg)
+struct X11Display *x11_setup_display(char *display, int authtype, Conf *conf)
{
struct X11Display *disp = snew(struct X11Display);
char *localcopy;
disp->port = 6000 + disp->displaynum;
disp->addr = name_lookup(disp->hostname, disp->port,
- &disp->realhost, cfg, ADDRTYPE_UNSPEC);
+ &disp->realhost, conf, ADDRTYPE_UNSPEC);
if ((err = sk_addr_error(disp->addr)) != NULL) {
sk_addr_free(disp->addr);
disp->localauthproto = X11_NO_AUTH;
disp->localauthdata = NULL;
disp->localauthdatalen = 0;
- platform_get_x11_auth(disp, cfg);
+ platform_get_x11_auth(disp, conf);
return disp;
}
{
struct X11Private *pr = (struct X11Private *) plug;
- /*
- * We have no way to communicate down the forwarded connection,
- * so if an error occurred on the socket, we just ignore it
- * and treat it like a proper close.
- */
- sshfwd_close(pr->c);
- x11_close(pr->s);
+ if (error_msg) {
+ /*
+ * Socket error. Slam the connection instantly shut.
+ */
+ sshfwd_unclean_close(pr->c);
+ } else {
+ /*
+ * Ordinary EOF received on socket. Send an EOF on the SSH
+ * channel.
+ */
+ if (pr->c)
+ sshfwd_write_eof(pr->c);
+ }
+
return 1;
}
* also, fills the SocketsStructure
*/
extern const char *x11_init(Socket *s, struct X11Display *disp, void *c,
- const char *peeraddr, int peerport,
- const Config *cfg)
+ const char *peeraddr, int peerport, Conf *conf)
{
static const struct plug_function_table fn_table = {
x11_log,
pr->s = *s = new_connection(sk_addr_dup(disp->addr),
disp->realhost, disp->port,
- 0, 1, 0, 0, (Plug) pr, cfg);
+ 0, 1, 0, 0, (Plug) pr, conf);
if ((err = sk_socket_error(*s)) != NULL) {
sfree(pr);
return err;
int msglen, msgsize;
unsigned char *reply;
- message = dupprintf("PuTTY X11 proxy: %s", err);
+ message = dupprintf("%s X11 proxy: %s", appname, err);
msglen = strlen(message);
reply = snewn(8 + msglen+1 + 4, unsigned char); /* include zero */
msgsize = (msglen + 3) & ~3;
memset(reply + 8, 0, msgsize);
memcpy(reply + 8, message, msglen);
sshfwd_write(pr->c, (char *)reply, 8 + msgsize);
- sshfwd_close(pr->c);
- x11_close(s);
+ sshfwd_write_eof(pr->c);
sfree(reply);
sfree(message);
return 0;
return sk_write(s, data, len);
}
+
+void x11_send_eof(Socket s)
+{
+ sk_write_eof(s);
+}