|
|
@ -230,7 +230,7 @@ int total_pools, enabled_pools; |
|
|
|
enum pool_strategy pool_strategy = POOL_FAILOVER; |
|
|
|
enum pool_strategy pool_strategy = POOL_FAILOVER; |
|
|
|
int opt_rotate_period; |
|
|
|
int opt_rotate_period; |
|
|
|
static int total_urls, total_users, total_passes, total_userpasses; |
|
|
|
static int total_urls, total_users, total_passes, total_userpasses; |
|
|
|
static int json_array_index; |
|
|
|
static int json_array_index = -1; |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
static |
|
|
|
#ifndef HAVE_CURSES |
|
|
|
#ifndef HAVE_CURSES |
|
|
@ -557,6 +557,20 @@ struct pool *add_pool(void) |
|
|
|
return pool; |
|
|
|
return pool; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct pool* get_current_pool() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
while ((json_array_index + 1) > total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (json_array_index < 0) { |
|
|
|
|
|
|
|
if (!total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
return pools[total_pools - 1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pools[json_array_index]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Pool variant of test and set */ |
|
|
|
/* Pool variant of test and set */ |
|
|
|
static bool pool_tset(struct pool *pool, bool *var) |
|
|
|
static bool pool_tset(struct pool *pool, bool *var) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -755,11 +769,7 @@ static char *set_url(char *arg) |
|
|
|
|
|
|
|
|
|
|
|
static char *set_poolname(char *arg) |
|
|
|
static char *set_poolname(char *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct pool *pool; |
|
|
|
struct pool *pool = get_current_pool(); |
|
|
|
|
|
|
|
|
|
|
|
while ((json_array_index + 1) > total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
pool = pools[json_array_index]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Setting pool %i name to %s", pool->pool_no, arg); |
|
|
|
applog(LOG_DEBUG, "Setting pool %i name to %s", pool->pool_no, arg); |
|
|
|
opt_set_charp(arg, &pool->name); |
|
|
|
opt_set_charp(arg, &pool->name); |
|
|
@ -823,12 +833,7 @@ void remove_pool(struct pool *pool) |
|
|
|
|
|
|
|
|
|
|
|
static char *set_pool_state(char *arg) |
|
|
|
static char *set_pool_state(char *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct pool *pool; |
|
|
|
struct pool *pool = get_current_pool(); |
|
|
|
|
|
|
|
|
|
|
|
/* TODO: consider using j_a_i everywhere */ |
|
|
|
|
|
|
|
while ((json_array_index + 1) > total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
pool = pools[json_array_index]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_INFO, "Setting pool %s state to %s", get_pool_name(pool), arg); |
|
|
|
applog(LOG_INFO, "Setting pool %s state to %s", get_pool_name(pool), arg); |
|
|
|
if (strcmp(arg, "disabled") == 0) { |
|
|
|
if (strcmp(arg, "disabled") == 0) { |
|
|
@ -877,15 +882,8 @@ static char *set_quota(char *arg) |
|
|
|
|
|
|
|
|
|
|
|
static char *set_user(const char *arg) |
|
|
|
static char *set_user(const char *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct pool *pool; |
|
|
|
struct pool *pool = get_current_pool(); |
|
|
|
|
|
|
|
|
|
|
|
if (total_userpasses) |
|
|
|
|
|
|
|
return "Use only user + pass or userpass, but not both"; |
|
|
|
|
|
|
|
total_users++; |
|
|
|
|
|
|
|
if (total_users > total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pool = pools[total_users - 1]; |
|
|
|
|
|
|
|
opt_set_charp(arg, &pool->rpc_user); |
|
|
|
opt_set_charp(arg, &pool->rpc_user); |
|
|
|
|
|
|
|
|
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
@ -893,15 +891,8 @@ static char *set_user(const char *arg) |
|
|
|
|
|
|
|
|
|
|
|
static char *set_pass(const char *arg) |
|
|
|
static char *set_pass(const char *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct pool *pool; |
|
|
|
struct pool *pool = get_current_pool(); |
|
|
|
|
|
|
|
|
|
|
|
if (total_userpasses) |
|
|
|
|
|
|
|
return "Use only user + pass or userpass, but not both"; |
|
|
|
|
|
|
|
total_passes++; |
|
|
|
|
|
|
|
if (total_passes > total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pool = pools[total_passes - 1]; |
|
|
|
|
|
|
|
opt_set_charp(arg, &pool->rpc_pass); |
|
|
|
opt_set_charp(arg, &pool->rpc_pass); |
|
|
|
|
|
|
|
|
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
@ -909,16 +900,9 @@ static char *set_pass(const char *arg) |
|
|
|
|
|
|
|
|
|
|
|
static char *set_userpass(const char *arg) |
|
|
|
static char *set_userpass(const char *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct pool *pool; |
|
|
|
struct pool *pool = get_current_pool(); |
|
|
|
char *updup; |
|
|
|
char *updup; |
|
|
|
|
|
|
|
|
|
|
|
if (total_users || total_passes) |
|
|
|
|
|
|
|
return "Use only user + pass or userpass, but not both"; |
|
|
|
|
|
|
|
total_userpasses++; |
|
|
|
|
|
|
|
if (total_userpasses > total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pool = pools[total_userpasses - 1]; |
|
|
|
|
|
|
|
updup = strdup(arg); |
|
|
|
updup = strdup(arg); |
|
|
|
opt_set_charp(arg, &pool->rpc_userpass); |
|
|
|
opt_set_charp(arg, &pool->rpc_userpass); |
|
|
|
pool->rpc_user = strtok(updup, ":"); |
|
|
|
pool->rpc_user = strtok(updup, ":"); |
|
|
@ -926,18 +910,15 @@ static char *set_userpass(const char *arg) |
|
|
|
return "Failed to find : delimited user info"; |
|
|
|
return "Failed to find : delimited user info"; |
|
|
|
pool->rpc_pass = strtok(NULL, ":"); |
|
|
|
pool->rpc_pass = strtok(NULL, ":"); |
|
|
|
if (!pool->rpc_pass) |
|
|
|
if (!pool->rpc_pass) |
|
|
|
return "Failed to find : delimited pass info"; |
|
|
|
pool->rpc_pass = ""; |
|
|
|
|
|
|
|
|
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static char *set_pool_priority(char *arg) |
|
|
|
static char *set_pool_priority(char *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct pool *pool; |
|
|
|
struct pool *pool = get_current_pool(); |
|
|
|
|
|
|
|
|
|
|
|
while ((json_array_index + 1) > total_pools) |
|
|
|
|
|
|
|
add_pool(); |
|
|
|
|
|
|
|
pool = pools[json_array_index]; |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Setting pool %i priority to %s", pool->pool_no, arg); |
|
|
|
applog(LOG_DEBUG, "Setting pool %i priority to %s", pool->pool_no, arg); |
|
|
|
opt_set_intval(arg, &pool->prio); |
|
|
|
opt_set_intval(arg, &pool->prio); |
|
|
|
|
|
|
|
|
|
|
@ -1474,7 +1455,6 @@ static char *parse_config(json_t *config, bool fileconf, int parent_iteration) |
|
|
|
else if (json_is_object(json_array_get(val, n))) |
|
|
|
else if (json_is_object(json_array_get(val, n))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
err = parse_config(json_array_get(val, n), false, n); |
|
|
|
err = parse_config(json_array_get(val, n), false, n); |
|
|
|
json_array_index = parent_iteration; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if ((opt->type & OPT_NOARG) && json_is_boolean(val)) { |
|
|
|
} else if ((opt->type & OPT_NOARG) && json_is_boolean(val)) { |
|
|
@ -1541,7 +1521,7 @@ static char *load_config(const char *arg, void __maybe_unused *unused) |
|
|
|
|
|
|
|
|
|
|
|
/* Parse the config now, so we can override it. That can keep pointers
|
|
|
|
/* Parse the config now, so we can override it. That can keep pointers
|
|
|
|
* so don't free config object. */ |
|
|
|
* so don't free config object. */ |
|
|
|
return parse_config(config, true, 0); |
|
|
|
return parse_config(config, true, -1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static char *set_default_config(const char *arg) |
|
|
|
static char *set_default_config(const char *arg) |
|
|
|