Fix bug #152 - disable self-registering
This commit is contained in:
parent
472c489ae1
commit
998f5a57e2
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* uhub - A tiny ADC p2p connection hub
|
* uhub - A tiny ADC p2p connection hub
|
||||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
* Copyright (C) 2007-2011, Jan Vidar Krey
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -732,6 +732,8 @@ static int command_register(struct hub_info* hub, struct hub_user* user, struct
|
|||||||
data.password[MAX_PASS_LEN] = '\0';
|
data.password[MAX_PASS_LEN] = '\0';
|
||||||
data.credentials = auth_cred_user;
|
data.credentials = auth_cred_user;
|
||||||
|
|
||||||
|
if (hub->config->register_self)
|
||||||
|
{
|
||||||
if (acl_register_user(hub, &data))
|
if (acl_register_user(hub, &data))
|
||||||
{
|
{
|
||||||
sprintf(tmp, "User \"%s\" registered.", user->id.nick);
|
sprintf(tmp, "User \"%s\" registered.", user->id.nick);
|
||||||
@ -742,6 +744,11 @@ static int command_register(struct hub_info* hub, struct hub_user* user, struct
|
|||||||
sprintf(tmp, "Unable to register user \"%s\".", user->id.nick);
|
sprintf(tmp, "Unable to register user \"%s\".", user->id.nick);
|
||||||
return command_status(hub, user, cmd, tmp);
|
return command_status(hub, user, cmd, tmp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return command_status(hub, user, cmd, "You are not allowed to register.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int command_password(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
static int command_password(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd)
|
||||||
|
@ -108,6 +108,15 @@
|
|||||||
<since>0.1.1</since>
|
<since>0.1.1</since>
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option name="register_self" type="boolean" default="0">
|
||||||
|
<short>Allow users to register themselves on the hub.</short>
|
||||||
|
<description><![CDATA[
|
||||||
|
If this is enabled guests can register their nickname on the hub.
|
||||||
|
Otherwise only operators can register users.
|
||||||
|
]]></description>
|
||||||
|
<since>0.4.0</since>
|
||||||
|
</option>
|
||||||
|
|
||||||
<option name="obsolete_clients" type="boolean" default="0">
|
<option name="obsolete_clients" type="boolean" default="0">
|
||||||
<short>Support obsolete clients using a ADC protocol prior to 1.0</short>
|
<short>Support obsolete clients using a ADC protocol prior to 1.0</short>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
|
@ -11,6 +11,7 @@ void config_defaults(struct hub_config* config)
|
|||||||
config->show_banner_sys_info = 1;
|
config->show_banner_sys_info = 1;
|
||||||
config->max_users = 500;
|
config->max_users = 500;
|
||||||
config->registered_users_only = 0;
|
config->registered_users_only = 0;
|
||||||
|
config->register_self = 0;
|
||||||
config->obsolete_clients = 0;
|
config->obsolete_clients = 0;
|
||||||
config->chat_only = 0;
|
config->chat_only = 0;
|
||||||
config->chat_is_privileged = 0;
|
config->chat_is_privileged = 0;
|
||||||
@ -184,6 +185,16 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(key, "register_self"))
|
||||||
|
{
|
||||||
|
if (!apply_boolean(key, data, &config->register_self))
|
||||||
|
{
|
||||||
|
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(key, "obsolete_clients"))
|
if (!strcmp(key, "obsolete_clients"))
|
||||||
{
|
{
|
||||||
if (!apply_boolean(key, data, &config->obsolete_clients))
|
if (!apply_boolean(key, data, &config->obsolete_clients))
|
||||||
@ -502,7 +513,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
|||||||
if (!apply_string(key, data, &config->tls_require_redirect_addr, (char*) ""))
|
if (!apply_string(key, data, &config->tls_require_redirect_addr, (char*) ""))
|
||||||
{
|
{
|
||||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||||
LOG_ERROR("\"tls_require_redirect_addr\" (string), default=\"\"");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1062,6 +1072,9 @@ void dump_config(struct hub_config* config, int ignore_defaults)
|
|||||||
if (!ignore_defaults || config->registered_users_only != 0)
|
if (!ignore_defaults || config->registered_users_only != 0)
|
||||||
fprintf(stdout, "registered_users_only = %s\n", config->registered_users_only ? "yes" : "no");
|
fprintf(stdout, "registered_users_only = %s\n", config->registered_users_only ? "yes" : "no");
|
||||||
|
|
||||||
|
if (!ignore_defaults || config->register_self != 0)
|
||||||
|
fprintf(stdout, "register_self = %s\n", config->register_self ? "yes" : "no");
|
||||||
|
|
||||||
if (!ignore_defaults || config->obsolete_clients != 0)
|
if (!ignore_defaults || config->obsolete_clients != 0)
|
||||||
fprintf(stdout, "obsolete_clients = %s\n", config->obsolete_clients ? "yes" : "no");
|
fprintf(stdout, "obsolete_clients = %s\n", config->obsolete_clients ? "yes" : "no");
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ struct hub_config
|
|||||||
int show_banner_sys_info; /*<<< Show banner on connect (default: 1) */
|
int show_banner_sys_info; /*<<< Show banner on connect (default: 1) */
|
||||||
int max_users; /*<<< Maximum number of users allowed on the hub (default: 500) */
|
int max_users; /*<<< Maximum number of users allowed on the hub (default: 500) */
|
||||||
int registered_users_only; /*<<< Allow registered users only (default: 0) */
|
int registered_users_only; /*<<< Allow registered users only (default: 0) */
|
||||||
|
int register_self; /*<<< Allow users to register themselves on the hub. (default: 0) */
|
||||||
int obsolete_clients; /*<<< Support obsolete clients using a ADC protocol prior to 1.0 (default: 0) */
|
int obsolete_clients; /*<<< Support obsolete clients using a ADC protocol prior to 1.0 (default: 0) */
|
||||||
int chat_only; /*<<< Allow chat only operation on hub (default: 0) */
|
int chat_only; /*<<< Allow chat only operation on hub (default: 0) */
|
||||||
int chat_is_privileged; /*<<< Allow chat for operators and above only (default: 0) */
|
int chat_is_privileged; /*<<< Allow chat for operators and above only (default: 0) */
|
||||||
|
Loading…
Reference in New Issue
Block a user