mirror of https://github.com/omar-polo/gmid.git
properly handle handshake failures
If a TLS handshake fails there's nothing we can do, so don't attempt to reply an error (the connected client is not speaking Gemini as it's not using TLS at all) and instead just close the connection. Fixes issue #13
This commit is contained in:
parent
53bdae38fe
commit
c5edb15740
12
server.c
12
server.c
|
@ -434,8 +434,11 @@ handle_handshake(int fd, short ev, void *d)
|
|||
|
||||
switch (tls_handshake(c->ctx)) {
|
||||
case 0: /* success */
|
||||
case -1: /* already handshaked */
|
||||
break;
|
||||
case -1:
|
||||
log_warnx("tls_handshake failed: %s", tls_error(c->ctx));
|
||||
client_close(c);
|
||||
return;
|
||||
case TLS_WANT_POLLIN:
|
||||
event_once(c->fd, EV_READ, handle_handshake, c, NULL);
|
||||
return;
|
||||
|
@ -1309,9 +1312,10 @@ client_close(struct client *c)
|
|||
c->pfd = -1;
|
||||
}
|
||||
|
||||
bufferevent_disable(c->bev, EVBUFFER_READ|EVBUFFER_WRITE);
|
||||
bufferevent_free(c->bev);
|
||||
c->bev = NULL;
|
||||
if (c->bev != NULL) {
|
||||
bufferevent_disable(c->bev, EVBUFFER_READ|EVBUFFER_WRITE);
|
||||
bufferevent_free(c->bev);
|
||||
}
|
||||
|
||||
if (c->proxyevset &&
|
||||
event_pending(&c->proxyev, EV_READ|EV_WRITE, NULL)) {
|
||||
|
|
Loading…
Reference in New Issue