Bump liberty, enable TLS SNI

Involves some rewrites to fit the new APIs.

SNI has been implemented Mostly just because we can, I don't think it's
widely in use and kike doesn't support this feature of the protocol either.
This commit is contained in:
2015-12-09 00:53:56 +01:00
parent 28fec6d4a6
commit aeb047260f
7 changed files with 53 additions and 54 deletions

View File

@@ -18,6 +18,7 @@
*/
#define LIBERTY_WANT_SSL
#define LIBERTY_WANT_ASYNC
#define LIBERTY_WANT_POLLER
#define LIBERTY_WANT_PROTO_IRC
@@ -40,9 +41,6 @@
return 0; \
BLOCK_END
#define CONTAINER_OF(pointer, type, member) \
(type *) ((char *) pointer - offsetof (type, member))
// --- To be moved to liberty --------------------------------------------------
static ssize_t
@@ -223,7 +221,7 @@ struct socks_connector
// You may destroy the connector object in these two main callbacks:
/// Connection has been successfully established
void (*on_connected) (void *user_data, int socket);
void (*on_connected) (void *user_data, int socket, const char *hostname);
/// Failed to establish a connection to either target
void (*on_failure) (void *user_data);
@@ -594,9 +592,11 @@ socks_connector_on_timeout (struct socks_connector *self)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static void
socks_connector_on_connected (void *user_data, int socket_fd)
socks_connector_on_connected
(void *user_data, int socket_fd, const char *hostname)
{
set_blocking (socket_fd, false);
(void) hostname;
struct socks_connector *self = user_data;
self->socket_fd = socket_fd;
@@ -658,20 +658,8 @@ socks_connector_start (struct socks_connector *self)
connector->on_error = socks_connector_on_error;
connector->on_failure = socks_connector_on_failure;
struct error *e = NULL;
if (!connector_add_target (connector, self->hostname, self->service, &e))
{
if (self->on_error)
self->on_error (self->user_data, e->message);
error_free (e);
socks_connector_destroy_connector (self);
socks_connector_fail (self);
return;
}
connector_add_target (connector, self->hostname, self->service);
poller_timer_set (&self->timeout, 60 * 1000);
connector_step (connector);
self->done = false;
self->bound_port = 0;
@@ -762,8 +750,10 @@ socks_connector_on_ready
int fd = self->socket_fd;
self->socket_fd = -1;
struct socks_target *target = self->targets_iter;
set_blocking (fd, true);
self->on_connected (self->user_data, fd);
self->on_connected (self->user_data, fd, target->address_str);
}
else
// We've failed this target, let's try to move on