Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set ziti-edge application protocol(ALPN) #739

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion library/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
Closed,
};

static const char *edge_alpn[] = {
"ziti-edge",
};

static inline const char *ch_state_str(ziti_channel_t *ch) {
switch (ch->state) {
case Initial:
Expand Down Expand Up @@ -115,6 +119,7 @@
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;
}
Expand Down Expand Up @@ -186,7 +191,7 @@
const char *url;
model_list ch_ids = {0};
MODEL_MAP_FOR(it, ztx->channels) {
model_list_append(&ch_ids, model_map_it_key(it));

Check warning on line 194 in library/channel.c

View workflow job for this annotation

GitHub Actions / Linux ARM64

passing argument 2 of 'model_list_append' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

Check warning on line 194 in library/channel.c

View workflow job for this annotation

GitHub Actions / MacOS x86_64

passing 'const char *' to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

Check warning on line 194 in library/channel.c

View workflow job for this annotation

GitHub Actions / MacOS arm64

passing 'const char *' to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
}

MODEL_LIST_FOR(it, ch_ids) {
Expand Down Expand Up @@ -663,8 +668,8 @@
}

if (success) {
uint8_t *erVersion = "<unknown>";

Check warning on line 671 in library/channel.c

View workflow job for this annotation

GitHub Actions / MacOS x86_64

initializing 'uint8_t *' (aka 'unsigned char *') with an expression of type 'char[10]' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]

Check warning on line 671 in library/channel.c

View workflow job for this annotation

GitHub Actions / MacOS arm64

initializing 'uint8_t *' (aka 'unsigned char *') with an expression of type 'char[10]' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
size_t erVersionLen = strlen(erVersion);

Check warning on line 672 in library/channel.c

View workflow job for this annotation

GitHub Actions / MacOS x86_64

passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]

Check warning on line 672 in library/channel.c

View workflow job for this annotation

GitHub Actions / MacOS arm64

passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
message_get_bytes_header(msg, HelloVersionHeader, &erVersion, &erVersionLen);
CH_LOG(INFO, "connected. EdgeRouter version: %.*s", (int) erVersionLen, erVersion);
ch->state = Connected;
Expand Down Expand Up @@ -890,8 +895,8 @@

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);
Expand Down
Loading