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

fix run --refresh parameter #690

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions lib/ziti-tunnel-cbs/include/ziti/ziti_tunnel_cbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ struct ziti_instance_s {
LIST_ENTRY(ziti_instance_s) _next;
};

void ziti_set_refresh_interval(unsigned long seconds);

struct ziti_instance_s *new_ziti_instance_ex(const char *identifier);
void set_ziti_instance(const char *identifier, struct ziti_instance_s *inst);
void remove_ziti_instance(const char *identifier);
Expand Down
7 changes: 6 additions & 1 deletion lib/ziti-tunnel-cbs/ziti_tunnel_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void on_ziti_event(ziti_context ztx, const ziti_event_t *event);

static const char * cfg_types[] = { "ziti-tunneler-client.v1", "intercept.v1", "ziti-tunneler-server.v1", "host.v1", NULL };

static long refresh_interval = 10;
static unsigned long refresh_interval = 10;

static int process_cmd(const tunnel_command *cmd, void (*cb)(const tunnel_result *, void *ctx), void *ctx);
static int load_identity(const char *identifier, const char *path, int api_page_size, command_cb cb, void *ctx);
Expand Down Expand Up @@ -103,6 +103,11 @@ const ziti_tunnel_ctrl* ziti_tunnel_init_cmd(uv_loop_t *loop, tunneler_context t

IMPL_ENUM(mfa_status, MFA_STATUS)

void ziti_set_refresh_interval(unsigned long seconds) {
unsigned long old = refresh_interval;
ekoby marked this conversation as resolved.
Show resolved Hide resolved
refresh_interval = seconds;
}

static ziti_context get_ziti(const char *identifier) {
struct ziti_instance_s *inst = model_map_get(&instances, identifier);

Expand Down
13 changes: 8 additions & 5 deletions programs/ziti-edge-tunnel/ziti-edge-tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ struct ipc_conn_s {
// list to store the ipc connections
static LIST_HEAD(ipc_list, ipc_conn_s) ipc_clients_list = LIST_HEAD_INITIALIZER(ipc_clients_list);

static long refresh_interval = 10;
static long refresh_metrics = 5000;
static long metrics_latency = 5000;
static char* configured_cidr;
Expand Down Expand Up @@ -1824,9 +1823,11 @@ static int run_opts(int argc, char *argv[]) {
case 'v':
setenv("ZITI_LOG", optarg, true);
break;
case 'r':
refresh_interval = strtol(optarg, NULL, 10);
case 'r': {
unsigned long interval = strtoul(optarg, NULL, 10);
ziti_set_refresh_interval(interval);
break;
}
case 'd': // ip range
configured_cidr = optarg;
break;
Expand Down Expand Up @@ -1871,9 +1872,11 @@ static int run_host_opts(int argc, char *argv[]) {
case 'v':
setenv("ZITI_LOG", optarg, true);
break;
case 'r':
refresh_interval = strtol(optarg, NULL, 10);
case 'r': {
unsigned long interval = strtoul(optarg, NULL, 10);
ziti_set_refresh_interval(interval);
break;
}
default: {
ZITI_LOG(ERROR, "Unknown option '%c'", c);
errors++;
Expand Down
Loading