commit
c26e8aaefe
|
@ -13,6 +13,15 @@
|
||||||
#
|
#
|
||||||
plugin /usr/lib/uhub/mod_auth_sqlite.so "file=/etc/uhub/users.db"
|
plugin /usr/lib/uhub/mod_auth_sqlite.so "file=/etc/uhub/users.db"
|
||||||
|
|
||||||
|
# Topic commands.
|
||||||
|
# Note: "topic" == "hub description" (as configured in uhub.conf)
|
||||||
|
#
|
||||||
|
# !topic - change the topic (op required)
|
||||||
|
# !showtopic - show the topic
|
||||||
|
# !resettopic - reset the topic to the default (op required)
|
||||||
|
#
|
||||||
|
# This plugins takes no parameters.
|
||||||
|
#plugin /usr/lib/uhub/mod_topic.so
|
||||||
|
|
||||||
# Log file writer
|
# Log file writer
|
||||||
#
|
#
|
||||||
|
@ -22,7 +31,8 @@ plugin /usr/lib/uhub/mod_auth_sqlite.so "file=/etc/uhub/users.db"
|
||||||
plugin /usr/lib/uhub/mod_logging.so "file=/var/log/uhub.log"
|
plugin /usr/lib/uhub/mod_logging.so "file=/var/log/uhub.log"
|
||||||
|
|
||||||
# A simple example plugin
|
# A simple example plugin
|
||||||
# plugin /usr/lib/uhub/mod_example.so
|
#plugin /usr/lib/uhub/mod_example.so
|
||||||
|
|
||||||
# A plugin sending a welcome message.
|
# A plugin sending a welcome message.
|
||||||
#
|
#
|
||||||
# This plugin provides the following commands:
|
# This plugin provides the following commands:
|
||||||
|
|
|
@ -104,11 +104,11 @@ msg_auth_invalid_password = Password is wrong
|
||||||
msg_auth_user_not_found = User not found in password database
|
msg_auth_user_not_found = User not found in password database
|
||||||
msg_user_share_size_low = User is not sharing enough
|
msg_user_share_size_low = User is not sharing enough
|
||||||
msg_user_share_size_high = User is sharing too much
|
msg_user_share_size_high = User is sharing too much
|
||||||
msg_user_slots_low = User have too few upload slots
|
msg_user_slots_low = User has too few upload slots
|
||||||
msg_user_slots_high = User have too many upload slots
|
msg_user_slots_high = User has too many upload slots
|
||||||
msg_user_hub_limit_low = User is on too few hubs
|
msg_user_hub_limit_low = User is on too few hubs
|
||||||
msg_user_hub_limit_high = User is on too many hubs
|
msg_user_hub_limit_high = User is on too many hubs
|
||||||
msg_error_no_memory = No memory
|
msg_error_no_memory = Out of memory
|
||||||
msg_user_flood_chat = Chat flood detected, messages are dropped.
|
msg_user_flood_chat = Chat flood detected, messages are dropped.
|
||||||
msg_user_flood_connect = Connect flood detected, connection refused.
|
msg_user_flood_connect = Connect flood detected, connection refused.
|
||||||
msg_user_flood_search = Search flood detected, search is stopped.
|
msg_user_flood_search = Search flood detected, search is stopped.
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
<option name="server_bind_addr" type="string" default="any">
|
<option name="server_bind_addr" type="string" default="any">
|
||||||
<check regexp="(\d\.\d\.\d\.\d\)|(any)|(loopback)|(.*)" /><!-- FIXME: add better IPv6 regexp in the future! -->
|
<check regexp="[\x:.]+|any|loopback" />
|
||||||
<short>Server bind address</short>
|
<short>Server bind address</short>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
Specify the IP address the local hub should bind to. This can be an IPv4 or IPv6 address, or one of the special addresses "any" or "loopback". <br />
|
Specify the IP address the local hub should bind to. This can be an IPv4 or IPv6 address, or one of the special addresses "any" or "loopback". <br />
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
<option name="server_alt_ports" type="string" default="">
|
<option name="server_alt_ports" type="string" default="">
|
||||||
<check regexp="((\d+)(,(\d+))*)?" />
|
<check regexp="\d+(,\d+)*" />
|
||||||
<short>Comma separated list of alternative ports to listen to</short>
|
<short>Comma separated list of alternative ports to listen to</short>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
In addition to the server_port the hub can listen to a list of alternative ports.
|
In addition to the server_port the hub can listen to a list of alternative ports.
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
<option name="redirect_addr" type="string" default="">
|
<option name="redirect_addr" type="string" default="">
|
||||||
<check regexp="(adc|adcs|dchub)://.*" />
|
<check regexp="(adcs?|dchub)://.*" />
|
||||||
<short>A common hub redirect address.</short>
|
<short>A common hub redirect address.</short>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
This is the redirect address used when the hub wants to redirect a client for not fulfilling some requirements.
|
This is the redirect address used when the hub wants to redirect a client for not fulfilling some requirements.
|
||||||
|
@ -419,7 +419,7 @@
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
<option name="tls_require_redirect_addr" type="string" default="">
|
<option name="tls_require_redirect_addr" type="string" default="">
|
||||||
<check regexp="(adc|adcs|dchub)://.*" />
|
<check regexp="(adcs?|dchub)://.*" />
|
||||||
<short>A redirect address in case a client connects using "adc://" when "adcs://" is required.</short>
|
<short>A redirect address in case a client connects using "adc://" when "adcs://" is required.</short>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
This is the redirect address used when the hub wants to redirect a client for not using ADCS.
|
This is the redirect address used when the hub wants to redirect a client for not using ADCS.
|
||||||
|
@ -432,7 +432,7 @@
|
||||||
<option name="tls_certificate" type="file" default="">
|
<option name="tls_certificate" type="file" default="">
|
||||||
<short>Certificate file</short>
|
<short>Certificate file</short>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
Path to a TLS/SSL certificate (PEM format).
|
Path to a TLS/SSL certificate or certificate chain (PEM format).
|
||||||
]]></description>
|
]]></description>
|
||||||
<since>0.3.0</since>
|
<since>0.3.0</since>
|
||||||
</option>
|
</option>
|
||||||
|
|
|
@ -27,7 +27,7 @@ enum status_message
|
||||||
status_msg_hub_registered_users_only = -3, /* hub is for registered users only */
|
status_msg_hub_registered_users_only = -3, /* hub is for registered users only */
|
||||||
status_msg_inf_error_nick_missing = -4, /* no nickname given */
|
status_msg_inf_error_nick_missing = -4, /* no nickname given */
|
||||||
status_msg_inf_error_nick_multiple = -5, /* multiple nicknames given */
|
status_msg_inf_error_nick_multiple = -5, /* multiple nicknames given */
|
||||||
status_msg_inf_error_nick_invalid = -6, /* generic/unkown */
|
status_msg_inf_error_nick_invalid = -6, /* generic/unknown */
|
||||||
status_msg_inf_error_nick_long = -7, /* nickname too long */
|
status_msg_inf_error_nick_long = -7, /* nickname too long */
|
||||||
status_msg_inf_error_nick_short = -8, /* nickname too short */
|
status_msg_inf_error_nick_short = -8, /* nickname too short */
|
||||||
status_msg_inf_error_nick_spaces = -9, /* nickname cannot start with spaces */
|
status_msg_inf_error_nick_spaces = -9, /* nickname cannot start with spaces */
|
||||||
|
@ -50,8 +50,8 @@ enum status_message
|
||||||
status_msg_user_share_size_high = -41, /* User is sharing too much. */
|
status_msg_user_share_size_high = -41, /* User is sharing too much. */
|
||||||
status_msg_user_slots_low = -42, /* User has too few slots open. */
|
status_msg_user_slots_low = -42, /* User has too few slots open. */
|
||||||
status_msg_user_slots_high = -43, /* User has too many slots open. */
|
status_msg_user_slots_high = -43, /* User has too many slots open. */
|
||||||
status_msg_user_hub_limit_low = -44, /* Use is on too few hubs. */
|
status_msg_user_hub_limit_low = -44, /* User is on too few hubs. */
|
||||||
status_msg_user_hub_limit_high = -45, /* Use is on too many hubs. */
|
status_msg_user_hub_limit_high = -45, /* User is on too many hubs. */
|
||||||
|
|
||||||
status_msg_proto_no_common_hash = -50, /* No common hash algorithms */
|
status_msg_proto_no_common_hash = -50, /* No common hash algorithms */
|
||||||
status_msg_proto_obsolete_adc0 = -51, /* Client is using an obsolete protocol version */
|
status_msg_proto_obsolete_adc0 = -51, /* Client is using an obsolete protocol version */
|
||||||
|
|
|
@ -178,7 +178,7 @@ static int net_connect_job_check(struct net_connect_job* job)
|
||||||
int af = job->addr.ss_family;
|
int af = job->addr.ss_family;
|
||||||
enum net_connect_status status;
|
enum net_connect_status status;
|
||||||
|
|
||||||
int ret = net_connect(net_con_get_sd(con), (struct sockaddr*) &job->addr, af == AF_INET ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
|
int ret = net_connect(net_con_get_sd(con), (struct sockaddr*) &job->addr, af == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6));
|
||||||
if (ret == 0 || (ret == -1 && net_error() == EISCONN))
|
if (ret == 0 || (ret == -1 && net_error() == EISCONN))
|
||||||
{
|
{
|
||||||
LOG_TRACE("net_connect_job_check(): Socket connected!");
|
LOG_TRACE("net_connect_job_check(): Socket connected!");
|
||||||
|
|
|
@ -127,7 +127,7 @@ extern void net_ssl_context_destroy(struct ssl_context_handle* ctx_)
|
||||||
int ssl_load_certificate(struct ssl_context_handle* ctx_, const char* pem_file)
|
int ssl_load_certificate(struct ssl_context_handle* ctx_, const char* pem_file)
|
||||||
{
|
{
|
||||||
struct net_context_openssl* ctx = (struct net_context_openssl*) ctx_;
|
struct net_context_openssl* ctx = (struct net_context_openssl*) ctx_;
|
||||||
if (SSL_CTX_use_certificate_file(ctx->ssl_ctx, pem_file, SSL_FILETYPE_PEM) < 0)
|
if (SSL_CTX_use_certificate_chain_file(ctx->ssl_ctx, pem_file) < 0)
|
||||||
{
|
{
|
||||||
LOG_ERROR("SSL_CTX_use_certificate_file: %s", ERR_error_string(ERR_get_error(), NULL));
|
LOG_ERROR("SSL_CTX_use_certificate_file: %s", ERR_error_string(ERR_get_error(), NULL));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -302,6 +302,7 @@ void net_ssl_destroy(struct net_connection* con)
|
||||||
{
|
{
|
||||||
struct net_ssl_openssl* handle = get_handle(con);
|
struct net_ssl_openssl* handle = get_handle(con);
|
||||||
SSL_free(handle->ssl);
|
SSL_free(handle->ssl);
|
||||||
|
hub_free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void net_ssl_callback(struct net_connection* con, int events)
|
void net_ssl_callback(struct net_connection* con, int events)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
struct topic_plugin_data
|
struct topic_plugin_data
|
||||||
{
|
{
|
||||||
struct plugin_command_handle* topic;
|
struct plugin_command_handle* topic;
|
||||||
struct plugin_command_handle* cleartopic;
|
struct plugin_command_handle* resettopic;
|
||||||
struct plugin_command_handle* showtopic;
|
struct plugin_command_handle* showtopic;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,19 +33,20 @@ static int command_topic_handler(struct plugin_handle* plugin, struct plugin_use
|
||||||
{
|
{
|
||||||
struct cbuffer* buf = cbuf_create(128);
|
struct cbuffer* buf = cbuf_create(128);
|
||||||
struct plugin_command_arg_data* arg = plugin->hub.command_arg_next(plugin, cmd, plugin_cmd_arg_type_string);
|
struct plugin_command_arg_data* arg = plugin->hub.command_arg_next(plugin, cmd, plugin_cmd_arg_type_string);
|
||||||
|
char* topic = arg ? arg->data.string : "";
|
||||||
|
|
||||||
plugin->hub.set_description(plugin, arg ? arg->data.string : NULL);
|
plugin->hub.set_description(plugin, topic);
|
||||||
cbuf_append_format(buf, "*** %s: Topic set to \"%s\"", cmd->prefix, arg->data.string);
|
cbuf_append_format(buf, "*** %s: Topic set to \"%s\"", cmd->prefix, topic);
|
||||||
plugin->hub.send_message(plugin, user, cbuf_get(buf));
|
plugin->hub.send_message(plugin, user, cbuf_get(buf));
|
||||||
cbuf_destroy(buf);
|
cbuf_destroy(buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int command_cleartopic_handler(struct plugin_handle* plugin, struct plugin_user* user, struct plugin_command* cmd)
|
static int command_resettopic_handler(struct plugin_handle* plugin, struct plugin_user* user, struct plugin_command* cmd)
|
||||||
{
|
{
|
||||||
struct cbuffer* buf = cbuf_create(128);
|
struct cbuffer* buf = cbuf_create(128);
|
||||||
plugin->hub.set_description(plugin, NULL);
|
plugin->hub.set_description(plugin, NULL);
|
||||||
cbuf_append_format(buf, "*** %s: Topic cleared.", cmd->prefix);
|
cbuf_append_format(buf, "*** %s: Topic reset.", cmd->prefix);
|
||||||
plugin->hub.send_message(plugin, user, cbuf_get(buf));
|
plugin->hub.send_message(plugin, user, cbuf_get(buf));
|
||||||
cbuf_destroy(buf);
|
cbuf_destroy(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -67,17 +68,17 @@ int plugin_register(struct plugin_handle* plugin, const char* config)
|
||||||
struct topic_plugin_data* data = (struct topic_plugin_data*) hub_malloc(sizeof(struct topic_plugin_data));
|
struct topic_plugin_data* data = (struct topic_plugin_data*) hub_malloc(sizeof(struct topic_plugin_data));
|
||||||
|
|
||||||
data->topic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
|
data->topic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
|
||||||
data->cleartopic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
|
data->resettopic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
|
||||||
data->showtopic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
|
data->showtopic = (struct plugin_command_handle*) hub_malloc_zero(sizeof(struct plugin_command_handle));
|
||||||
|
|
||||||
PLUGIN_INITIALIZE(plugin, "Topic plugin", "1.0", "Add commands for changing the hub topic (description)");
|
PLUGIN_INITIALIZE(plugin, "Topic plugin", "1.0", "Add commands for changing the hub topic (description)");
|
||||||
|
|
||||||
PLUGIN_COMMAND_INITIALIZE(data->topic, (void*) data, "topic", "+m", auth_cred_operator, command_topic_handler, "Set new topic");
|
PLUGIN_COMMAND_INITIALIZE(data->topic, (void*) data, "topic", "+m", auth_cred_operator, command_topic_handler, "Set new topic");
|
||||||
PLUGIN_COMMAND_INITIALIZE(data->cleartopic, (void*) data, "cleartopic", "", auth_cred_operator, command_cleartopic_handler, "Clear the current topic");
|
PLUGIN_COMMAND_INITIALIZE(data->resettopic, (void*) data, "resettopic", "", auth_cred_operator, command_resettopic_handler, "Set topic to default");
|
||||||
PLUGIN_COMMAND_INITIALIZE(data->showtopic, (void*) data, "showtopic", "", auth_cred_guest, command_showtopic_handler, "Shows the current topic");
|
PLUGIN_COMMAND_INITIALIZE(data->showtopic, (void*) data, "showtopic", "", auth_cred_guest, command_showtopic_handler, "Shows the current topic");
|
||||||
|
|
||||||
plugin->hub.command_add(plugin, data->topic);
|
plugin->hub.command_add(plugin, data->topic);
|
||||||
plugin->hub.command_add(plugin, data->cleartopic);
|
plugin->hub.command_add(plugin, data->resettopic);
|
||||||
plugin->hub.command_add(plugin, data->showtopic);
|
plugin->hub.command_add(plugin, data->showtopic);
|
||||||
plugin->ptr = data;
|
plugin->ptr = data;
|
||||||
|
|
||||||
|
@ -90,10 +91,10 @@ int plugin_unregister(struct plugin_handle* plugin)
|
||||||
struct topic_plugin_data* data = (struct topic_plugin_data*) plugin->ptr;
|
struct topic_plugin_data* data = (struct topic_plugin_data*) plugin->ptr;
|
||||||
|
|
||||||
plugin->hub.command_del(plugin, data->topic);
|
plugin->hub.command_del(plugin, data->topic);
|
||||||
plugin->hub.command_del(plugin, data->cleartopic);
|
plugin->hub.command_del(plugin, data->resettopic);
|
||||||
plugin->hub.command_del(plugin, data->showtopic);
|
plugin->hub.command_del(plugin, data->showtopic);
|
||||||
hub_free(data->topic);
|
hub_free(data->topic);
|
||||||
hub_free(data->cleartopic);
|
hub_free(data->resettopic);
|
||||||
hub_free(data->showtopic);
|
hub_free(data->showtopic);
|
||||||
hub_free(data);
|
hub_free(data);
|
||||||
plugin->ptr = NULL;
|
plugin->ptr = NULL;
|
||||||
|
|
Loading…
Reference in New Issue