From 2e4be792237bdc106d10b0e2e2861dfc17312b31 Mon Sep 17 00:00:00 2001 From: ekoby Date: Thu, 3 Oct 2024 14:09:31 -0400 Subject: [PATCH] set `ziti-edge` application protocol(ALPN) --- library/channel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/channel.c b/library/channel.c index 9701c732..5f713ace 100644 --- a/library/channel.c +++ b/library/channel.c @@ -45,6 +45,10 @@ enum ChannelState { Closed, }; +static const char *edge_alpn[] = { + "ziti-edge", +}; + static inline const char *ch_state_str(ziti_channel_t *ch) { switch (ch->state) { case Initial: @@ -115,6 +119,7 @@ static void ch_init_stream(ziti_channel_t *ch) { tlsuv_stream_init(ch->loop, ch->connection, ch->ctx->tlsCtx); tlsuv_stream_keepalive(ch->connection, true, 30); tlsuv_stream_nodelay(ch->connection, true); + tlsuv_stream_set_protocols(ch->connection, 1, edge_alpn); ch->connection->data = ch; ch->reconnect = false; } @@ -890,8 +895,8 @@ static void on_channel_connect_internal(uv_connect_t *req, int status) { if (status == 0) { if (ch->ctx->api_session != NULL && ch->ctx->api_session->token != NULL) { - CH_LOG(DEBUG, "connected"); tlsuv_stream_t *mbed = (tlsuv_stream_t *) req->handle; + CH_LOG(DEBUG, "connected alpn[%s]", tlsuv_stream_get_protocol(mbed)); tlsuv_stream_read_start(mbed, channel_alloc_cb, on_channel_data); ch->reconnect_count = 0; send_hello(ch, ch->ctx->api_session);