summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-12-09 00:53:56 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-01-04 01:12:42 +0100
commitaeb047260fefa187f5b2c5c740280c81b9ccb8f4 (patch)
tree68871219f216772b1a441f1a64ee2719d6be27a5 /common.c
parent28fec6d4a6a30e2fdb5394e90673e60f7c46234b (diff)
downloadxK-aeb047260fefa187f5b2c5c740280c81b9ccb8f4.tar.gz
xK-aeb047260fefa187f5b2c5c740280c81b9ccb8f4.tar.xz
xK-aeb047260fefa187f5b2c5c740280c81b9ccb8f4.zip
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.
Diffstat (limited to 'common.c')
-rw-r--r--common.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/common.c b/common.c
index 0d34591..d4cf479 100644
--- a/common.c
+++ b/common.c
@@ -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