Skip to content

Commit

Permalink
Merge pull request #690 from openziti/fix-run-refresh-interval
Browse files Browse the repository at this point in the history
fix `run --refresh ` parameter
  • Loading branch information
ekoby authored Jul 12, 2023
2 parents c1c117c + 441c9fa commit a02afea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
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
6 changes: 5 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,10 @@ 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) {
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

0 comments on commit a02afea

Please sign in to comment.