Skip to content

Commit

Permalink
update tlsuv@0.29.0
Browse files Browse the repository at this point in the history
add proxy option to ziti-prox-c
  • Loading branch information
ekoby committed May 14, 2024
1 parent a727020 commit b877e8a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else ()

FetchContent_Declare(tlsuv
GIT_REPOSITORY https://github.com/openziti/tlsuv.git
GIT_TAG v0.28.5
GIT_TAG v0.29.0
)
FetchContent_MakeAvailable(tlsuv)

Expand Down
43 changes: 29 additions & 14 deletions programs/ziti-prox-c/proxy.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) 2022-2023. NetFoundry Inc.
// Copyright (c) 2022-2024. NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
Expand All @@ -14,6 +14,7 @@
#define _GNU_SOURCE

#include <uv.h>
#include <tlsuv/http.h>

#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -691,14 +692,16 @@ void run(int argc, char **argv) {
CommandLine main_cmd;
#define GLOBAL_FLAGS "[--debug=level|-d[ddd]] [--config|-c=<path>] "

typedef struct tlsuv_url tlsuv_url;
int run_opts(int argc, char **argv) {
static struct option long_options[] = {
{"debug", optional_argument, NULL, 'd'},
{"config", required_argument, NULL, 'c'},
{"metrics", optional_argument, NULL, 'm'},
{"bind", required_argument, NULL, 'b'},
{"bind-udp", required_argument, NULL, 'B'},
{NULL, 0, NULL, 0}
{"debug", optional_argument, NULL, 'd'},
{"config", required_argument, NULL, 'c'},
{"metrics", optional_argument, NULL, 'm'},
{"bind", required_argument, NULL, 'b'},
{"bind-udp", required_argument, NULL, 'B'},
{"proxy", required_argument, NULL, 'p'},
{NULL, 0, NULL, 0}
};

int c, option_index, errors = 0;
Expand All @@ -707,7 +710,7 @@ int run_opts(int argc, char **argv) {

optind = 0;

while ((c = getopt_long(argc, argv, "b:B:c:d:m:",
while ((c = getopt_long(argc, argv, "b:B:c:d:m:p:",
long_options, &option_index)) != -1) {
switch (c) {
case 'd':
Expand Down Expand Up @@ -772,11 +775,23 @@ int run_opts(int argc, char **argv) {
model_list_clear(&args, free);
break;

default: {
fprintf(stderr, "Unknown option \"%c\"\n", c);
errors++;
break;
}
case 'p': {
struct tlsuv_url_s url;
tlsuv_parse_url(&url, optarg);
char host[128], port[6];
snprintf(host, sizeof(host), "%.*s", (int)url.hostname_len, url.hostname);
snprintf(port, sizeof(port), "%d", url.port);
tlsuv_set_global_connector(
tlsuv_new_proxy_connector(tlsuv_PROXY_HTTP, host, port)
);
break;
}

default: {
fprintf(stderr, "Unknown option \"%c\"\n", c);
errors++;
break;
}
}
}

Expand Down

0 comments on commit b877e8a

Please sign in to comment.