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

Feature/staticbuffers #173

Closed
wants to merge 12 commits into from
5 changes: 5 additions & 0 deletions src/config/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void set_defaults(ksnet_cfg *ksn_cfg) {

strncpy(ksn_cfg->network, "local", KSN_BUFFER_SM_SIZE/2);
ksn_cfg->net_key[0] = '\0';
ksn_cfg->auth_secret[0] = '\0';

// Show info at console flags
ksn_cfg->show_connect_f = 1;
Expand Down Expand Up @@ -147,6 +148,7 @@ void read_config(ksnet_cfg *conf, int port_param) {
// Save values back to structure
#define save_conf_back() \
strncpy(conf->net_key, net_key, KSN_BUFFER_SM_SIZE/2); \
strncpy(conf->auth_secret, auth_secret, KSN_BUFFER_SM_SIZE/2); \
strncpy(conf->host_name, host_name, KSN_MAX_HOST_NAME); \
strncpy(conf->r_host_addr, r_host_addr, KSN_BUFFER_SM_SIZE/2); \
strncpy(conf->vpn_ip, vpn_ip, KSN_MAX_HOST_NAME); \
Expand All @@ -162,6 +164,7 @@ void read_config(ksnet_cfg *conf, int port_param) {
char *vpn_ip = strdup(conf->vpn_ip);
char *filter = strdup(conf->filter);
char *net_key = strdup(conf->net_key);
char *auth_secret = strdup(conf->auth_secret);
char *statsd_ip = strdup(conf->statsd_ip);
char *host_name = strdup(conf->host_name);
char *r_host_addr = strdup(conf->r_host_addr);
Expand All @@ -181,6 +184,7 @@ void read_config(ksnet_cfg *conf, int port_param) {
CFG_SIMPLE_BOOL("port_inc_f", (cfg_bool_t*)&conf->port_inc_f),

CFG_SIMPLE_STR("key", &net_key),
CFG_SIMPLE_STR("auth_secret", &auth_secret),

CFG_SIMPLE_INT("tcp_port", &conf->tcp_port),
CFG_SIMPLE_BOOL("tcp_allow_f", (cfg_bool_t*)&conf->tcp_allow_f),
Expand Down Expand Up @@ -336,6 +340,7 @@ void read_config(ksnet_cfg *conf, int port_param) {
free(host_name);
free(statsd_ip);
free(net_key);
free(auth_secret);
free(filter);
free(vpn_ip);

Expand Down
1 change: 1 addition & 0 deletions src/config/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ typedef struct ksnet_cfg {
// Network
char network[KSN_BUFFER_SM_SIZE/2]; ///< Network
char net_key[KSN_BUFFER_SM_SIZE/2]; ///< Network key
char auth_secret[KSN_BUFFER_SM_SIZE/2]; ///< Auth secret

// Application name
char app_prompt[KSN_BUFFER_SM_SIZE/2]; ///< Application prompt
Expand Down
5 changes: 5 additions & 0 deletions src/config/opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ char ** ksnet_optRead(int argc, char **argv, ksnet_cfg *conf,
{ "r_tcp", no_argument, &conf->r_tcp_f, 1 },
{ "network", required_argument, 0, 'n' },
{ "key", required_argument, 0, 'e' },
{ "auth_secret", required_argument, 0, 'u' },
{ "tcp_allow", no_argument, &conf->tcp_allow_f, 1 },
{ "tcp_port", required_argument, 0, 'o' },
{ "l0_allow", no_argument, &conf->l0_allow_f, 1 },
Expand Down Expand Up @@ -290,6 +291,10 @@ char ** ksnet_optRead(int argc, char **argv, ksnet_cfg *conf,
// Kill application started in Daemon mode
conf->kflag = 1;
break;

case 'u'://NOTE: both a and s are already used, so aUth_secret
strncpy((char*)conf->auth_secret, optarg, KSN_BUFFER_SM_SIZE/2);
break;
}
}

Expand Down
Loading