Compare commits
7 Commits
0.3.x-stab
...
plugin_wor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa26052479 | ||
|
|
ccaa4860b4 | ||
|
|
7218011449 | ||
|
|
baeba01835 | ||
|
|
07d4e4470c | ||
|
|
ed53034ad5 | ||
|
|
fc8965f1c5 |
20
ChangeLog
20
ChangeLog
@@ -1,23 +1,3 @@
|
||||
0.3.3:
|
||||
- Fix SSL/TLS related memory leak.
|
||||
- Fix 100% CPU issue with SSL connections.
|
||||
- Added option to redirect from adc:// to adcs:// if tls is required.
|
||||
- Added more informative error messages for the configuration file parser.
|
||||
- Made sure logs can be rotated by sending a SIGHUP to the hub
|
||||
- Fix bug #139: Unable to use TLS - due to not handling quotes around configuration strings.
|
||||
- Fix bug #136 - !broadcast does not report status back to to sender.
|
||||
|
||||
|
||||
0.3.2:
|
||||
- Fixed bugs in the kqueue network backend (OSX/BSD)
|
||||
- Rewrote the configuration backend code.
|
||||
- Added support for escaping characters in the configuration files.
|
||||
- Updated the !broadcast command to send private messages instead of main chat messages.
|
||||
- Adding support for redirecting clients to other hubs when they fail to log in.
|
||||
- Fix some out of memory related crashes.
|
||||
- Fixed minor memory leaks.
|
||||
|
||||
|
||||
0.3.1:
|
||||
- Fixed bug where !getip did not work.
|
||||
- Added flood control configuration options.
|
||||
|
||||
28
GNUmakefile
28
GNUmakefile
@@ -10,8 +10,9 @@ LD := $(CC)
|
||||
MV := mv
|
||||
RANLIB := ranlib
|
||||
CFLAGS += -pipe -Wall
|
||||
USE_SSL ?= YES
|
||||
USE_SSL ?= NO
|
||||
USE_BIGENDIAN ?= AUTO
|
||||
USE_PLUGINS ?= YES
|
||||
BITS ?= AUTO
|
||||
SILENT ?= YES
|
||||
TERSE ?= NO
|
||||
@@ -42,6 +43,7 @@ UHUB_PREFIX ?= c:/uhub/
|
||||
CFLAGS += -mno-cygwin
|
||||
LDFLAGS += -mno-cygwin
|
||||
BIN_EXT ?= .exe
|
||||
USE_PLUGINS := NO
|
||||
else
|
||||
DESTDIR ?= /
|
||||
UHUB_CONF_DIR ?= $(DESTDIR)/etc/uhub
|
||||
@@ -118,6 +120,12 @@ CFLAGS += -DSSL_SUPPORT
|
||||
LDLIBS += -lssl
|
||||
endif
|
||||
|
||||
ifeq ($(USE_PLUGINS),YES)
|
||||
CFLAGS += -DPLUGIN_SUPPORT
|
||||
LDLIBS += -ldl
|
||||
endif
|
||||
|
||||
|
||||
GIT_VERSION=$(shell git describe --tags 2>/dev/null || echo "")
|
||||
GIT_REVISION=$(shell git show --abbrev-commit 2>/dev/null | head -n 1 | cut -f 2 -d " " || echo "")
|
||||
OLD_REVISION=$(shell grep GIT_REVISION revision.h 2>/dev/null | cut -f 3 -d " " | tr -d "\"")
|
||||
@@ -138,6 +146,8 @@ libuhub_SOURCES := \
|
||||
src/core/route.c \
|
||||
src/core/user.c \
|
||||
src/core/usermanager.c \
|
||||
src/core/plugininvoke.c \
|
||||
src/core/pluginloader.c \
|
||||
src/network/backend.c \
|
||||
src/network/connection.c \
|
||||
src/network/epoll.c \
|
||||
@@ -183,6 +193,13 @@ autotest_SOURCES := \
|
||||
|
||||
autotest_OBJECTS = autotest.o
|
||||
|
||||
plugin_example_SOURCES := src/plugins/mod_example.c
|
||||
plugin_example_TARGET := $(plugin_example_SOURCES:.c=.so)
|
||||
|
||||
plugin_logging_SOURCES := src/plugins/mod_logging.c
|
||||
plugin_logging_TARGET := $(plugin_example_SOURCES:.c=.so)
|
||||
|
||||
|
||||
# Source to objects
|
||||
libuhub_OBJECTS := $(libuhub_SOURCES:.c=.o)
|
||||
libadc_client_OBJECTS := $(libadc_client_SOURCES:.c=.o)
|
||||
@@ -193,14 +210,23 @@ adcrush_OBJECTS := $(adcrush_SOURCES:.c=.o)
|
||||
admin_OBJECTS := $(admin_SOURCES:.c=.o)
|
||||
|
||||
all_OBJECTS := $(libuhub_OBJECTS) $(uhub_OBJECTS) $(adcrush_OBJECTS) $(autotest_OBJECTS) $(admin_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
|
||||
all_plugins := $(plugin_example_TARGET) $(plugin_logging_TARGET)
|
||||
|
||||
uhub_BINARY=uhub$(BIN_EXT)
|
||||
adcrush_BINARY=adcrush$(BIN_EXT)
|
||||
admin_BINARY=uhub-admin$(BIN_EXT)
|
||||
autotest_BINARY=autotest/test$(BIN_EXT)
|
||||
|
||||
ifeq ($(USE_PLUGINS),YES)
|
||||
all_OBJECTS += $(plugins)
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: revision.h.tmp
|
||||
|
||||
%.so: %.c
|
||||
$(MSG_CC) $(CC) -shared -fPIC -o $@ $< $(CFLAGS)
|
||||
|
||||
%.o: %.c version.h revision.h
|
||||
$(MSG_CC) $(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
|
||||
12
debian/changelog
vendored
12
debian/changelog
vendored
@@ -1,15 +1,3 @@
|
||||
uhub (0.3.3-1) unstable; urgency=low
|
||||
|
||||
* Updated upstream version.
|
||||
|
||||
-- Jan Vidar Krey <janvidar@extatic.org> Tue 24 Aug 2010 18:00:00 +0200
|
||||
|
||||
uhub (0.3.2-1) unstable; urgency=low
|
||||
|
||||
* Updated upstream version.
|
||||
|
||||
-- Jan Vidar Krey <janvidar@extatic.org> Mon 30 May 2010 18:00:00 +0200
|
||||
|
||||
uhub (0.3.1-1) unstable; urgency=low
|
||||
|
||||
* Updated version number.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Summary: High performance ADC p2p hub.
|
||||
Name: uhub
|
||||
Version: 0.3.3
|
||||
Version: 0.3.1
|
||||
Release: 3
|
||||
License: GPLv3
|
||||
Group: Networking/File transfer
|
||||
|
||||
@@ -119,7 +119,6 @@ void sid_pool_destroy(struct sid_pool* pool)
|
||||
|
||||
sid_t sid_alloc(struct sid_pool* pool, struct hub_user* user)
|
||||
{
|
||||
sid_t n;
|
||||
if (pool->count >= (pool->max - pool->min))
|
||||
{
|
||||
#ifdef DEBUG_SID
|
||||
@@ -128,7 +127,7 @@ sid_t sid_alloc(struct sid_pool* pool, struct hub_user* user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = (++pool->count);
|
||||
sid_t n = (++pool->count);
|
||||
for (; (pool->map[n % pool->max]); n++) ;
|
||||
|
||||
#ifdef DEBUG_SID
|
||||
|
||||
@@ -426,12 +426,11 @@ static int command_broadcast(struct hub_info* hub, struct hub_user* user, struct
|
||||
char from_sid[5];
|
||||
char buffer[128];
|
||||
size_t recipients = 0;
|
||||
struct hub_user* target;
|
||||
|
||||
memcpy(from_sid, sid_to_string(user->id.sid), sizeof(from_sid));
|
||||
memcpy(pm_flag + 2, from_sid, sizeof(from_sid));
|
||||
|
||||
target = (struct hub_user*) list_get_first(hub->users->list);
|
||||
struct hub_user* target = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (target)
|
||||
{
|
||||
if (target != user)
|
||||
@@ -453,7 +452,6 @@ static int command_broadcast(struct hub_info* hub, struct hub_user* user, struct
|
||||
}
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "*** %s: Delivered to " PRINTF_SIZE_T " user%s", cmd->prefix, recipients, (recipients != 1 ? "s" : ""));
|
||||
send_message(hub, user, buffer);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ static int config_parse_line(char* line, int line_count, void* ptr_data)
|
||||
|
||||
key = strip_white_space(key);
|
||||
data = strip_white_space(data);
|
||||
data = strip_off_quotes(data);
|
||||
|
||||
if (!*key || !*data)
|
||||
{
|
||||
|
||||
@@ -125,7 +125,6 @@ sub write_c_impl_apply(@)
|
||||
my $min;
|
||||
my $max;
|
||||
my $regexp;
|
||||
my $expect = "";
|
||||
|
||||
if (defined $p)
|
||||
{
|
||||
@@ -142,21 +141,14 @@ sub write_c_impl_apply(@)
|
||||
|
||||
print GENIMPL "\tif (!strcmp(key, \"" . $name . "\"))\n\t{\n";
|
||||
|
||||
$expect = "\\\"$name\\\"";
|
||||
|
||||
if ($type eq "int")
|
||||
{
|
||||
$expect .= " (integer)";
|
||||
$expect .= ", default=" . $default;
|
||||
|
||||
if (defined $min)
|
||||
{
|
||||
$expect .= ", min=" . $min;
|
||||
print GENIMPL "\t\tmin = $min;\n"
|
||||
}
|
||||
if (defined $max)
|
||||
{
|
||||
$expect .= ", max=" . $max;
|
||||
print GENIMPL "\t\tmax = $max;\n"
|
||||
}
|
||||
|
||||
@@ -186,27 +178,16 @@ sub write_c_impl_apply(@)
|
||||
}
|
||||
elsif ($type eq "boolean")
|
||||
{
|
||||
$expect .= " (boolean)";
|
||||
$expect .= ", default=" . $default;
|
||||
print GENIMPL "\t\tif (!apply_boolean(key, data, &config->$name))\n";
|
||||
}
|
||||
elsif ($type =~ /(string|file|message)/)
|
||||
{
|
||||
$expect .= " (" . $type . ")";
|
||||
$expect .= ", default=\\\"" . $default . "\\\"";
|
||||
print GENIMPL "\t\tif (!apply_string(key, data, &config->$name, (char*) \"\"))\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$expect = " is unknown.";
|
||||
}
|
||||
|
||||
print GENIMPL "\t\t{\n" .
|
||||
"\t\t\tLOG_ERROR(\"Configuration parse error on line %d\", line_count);\n";
|
||||
|
||||
print GENIMPL "\t\t\tLOG_ERROR(\"" . $expect . "\");\n" if ($expect ne "");
|
||||
|
||||
print GENIMPL "\t\t\treturn -1;\n" .
|
||||
"\t\t\tLOG_ERROR(\"Configuration parse error on line %d\", line_count);\n" .
|
||||
"\t\t\treturn -1;\n" .
|
||||
"\t\t}\n" .
|
||||
"\t\treturn 0;\n" .
|
||||
"\t}\n\n";
|
||||
|
||||
@@ -417,17 +417,6 @@
|
||||
<since>0.3.0</since>
|
||||
</option>
|
||||
|
||||
<option name="tls_require_redirect_addr" type="string" default="">
|
||||
<check regexp="(adc|adcs|dchub)://.*" />
|
||||
<short>A redirect address in case a client connects using "adc://" when "adcs://" is required.</short>
|
||||
<description><![CDATA[
|
||||
This is the redirect address used when the hub wants to redirect a client for not using ADCS.
|
||||
For instance a hub at adc://adc.example.com might redirect to adcs://adc.example.com
|
||||
]]></description>
|
||||
<since>0.3.3</since>
|
||||
</option>
|
||||
|
||||
|
||||
<option name="tls_certificate" type="file" default="">
|
||||
<short>Certificate file</short>
|
||||
<description><![CDATA[
|
||||
@@ -501,6 +490,19 @@
|
||||
]]></example>
|
||||
</option>
|
||||
|
||||
<option name="file_plugins" type="file" default="">
|
||||
<short>Plugin configuration file</short>
|
||||
<description><![CDATA[
|
||||
Plugin configuration file.
|
||||
]]></description>
|
||||
<since>0.3.3</since>
|
||||
<example><![CDATA[
|
||||
<p>
|
||||
file_plugins = "/etc/uhub/plugins.conf"
|
||||
</p>
|
||||
]]></example>
|
||||
</option>
|
||||
|
||||
<option name="msg_hub_full" type="message" default="Hub is full" >
|
||||
<description><![CDATA[This will be sent if the hub is full]]></description>
|
||||
<since>0.2.0</since>
|
||||
|
||||
@@ -42,12 +42,12 @@ void config_defaults(struct hub_config* config)
|
||||
config->flood_ctl_extras = 0;
|
||||
config->tls_enable = 0;
|
||||
config->tls_require = 0;
|
||||
config->tls_require_redirect_addr = hub_strdup("");
|
||||
config->tls_certificate = hub_strdup("");
|
||||
config->tls_private_key = hub_strdup("");
|
||||
config->file_motd = hub_strdup("");
|
||||
config->file_acl = hub_strdup("");
|
||||
config->file_rules = hub_strdup("");
|
||||
config->file_plugins = hub_strdup("");
|
||||
config->msg_hub_full = hub_strdup("Hub is full");
|
||||
config->msg_hub_disabled = hub_strdup("Hub is disabled");
|
||||
config->msg_hub_registered_users_only = hub_strdup("Hub is for registered users only");
|
||||
@@ -96,7 +96,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->hub_enabled))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"hub_enabled\" (boolean), default=1");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -107,7 +106,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->server_port, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"server_port\" (integer), default=1511");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -118,7 +116,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->server_bind_addr, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"server_bind_addr\" (string), default=\"any\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -129,7 +126,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->server_listen_backlog, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"server_listen_backlog\" (integer), default=50");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -140,7 +136,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->server_alt_ports, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"server_alt_ports\" (string), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -151,7 +146,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->show_banner))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"show_banner\" (boolean), default=1");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -162,7 +156,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->show_banner_sys_info))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"show_banner_sys_info\" (boolean), default=1");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -175,7 +168,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->max_users, &min, &max))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"max_users\" (integer), default=500, min=1, max=1048576");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -186,7 +178,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->registered_users_only))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"registered_users_only\" (boolean), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -197,7 +188,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->obsolete_clients))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"obsolete_clients\" (boolean), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -208,7 +198,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->chat_only))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"chat_only\" (boolean), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -219,7 +208,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->chat_is_privileged))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"chat_is_privileged\" (boolean), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -230,7 +218,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->hub_name, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"hub_name\" (string), default=\"uhub\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -241,7 +228,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->hub_description, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"hub_description\" (string), default=\"no description\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -252,7 +238,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->redirect_addr, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"redirect_addr\" (string), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -263,7 +248,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->max_recv_buffer, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"max_recv_buffer\" (integer), default=4096");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -274,7 +258,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->max_send_buffer, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"max_send_buffer\" (integer), default=131072");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -285,7 +268,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->max_send_buffer_soft, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"max_send_buffer_soft\" (integer), default=98304");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -296,7 +278,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->low_bandwidth_mode))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"low_bandwidth_mode\" (boolean), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -307,7 +288,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->max_chat_history, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"max_chat_history\" (integer), default=20");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -318,7 +298,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->max_logout_log, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"max_logout_log\" (integer), default=20");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -329,7 +308,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_max_hubs_user, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_max_hubs_user\" (integer), default=10");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -340,7 +318,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_max_hubs_reg, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_max_hubs_reg\" (integer), default=10");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -351,7 +328,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_max_hubs_op, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_max_hubs_op\" (integer), default=10");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -362,7 +338,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_max_hubs, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_max_hubs\" (integer), default=25");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -373,7 +348,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_min_hubs_user, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_min_hubs_user\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -384,7 +358,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_min_hubs_reg, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_min_hubs_reg\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -395,7 +368,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_min_hubs_op, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_min_hubs_op\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -407,7 +379,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_min_share, &min, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_min_share\" (integer), default=0, min=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -418,7 +389,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_max_share, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_max_share\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -429,7 +399,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_min_slots, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_min_slots\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -440,7 +409,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->limit_max_slots, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"limit_max_slots\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -453,7 +421,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->flood_ctl_interval, &min, &max))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"flood_ctl_interval\" (integer), default=0, min=1, max=60");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -464,7 +431,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->flood_ctl_chat, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"flood_ctl_chat\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -475,7 +441,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->flood_ctl_connect, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"flood_ctl_connect\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -486,7 +451,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->flood_ctl_search, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"flood_ctl_search\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -497,7 +461,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->flood_ctl_update, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"flood_ctl_update\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -508,7 +471,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_integer(key, data, &config->flood_ctl_extras, 0, 0))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"flood_ctl_extras\" (integer), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -519,7 +481,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->tls_enable))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"tls_enable\" (boolean), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -530,18 +491,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_boolean(key, data, &config->tls_require))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"tls_require\" (boolean), default=0");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(key, "tls_require_redirect_addr"))
|
||||
{
|
||||
if (!apply_string(key, data, &config->tls_require_redirect_addr, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"tls_require_redirect_addr\" (string), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -552,7 +501,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->tls_certificate, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"tls_certificate\" (file), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -563,7 +511,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->tls_private_key, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"tls_private_key\" (file), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -574,7 +521,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->file_motd, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"file_motd\" (file), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -585,7 +531,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->file_acl, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"file_acl\" (file), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -596,7 +541,16 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->file_rules, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"file_rules\" (file), default=\"\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(key, "file_plugins"))
|
||||
{
|
||||
if (!apply_string(key, data, &config->file_plugins, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -607,7 +561,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_hub_full, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_hub_full\" (message), default=\"Hub is full\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -618,7 +571,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_hub_disabled, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_hub_disabled\" (message), default=\"Hub is disabled\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -629,7 +581,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_hub_registered_users_only, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_hub_registered_users_only\" (message), default=\"Hub is for registered users only\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -640,7 +591,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_missing, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_missing\" (message), default=\"No nickname given\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -651,7 +601,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_multiple, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_multiple\" (message), default=\"Multiple nicknames given\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -662,7 +611,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_invalid, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_invalid\" (message), default=\"Nickname is invalid\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -673,7 +621,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_long, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_long\" (message), default=\"Nickname too long\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -684,7 +631,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_short, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_short\" (message), default=\"Nickname too short\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -695,7 +641,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_spaces, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_spaces\" (message), default=\"Nickname cannot start with spaces\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -706,7 +651,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_bad_chars, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_bad_chars\" (message), default=\"Nickname contains invalid characters\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -717,7 +661,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_not_utf8, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_not_utf8\" (message), default=\"Nickname is not valid UTF-8\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -728,7 +671,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_taken, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_taken\" (message), default=\"Nickname is already in use\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -739,7 +681,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_nick_restricted, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_nick_restricted\" (message), default=\"Nickname cannot be used on this hub\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -750,7 +691,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_cid_invalid, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_cid_invalid\" (message), default=\"CID is not valid\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -761,7 +701,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_cid_missing, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_cid_missing\" (message), default=\"CID is not specified\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -772,7 +711,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_cid_taken, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_cid_taken\" (message), default=\"CID is taken\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -783,7 +721,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_pid_missing, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_pid_missing\" (message), default=\"PID is not specified\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -794,7 +731,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_inf_error_pid_invalid, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_inf_error_pid_invalid\" (message), default=\"PID is invalid\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -805,7 +741,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_ban_permanently, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_ban_permanently\" (message), default=\"Banned permanently\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -816,7 +751,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_ban_temporarily, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_ban_temporarily\" (message), default=\"Banned temporarily\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -827,7 +761,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_auth_invalid_password, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_auth_invalid_password\" (message), default=\"Password is wrong\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -838,7 +771,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_auth_user_not_found, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_auth_user_not_found\" (message), default=\"User not found in password database\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -849,7 +781,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_error_no_memory, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_error_no_memory\" (message), default=\"No memory\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -860,7 +791,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_share_size_low, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_share_size_low\" (message), default=\"User is not sharing enough\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -871,7 +801,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_share_size_high, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_share_size_high\" (message), default=\"User is sharing too much\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -882,7 +811,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_slots_low, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_slots_low\" (message), default=\"User have too few upload slots.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -893,7 +821,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_slots_high, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_slots_high\" (message), default=\"User have too many upload slots.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -904,7 +831,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_hub_limit_low, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_hub_limit_low\" (message), default=\"User is on too few hubs.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -915,7 +841,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_hub_limit_high, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_hub_limit_high\" (message), default=\"User is on too many hubs.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -926,7 +851,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_flood_chat, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_flood_chat\" (message), default=\"Chat flood detected, messages are dropped.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -937,7 +861,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_flood_connect, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_flood_connect\" (message), default=\"Connect flood detected, connection refused.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -948,7 +871,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_flood_search, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_flood_search\" (message), default=\"Search flood detected, search is stopped.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -959,7 +881,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_flood_update, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_flood_update\" (message), default=\"Update flood detected.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -970,7 +891,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_user_flood_extras, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_user_flood_extras\" (message), default=\"Flood detected.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -981,7 +901,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_proto_no_common_hash, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_proto_no_common_hash\" (message), default=\"No common hash algorithm.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -992,7 +911,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||
if (!apply_string(key, data, &config->msg_proto_obsolete_adc0, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
LOG_ERROR("\"msg_proto_obsolete_adc0\" (message), default=\"Client is using an obsolete ADC protocol version.\"");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1015,8 +933,6 @@ void free_config(struct hub_config* config)
|
||||
|
||||
hub_free(config->redirect_addr);
|
||||
|
||||
hub_free(config->tls_require_redirect_addr);
|
||||
|
||||
hub_free(config->tls_certificate);
|
||||
|
||||
hub_free(config->tls_private_key);
|
||||
@@ -1027,6 +943,8 @@ void free_config(struct hub_config* config)
|
||||
|
||||
hub_free(config->file_rules);
|
||||
|
||||
hub_free(config->file_plugins);
|
||||
|
||||
hub_free(config->msg_hub_full);
|
||||
|
||||
hub_free(config->msg_hub_disabled);
|
||||
@@ -1223,9 +1141,6 @@ void dump_config(struct hub_config* config, int ignore_defaults)
|
||||
if (!ignore_defaults || config->tls_require != 0)
|
||||
fprintf(stdout, "tls_require = %s\n", config->tls_require ? "yes" : "no");
|
||||
|
||||
if (!ignore_defaults || strcmp(config->tls_require_redirect_addr, "") != 0)
|
||||
fprintf(stdout, "tls_require_redirect_addr = \"%s\"\n", config->tls_require_redirect_addr);
|
||||
|
||||
if (!ignore_defaults || strcmp(config->tls_certificate, "") != 0)
|
||||
fprintf(stdout, "tls_certificate = \"%s\"\n", config->tls_certificate);
|
||||
|
||||
@@ -1241,6 +1156,9 @@ void dump_config(struct hub_config* config, int ignore_defaults)
|
||||
if (!ignore_defaults || strcmp(config->file_rules, "") != 0)
|
||||
fprintf(stdout, "file_rules = \"%s\"\n", config->file_rules);
|
||||
|
||||
if (!ignore_defaults || strcmp(config->file_plugins, "") != 0)
|
||||
fprintf(stdout, "file_plugins = \"%s\"\n", config->file_plugins);
|
||||
|
||||
if (!ignore_defaults || strcmp(config->msg_hub_full, "Hub is full") != 0)
|
||||
fprintf(stdout, "msg_hub_full = \"%s\"\n", config->msg_hub_full);
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@ struct hub_config
|
||||
int flood_ctl_extras; /*<<< Max extra messages allowed in time interval (default: 0) */
|
||||
int tls_enable; /*<<< Enable SSL/TLS support (default: 0) */
|
||||
int tls_require; /*<<< If SSL/TLS enabled, should it be required (default: 0) (default: 0) */
|
||||
char* tls_require_redirect_addr; /*<<< A redirect address in case a client connects using "adc://" when "adcs://" is required. (default: ) */
|
||||
char* tls_certificate; /*<<< Certificate file (default: ) */
|
||||
char* tls_private_key; /*<<< Private key file (default: ) */
|
||||
char* file_motd; /*<<< File containing the 'message of the day (default: ) */
|
||||
char* file_acl; /*<<< File containing access control lists (default: ) */
|
||||
char* file_rules; /*<<< File containing hub rules (default: ) */
|
||||
char* file_plugins; /*<<< Plugin configuration file (default: ) */
|
||||
char* msg_hub_full; /*<<< "Hub is full" */
|
||||
char* msg_hub_disabled; /*<<< "Hub is disabled" */
|
||||
char* msg_hub_registered_users_only; /*<<< "Hub is for registered users only" */
|
||||
|
||||
@@ -662,7 +662,6 @@ static int load_ssl_certificates(struct hub_info* hub, struct hub_config* config
|
||||
|
||||
/* Disable SSLv2 */
|
||||
SSL_CTX_set_options(hub->ssl_ctx, SSL_OP_NO_SSLv2);
|
||||
SSL_CTX_set_quiet_shutdown(hub->ssl_ctx, 1);
|
||||
|
||||
if (SSL_CTX_use_certificate_file(hub->ssl_ctx, config->tls_certificate, SSL_FILETYPE_PEM) < 0)
|
||||
{
|
||||
@@ -792,6 +791,7 @@ void hub_shutdown_service(struct hub_info* hub)
|
||||
|
||||
event_queue_shutdown(hub->queue);
|
||||
net_con_close(hub->server);
|
||||
hub_free(hub->server);
|
||||
server_alt_port_stop(hub);
|
||||
uman_shutdown(hub);
|
||||
hub->status = hub_status_stopped;
|
||||
@@ -806,6 +806,45 @@ void hub_shutdown_service(struct hub_info* hub)
|
||||
g_hub = 0;
|
||||
}
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
void hub_plugins_load(struct hub_info* hub)
|
||||
{
|
||||
if (!hub->config->file_plugins || !*hub->config->file_plugins)
|
||||
return;
|
||||
|
||||
hub->plugins = hub_malloc_zero(sizeof(struct uhub_plugins));
|
||||
if (!hub->plugins)
|
||||
return;
|
||||
|
||||
if (plugin_initialize(hub->config, hub->plugins) < 0)
|
||||
{
|
||||
hub_free(hub->plugins);
|
||||
hub->plugins = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void hub_plugins_unload(struct hub_info* hub)
|
||||
{
|
||||
if (!hub->plugins || !hub->plugins->loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
struct uhub_plugin_handle* plugin = (struct uhub_plugin_handle*) list_get_first(hub->plugins->loaded);
|
||||
while (plugin)
|
||||
{
|
||||
plugin_unload(plugin);
|
||||
plugin = (struct uhub_plugin_handle*) list_get_next(hub->plugins->loaded);
|
||||
}
|
||||
|
||||
list_destroy(hub->plugins->loaded);
|
||||
hub_free(hub->plugins->plugin_dir);
|
||||
hub_free(hub->plugins);
|
||||
hub->plugins = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
||||
{
|
||||
int fd, ret;
|
||||
@@ -880,6 +919,10 @@ void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
||||
hub_free(tmp);
|
||||
}
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
hub_plugins_load(hub);
|
||||
#endif
|
||||
|
||||
hub->status = (hub->config->hub_enabled ? hub_status_running : hub_status_disabled);
|
||||
hub_free(server);
|
||||
}
|
||||
@@ -887,6 +930,10 @@ void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
||||
|
||||
void hub_free_variables(struct hub_info* hub)
|
||||
{
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
hub_plugins_unload(hub);
|
||||
#endif
|
||||
|
||||
adc_msg_free(hub->command_info);
|
||||
adc_msg_free(hub->command_banner);
|
||||
|
||||
|
||||
@@ -114,6 +114,10 @@ struct hub_info
|
||||
struct linked_list* chat_history; /* Chat history */
|
||||
struct linked_list* logout_info; /* Log of people logging out. */
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
struct uhub_plugins* plugins;
|
||||
#endif
|
||||
|
||||
#ifdef SSL_SUPPORT
|
||||
SSL_METHOD* ssl_method;
|
||||
SSL_CTX* ssl_ctx;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "uhub.h"
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
static void log_user_login(struct hub_user* u)
|
||||
{
|
||||
@@ -67,6 +68,10 @@ void on_login_success(struct hub_info* hub, struct hub_user* u)
|
||||
/* Print log message */
|
||||
log_user_login(u);
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
plugin_log_user_login_success(hub, u);
|
||||
#endif
|
||||
|
||||
/* Announce new user to all connected users */
|
||||
if (user_is_logged_in(u))
|
||||
route_info_message(hub, u);
|
||||
@@ -109,6 +114,11 @@ void on_logout_user(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
const char* reason = user_get_quit_reason_string(user->quit_reason);
|
||||
log_user_logout(user, reason);
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
plugin_log_user_logout(hub, user);
|
||||
#endif
|
||||
|
||||
hub_logout_log(hub, user);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,11 +115,6 @@ int main_loop()
|
||||
{
|
||||
LOG_INFO("Reloading configuration files...");
|
||||
LOG_DEBUG("Hub status: %d", (int) hub->status);
|
||||
|
||||
/* Reinitialize logs */
|
||||
hub_log_shutdown();
|
||||
hub_log_initialize(arg_log, arg_log_syslog);
|
||||
hub_set_log_verbosity(arg_verbose);
|
||||
}
|
||||
|
||||
if (read_config(arg_config, &configuration, !arg_have_config) == -1)
|
||||
|
||||
@@ -175,8 +175,10 @@ void net_on_accept(struct net_connection* con, int event, void *arg)
|
||||
struct hub_info* hub = (struct hub_info*) arg;
|
||||
struct hub_probe* probe = 0;
|
||||
struct ip_addr_encap ipaddr;
|
||||
const char* addr;
|
||||
int server_fd = net_con_get_sd(con);
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
plugin_st status;
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -194,19 +196,18 @@ void net_on_accept(struct net_connection* con, int event, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
addr = ip_convert_to_string(&ipaddr);
|
||||
|
||||
/* FIXME: Should have a plugin log this */
|
||||
LOG_TRACE("Got connection from %s", addr);
|
||||
|
||||
/* FIXME: A plugin should perform this check: is IP banned? */
|
||||
if (acl_is_ip_banned(hub->acl, addr))
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
status = plugin_check_ip_early(hub, &ipaddr);
|
||||
if (status == st_deny)
|
||||
{
|
||||
LOG_INFO("Denied [%s] (IP banned)", addr);
|
||||
plugin_log_connection_denied(hub, &ipaddr);
|
||||
net_close(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
plugin_log_connection_accepted(hub, &ipaddr);
|
||||
#endif
|
||||
|
||||
probe = probe_create(hub, fd, &ipaddr);
|
||||
if (!probe)
|
||||
{
|
||||
|
||||
89
src/core/plugininvoke.c
Normal file
89
src/core/plugininvoke.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "uhub.h"
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
#define PLUGIN_INVOKE(HUB, FUNCNAME, CODE) \
|
||||
if (HUB->plugins && HUB->plugins->loaded) \
|
||||
{ \
|
||||
struct uhub_plugin_handle* plugin = (struct uhub_plugin_handle*) list_get_first(HUB->plugins->loaded); \
|
||||
while (plugin) \
|
||||
{ \
|
||||
if (plugin->funcs.FUNCNAME) \
|
||||
CODE \
|
||||
plugin = (struct uhub_plugin_handle*) list_get_next(HUB->plugins->loaded); \
|
||||
} \
|
||||
}
|
||||
|
||||
plugin_st plugin_check_ip_early(struct hub_info* hub, struct ip_addr_encap* addr)
|
||||
{
|
||||
plugin_st status = st_default;
|
||||
PLUGIN_INVOKE(hub, login_check_ip_early, {
|
||||
status = plugin->funcs.login_check_ip_early(addr);
|
||||
if (status != st_default)
|
||||
break;
|
||||
});
|
||||
return status;
|
||||
}
|
||||
|
||||
plugin_st plugin_check_ip_late(struct hub_info* hub, struct ip_addr_encap* addr)
|
||||
{
|
||||
plugin_st status = st_default;
|
||||
PLUGIN_INVOKE(hub, login_check_ip_late, {
|
||||
status = plugin->funcs.login_check_ip_late(addr);
|
||||
if (status != st_default)
|
||||
break;
|
||||
});
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
void plugin_log_connection_accepted(struct hub_info* hub, struct ip_addr_encap* ipaddr)
|
||||
{
|
||||
const char* addr = ip_convert_to_string(ipaddr);
|
||||
LOG_TRACE("Got connection from %s", addr);
|
||||
}
|
||||
|
||||
void plugin_log_connection_denied(struct hub_info* hub, struct ip_addr_encap* ipaddr)
|
||||
{
|
||||
const char* addr = ip_convert_to_string(ipaddr);
|
||||
LOG_INFO("Denied connection from %s", addr);
|
||||
}
|
||||
|
||||
void plugin_log_user_login_success(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
}
|
||||
|
||||
void plugin_log_user_login_error(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
}
|
||||
|
||||
void plugin_log_user_logout(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void convert_user_to_plugin_user(struct plugin_user* puser, struct hub_user* user)
|
||||
{
|
||||
puser->sid = user->id.sid;
|
||||
puser->nick = user->id.nick;
|
||||
puser->cid = user->id.cid;
|
||||
puser->addr = user->id.addr;
|
||||
}
|
||||
46
src/core/plugininvoke.h
Normal file
46
src/core/plugininvoke.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAVE_UHUB_PLUGIN_INVOKE_H
|
||||
#define HAVE_UHUB_PLUGIN_INVOKE_H
|
||||
|
||||
#include "uhub.h"
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
|
||||
struct hub_info;
|
||||
struct ip_addr_encap;
|
||||
|
||||
void plugin_log_connection_accepted(struct hub_info* hub, struct ip_addr_encap* addr);
|
||||
void plugin_log_connection_denied(struct hub_info* hub, struct ip_addr_encap* addr);
|
||||
void plugin_log_user_login_success(struct hub_info* hub, struct hub_user* user);
|
||||
void plugin_log_user_login_error(struct hub_info* hub, struct hub_user* user);
|
||||
void plugin_log_user_logout(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
plugin_st plugin_check_ip_early(struct hub_info* hub, struct ip_addr_encap* addr);
|
||||
plugin_st plugin_check_ip_late(struct hub_info* hub, struct ip_addr_encap* addr);
|
||||
|
||||
plugin_st plugin_check_nickname_valid(struct hub_info* hub, const char* nick);
|
||||
plugin_st plugin_check_nickname_reserved(struct hub_info* hub, const char* nick);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif // HAVE_UHUB_PLUGIN_INVOKE_H
|
||||
187
src/core/pluginloader.c
Normal file
187
src/core/pluginloader.c
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "uhub.h"
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
struct uhub_plugin* plugin_open(const char* filename)
|
||||
{
|
||||
LOG_TRACE("plugin_open: \"%s\"", filename);
|
||||
#ifdef HAVE_DLOPEN
|
||||
struct uhub_plugin* plugin = (struct uhub_plugin*) hub_malloc_zero(sizeof(struct uhub_plugin));
|
||||
if (!plugin)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
plugin->handle = dlopen(filename, RTLD_LAZY);
|
||||
|
||||
if (!plugin->handle)
|
||||
{
|
||||
LOG_ERROR("Unable to open plugin %s: %s", filename, dlerror());
|
||||
hub_free(plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return plugin;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void plugin_close(struct uhub_plugin* plugin)
|
||||
{
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlclose(plugin->handle);
|
||||
hub_free(plugin);
|
||||
#endif
|
||||
}
|
||||
|
||||
void* plugin_lookup_symbol(struct uhub_plugin* plugin, const char* symbol)
|
||||
{
|
||||
#ifdef HAVE_DLOPEN
|
||||
void* addr = dlsym(plugin->handle, symbol);
|
||||
return addr;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct uhub_plugin_handle* plugin_load(const char* filename, const char* config)
|
||||
{
|
||||
plugin_register_f register_f;
|
||||
plugin_unregister_f unregister_f;
|
||||
int ret;
|
||||
struct uhub_plugin_handle* handle = hub_malloc_zero(sizeof(struct uhub_plugin_handle));
|
||||
struct uhub_plugin* plugin = plugin_open(filename);
|
||||
|
||||
if (!plugin)
|
||||
return NULL;
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
plugin_close(plugin);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle->handle = plugin;
|
||||
register_f = plugin_lookup_symbol(plugin, "plugin_register");
|
||||
unregister_f = plugin_lookup_symbol(plugin, "plugin_unregister");
|
||||
|
||||
if (register_f && unregister_f)
|
||||
{
|
||||
ret = register_f(handle, config);
|
||||
if (ret == 0)
|
||||
{
|
||||
if (handle->plugin_api_version == PLUGIN_API_VERSION && handle->plugin_funcs_size == sizeof(struct plugin_funcs))
|
||||
{
|
||||
LOG_INFO("Loaded plugin: %s: %s, version %s.", filename, handle->name, handle->version);
|
||||
LOG_TRACE("Plugin API version: %d (func table size: " PRINTF_SIZE_T ")", handle->plugin_api_version, handle->plugin_funcs_size);
|
||||
plugin->unregister = unregister_f;
|
||||
return handle;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Unable to load plugin: %s - API version mistmatch", filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Unable to load plugin: %s - Failed to initialize", filename);
|
||||
}
|
||||
}
|
||||
|
||||
plugin_close(plugin);
|
||||
hub_free(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void plugin_unload(struct uhub_plugin_handle* plugin)
|
||||
{
|
||||
plugin->handle->unregister(plugin);
|
||||
plugin_close(plugin->handle);
|
||||
}
|
||||
|
||||
static int plugin_parse_line(char* line, int line_count, void* ptr_data)
|
||||
{
|
||||
struct uhub_plugins* handle = (struct uhub_plugins*) ptr_data;
|
||||
char* pos;
|
||||
|
||||
strip_off_ini_line_comments(line, line_count);
|
||||
|
||||
line = strip_white_space(line);
|
||||
if (!*line)
|
||||
return 0;
|
||||
|
||||
LOG_TRACE("plugin: parse line %d: \"%s\"", line_count, line);
|
||||
|
||||
// Set plugin directory.
|
||||
pos = strstr(line, "plugin_directory");
|
||||
if (pos && is_white_space(line[(pos - line) + strlen("plugin_directory")]))
|
||||
{
|
||||
if (handle->plugin_dir)
|
||||
hub_free(handle->plugin_dir);
|
||||
handle->plugin_dir = strdup(strip_white_space(pos + strlen("plugin_directory") + 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Load plugin
|
||||
pos = strstr(line, "plugin");
|
||||
if (pos && is_white_space(line[(pos - line) + strlen("plugin")]))
|
||||
{
|
||||
char* data = strip_white_space(pos + strlen("plugin") + 1);
|
||||
if (*data)
|
||||
{
|
||||
LOG_TRACE("Load plugin: \"%s\"", data);
|
||||
struct uhub_plugin_handle* plugin = plugin_load(data, "");
|
||||
if (plugin)
|
||||
{
|
||||
list_append(handle->loaded, plugin);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int plugin_initialize(struct hub_config* config, struct uhub_plugins* handle)
|
||||
{
|
||||
int ret;
|
||||
|
||||
handle->loaded = list_create();
|
||||
if (!handle->loaded)
|
||||
return -1;
|
||||
|
||||
if (config)
|
||||
{
|
||||
if (!*config->file_plugins)
|
||||
return 0;
|
||||
|
||||
ret = file_read_lines(config->file_plugins, handle, &plugin_parse_line);
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /* PLUGIN_SUPPORT */
|
||||
62
src/core/pluginloader.h
Normal file
62
src/core/pluginloader.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAVE_UHUB_PLUGIN_LOADER_H
|
||||
#define HAVE_UHUB_PLUGIN_LOADER_H
|
||||
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
#ifdef PLUGIN_SUPPORT
|
||||
|
||||
struct hub_config;
|
||||
struct linked_list;
|
||||
struct uhub_plugin_handle;
|
||||
|
||||
struct uhub_plugin
|
||||
{
|
||||
#ifdef HAVE_DLOPEN
|
||||
void* handle;
|
||||
#endif
|
||||
plugin_unregister_f unregister;
|
||||
};
|
||||
|
||||
struct uhub_plugins
|
||||
{
|
||||
struct linked_list* loaded;
|
||||
char* plugin_dir;
|
||||
};
|
||||
|
||||
// High level plugin loader ode
|
||||
extern struct uhub_plugin_handle* plugin_load(const char* filename, const char* config);
|
||||
extern void plugin_unload(struct uhub_plugin_handle* plugin);
|
||||
|
||||
// extern void plugin_unload(struct uhub_plugin_handle*);
|
||||
extern int plugin_initialize(struct hub_config* config, struct uhub_plugins* handle);
|
||||
|
||||
// Low level plugin loader code (used internally)
|
||||
extern struct uhub_plugin* plugin_open(const char* filename);
|
||||
extern void plugin_close(struct uhub_plugin*);
|
||||
extern void* plugin_lookup_symbol(struct uhub_plugin*, const char* symbol);
|
||||
|
||||
|
||||
|
||||
#endif /* PLUGIN_SUPPORT */
|
||||
|
||||
#endif /* HAVE_UHUB_PLUGIN_LOADER_H */
|
||||
|
||||
@@ -48,19 +48,9 @@ static void probe_net_event(struct net_connection* con, int events, void *arg)
|
||||
LOG_TRACE("Probed ADC");
|
||||
#ifdef SSL_SUPPORT
|
||||
if (probe->hub->config->tls_enable && probe->hub->config->tls_require)
|
||||
{
|
||||
if (*probe->hub->config->tls_require_redirect_addr)
|
||||
{
|
||||
char buf[512];
|
||||
ssize_t len = snprintf(buf, sizeof(buf), "ISUP " ADC_PROTO_SUPPORT "\nISID AAAB\nIINF NIRedirecting...\nIQUI AAAB RD%s\n", probe->hub->config->tls_require_redirect_addr);
|
||||
net_con_send(con, buf, (size_t) len);
|
||||
LOG_TRACE("Not TLS connection - Redirecting to %s.", probe->hub->config->tls_require_redirect_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_TRACE("Not TLS connection - closing connection.");
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (user_create(probe->hub, probe->connection, &probe->addr))
|
||||
@@ -70,8 +60,9 @@ static void probe_net_event(struct net_connection* con, int events, void *arg)
|
||||
probe_destroy(probe);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SSL_SUPPORT
|
||||
else if (bytes >= 11 &&
|
||||
if (bytes >= 11 &&
|
||||
probe_recvbuf[0] == 22 &&
|
||||
probe_recvbuf[1] == 3 && /* protocol major version */
|
||||
probe_recvbuf[5] == 1 && /* message type */
|
||||
@@ -116,8 +107,6 @@ struct hub_probe* probe_create(struct hub_info* hub, int sd, struct ip_addr_enca
|
||||
if (probe == NULL)
|
||||
return NULL; /* OOM */
|
||||
|
||||
LOG_TRACE("probe_create(): %p", probe);
|
||||
|
||||
probe->hub = hub;
|
||||
probe->connection = net_con_create();
|
||||
net_con_initialize(probe->connection, sd, probe_net_event, probe, NET_EVENT_READ);
|
||||
@@ -129,7 +118,6 @@ struct hub_probe* probe_create(struct hub_info* hub, int sd, struct ip_addr_enca
|
||||
|
||||
void probe_destroy(struct hub_probe* probe)
|
||||
{
|
||||
LOG_TRACE("probe_destroy(): %p (connection=%p)", probe, probe->connection);
|
||||
if (probe->connection)
|
||||
{
|
||||
net_con_close(probe->connection);
|
||||
|
||||
@@ -71,12 +71,6 @@ void user_destroy(struct hub_user* user)
|
||||
hub_recvq_destroy(user->recv_queue);
|
||||
hub_sendq_destroy(user->send_queue);
|
||||
|
||||
if (user->connection)
|
||||
{
|
||||
LOG_TRACE("user_destory() -> net_con_close(%p)", user->connection);
|
||||
net_con_close(user->connection);
|
||||
}
|
||||
|
||||
adc_msg_free(user->info);
|
||||
user_clear_feature_cast_support(user);
|
||||
hub_free(user);
|
||||
|
||||
109
src/includes.h
109
src/includes.h
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAVE_UHUB_INCLUDES_H
|
||||
#define HAVE_UHUB_INCLUDES_H
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#ifdef WINSOCK
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
#else
|
||||
# include <sys/types.h>
|
||||
# include <sys/time.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <netdb.h>
|
||||
# include <netinet/in.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
# include <assert.h>
|
||||
# include <errno.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
#ifndef __sun__
|
||||
# include <getopt.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !defined(WIN32)
|
||||
# include <grp.h>
|
||||
# include <pwd.h>
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef SSL_SUPPORT
|
||||
# include <openssl/ssl.h>
|
||||
# include <openssl/err.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
# define USE_EPOLL
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#ifdef BSD_LIKE
|
||||
# define USE_KQUEUE
|
||||
# include <sys/event.h>
|
||||
#endif
|
||||
|
||||
#define USE_SELECT
|
||||
# ifndef WINSOCK
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WIN32)
|
||||
# define HAVE_STRNDUP
|
||||
# define HAVE_GETRLIMIT
|
||||
# if !defined(__HAIKU__)
|
||||
# define HAVE_MEMMEM
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(BSD_LIKE) || defined(__sun__)
|
||||
# undef HAVE_STRNDUP
|
||||
# undef HAVE_MEMMEM
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
/* Windows uses %Iu for size_t */
|
||||
#define PRINTF_SIZE_T "%Iu"
|
||||
#else
|
||||
/* NOTE: does not work for old versions of gcc (like 2.95) */
|
||||
#define PRINTF_SIZE_T "%zu"
|
||||
#endif
|
||||
|
||||
#define uhub_assert assert
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_INCLUDES_H */
|
||||
@@ -179,14 +179,6 @@ void net_con_close(struct net_connection* con)
|
||||
|
||||
g_backend->handler.con_del(g_backend->data, con);
|
||||
|
||||
#ifdef SSL_SUPPORT
|
||||
if (con->ssl)
|
||||
{
|
||||
SSL_shutdown(con->ssl);
|
||||
SSL_clear(con->ssl);
|
||||
}
|
||||
#endif
|
||||
|
||||
net_close(con->sd);
|
||||
con->sd = -1;
|
||||
|
||||
@@ -204,7 +196,6 @@ struct net_cleanup_handler* net_cleanup_initialize(size_t max)
|
||||
|
||||
void net_cleanup_shutdown(struct net_cleanup_handler* handler)
|
||||
{
|
||||
net_cleanup_process(handler);
|
||||
hub_free(handler->queue);
|
||||
hub_free(handler);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ ssize_t net_con_send(struct net_connection* con, const void* buf, size_t len)
|
||||
LOG_PROTO("SSL_write(con=%p, buf=%p, len=" PRINTF_SIZE_T ") => %d", con, buf, len, ret);
|
||||
if (ret <= 0)
|
||||
{
|
||||
return handle_openssl_error(con, ret);
|
||||
return -handle_openssl_error(con, ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -201,7 +201,7 @@ ssize_t net_con_recv(struct net_connection* con, void* buf, size_t len)
|
||||
}
|
||||
else
|
||||
{
|
||||
return handle_openssl_error(con, ret);
|
||||
return -handle_openssl_error(con, ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -251,9 +251,6 @@ void* net_con_get_ptr(struct net_connection* con)
|
||||
|
||||
void net_con_destroy(struct net_connection* con)
|
||||
{
|
||||
#ifdef SSL_SUPPORT
|
||||
SSL_free(con->ssl);
|
||||
#endif
|
||||
hub_free(con);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ int net_initialize()
|
||||
LOG_TRACE("Initializing OpenSSL...");
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
OpenSSL_add_all_algorithms();
|
||||
#endif /* SSL_SUPPORT */
|
||||
|
||||
net_initialized = 1;
|
||||
@@ -99,9 +100,7 @@ int net_destroy()
|
||||
net_backend_shutdown();
|
||||
|
||||
#ifdef SSL_SUPPORT
|
||||
ERR_free_strings();
|
||||
EVP_cleanup();
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
/* FIXME: Shutdown OpenSSL here. */
|
||||
#endif
|
||||
|
||||
#ifdef WINSOCK
|
||||
|
||||
153
src/plugin_api/handle.h
Normal file
153
src/plugin_api/handle.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAVE_UHUB_PLUGIN_HANDLE_H
|
||||
#define HAVE_UHUB_PLUGIN_HANDLE_H
|
||||
|
||||
#include "system.h"
|
||||
#include "util/ipcalc.h"
|
||||
|
||||
#define PLUGIN_API_VERSION 0
|
||||
|
||||
#ifndef MAX_NICK_LEN
|
||||
#define MAX_NICK_LEN 64
|
||||
#endif
|
||||
|
||||
#ifndef MAX_PASS_LEN
|
||||
#define MAX_PASS_LEN 64
|
||||
#endif
|
||||
|
||||
struct ip_addr_encap;
|
||||
|
||||
struct plugin_user
|
||||
{
|
||||
unsigned int sid;
|
||||
const char* nick;
|
||||
const char* cid;
|
||||
struct ip_addr_encap addr;
|
||||
};
|
||||
|
||||
enum plugin_status
|
||||
{
|
||||
st_default = 0, /* Use default */
|
||||
st_allow = 1, /* Allow action */
|
||||
st_deny = -1, /* Deny action */
|
||||
};
|
||||
|
||||
typedef enum plugin_status plugin_st;
|
||||
|
||||
enum auth_credentials
|
||||
{
|
||||
auth_cred_none, /**<<< "User has no credentials (not yet logged in)" */
|
||||
auth_cred_bot, /**<<< "User is a robot" */
|
||||
auth_cred_guest, /**<<< "User is a guest (unregistered user)" */
|
||||
auth_cred_user, /**<<< "User is identified as a registered user" */
|
||||
auth_cred_operator, /**<<< "User is identified as a hub operator" */
|
||||
auth_cred_super, /**<<< "User is a super user" (not used) */
|
||||
auth_cred_link, /**<<< "User is a link (not used currently)" */
|
||||
auth_cred_admin, /**<<< "User is identified as a hub administrator/owner" */
|
||||
};
|
||||
|
||||
struct auth_info
|
||||
{
|
||||
char nickname[MAX_NICK_LEN+1];
|
||||
char password[MAX_PASS_LEN+1];
|
||||
enum auth_credentials credentials;
|
||||
};
|
||||
|
||||
typedef plugin_st (*on_chat_msg_t)(struct plugin_user* from, const char* message);
|
||||
typedef plugin_st (*on_private_msg_t)(struct plugin_user* from, struct plugin_user* to, const char* message);
|
||||
typedef plugin_st (*on_search_t)(struct plugin_user* from, const char* data);
|
||||
typedef plugin_st (*on_p2p_connect_t)(struct plugin_user* from, struct plugin_user* to);
|
||||
typedef plugin_st (*on_p2p_revconnect_t)(struct plugin_user* from, struct plugin_user* to);
|
||||
|
||||
typedef void (*on_user_connect_t)(struct ip_addr_encap*);
|
||||
typedef void (*on_user_login_t)(struct plugin_user*);
|
||||
typedef void (*on_user_logout_t)(struct plugin_user*);
|
||||
typedef void (*on_user_nick_change_t)(struct plugin_user*, const char* new_nick);
|
||||
|
||||
typedef plugin_st (*on_change_nick_t)(struct plugin_user*, const char* new_nick);
|
||||
|
||||
typedef plugin_st (*on_check_ip_early_t)(struct ip_addr_encap*);
|
||||
typedef plugin_st (*on_check_ip_late_t)(struct ip_addr_encap*);
|
||||
typedef plugin_st (*on_validate_nick_t)(const char* nick);
|
||||
typedef plugin_st (*on_validate_cid_t)(const char* cid);
|
||||
|
||||
typedef int (*auth_get_user_t)(const char* nickname, struct auth_info* info);
|
||||
typedef plugin_st (*auth_register_user_t)(struct auth_info* user);
|
||||
typedef plugin_st (*auth_update_user_t)(struct auth_info* user);
|
||||
typedef plugin_st (*auth_delete_user_t)(struct auth_info* user);
|
||||
|
||||
struct plugin_funcs
|
||||
{
|
||||
// Users logging in and out
|
||||
on_user_connect_t on_user_connect; /* A user has connected to the hub */
|
||||
on_user_login_t on_user_login; /* A user has successfully logged in to the hub */
|
||||
on_user_logout_t on_user_logout; /* A user has logged out of the hub (was previously logged in) */
|
||||
on_user_nick_change_t on_user_nick_change; /* A user has changed nickname */
|
||||
|
||||
// Activity events (can be intercepted and refused by a plugin)
|
||||
on_chat_msg_t on_chat_msg; /* A public chat message is about to be sent (can be intercepted) */
|
||||
on_private_msg_t on_private_msg; /* A public chat message is about to be sent (can be intercepted) */
|
||||
on_search_t on_search; /* A search is about to be sent (can be intercepted) */
|
||||
on_p2p_connect_t on_p2p_connect; /* A user is about to connect to another user (can be intercepted) */
|
||||
on_p2p_revconnect_t on_p2p_revconnect; /* A user is about to connect to another user (can be intercepted) */
|
||||
|
||||
// Authentication actions.
|
||||
auth_get_user_t auth_get_user; /* Get authentication info from plugin */
|
||||
auth_register_user_t auth_register_user; /* Register user */
|
||||
auth_update_user_t auth_update_user; /* Update a registered user */
|
||||
auth_delete_user_t auth_delete_user; /* Delete a registered user */
|
||||
|
||||
// Login check functions
|
||||
on_check_ip_early_t login_check_ip_early;
|
||||
on_check_ip_late_t login_check_ip_late;
|
||||
|
||||
};
|
||||
|
||||
struct uhub_plugin_handle
|
||||
{
|
||||
struct uhub_plugin* handle; /* Must NOT be modified by the plugin */
|
||||
const char* name; /* plugin name */
|
||||
const char* version; /* plugin version */
|
||||
const char* description; /* plugin description */
|
||||
void* ptr; /* Plugin specific data */
|
||||
size_t plugin_api_version; /* Plugin API version */
|
||||
size_t plugin_funcs_size; /* Size of the plugin funcs */
|
||||
struct plugin_funcs funcs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implemented by the plugin.
|
||||
*
|
||||
* @param handle[out] Sets all information by the plugin
|
||||
* @param config A configuration string
|
||||
* @return 0 on success, -1 on error.
|
||||
*/
|
||||
extern int plugin_register(struct uhub_plugin_handle* handle, const char* config);
|
||||
|
||||
/**
|
||||
* @return 0 on success, -1 on error.
|
||||
*/
|
||||
extern int plugin_unregister(struct uhub_plugin_handle*);
|
||||
|
||||
typedef int (*plugin_register_f)(struct uhub_plugin_handle* handle, const char* config);
|
||||
typedef int (*plugin_unregister_f)(struct uhub_plugin_handle*);
|
||||
|
||||
#endif /* HAVE_UHUB_PLUGIN_HANDLE_H */
|
||||
28
src/plugins/mod_example.c
Normal file
28
src/plugins/mod_example.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* This is a minimal example plugin for uhub.
|
||||
*/
|
||||
|
||||
// #include "uhub.h"
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
int plugin_register(struct uhub_plugin_handle* plugin, const char* config)
|
||||
{
|
||||
plugin->name = "Example plugin";
|
||||
plugin->version = "1.0";
|
||||
plugin->description = "A simple example plugin";
|
||||
plugin->ptr = NULL;
|
||||
plugin->plugin_api_version = PLUGIN_API_VERSION;
|
||||
plugin->plugin_funcs_size = sizeof(struct plugin_funcs);
|
||||
memset(&plugin->funcs, 0, sizeof(struct plugin_funcs));
|
||||
|
||||
puts("plugin register");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int plugin_unregister(struct uhub_plugin_handle* plugin)
|
||||
{
|
||||
/* No need to do anything! */
|
||||
puts("plugin unregister");
|
||||
return 0;
|
||||
}
|
||||
|
||||
57
src/plugins/mod_logging.c
Normal file
57
src/plugins/mod_logging.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* This is a minimal example plugin for uhub.
|
||||
*/
|
||||
|
||||
// #include "uhub.h"
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
struct ip_addr_encap;
|
||||
|
||||
plugin_st log_connect(struct ip_addr_encap* addr)
|
||||
{
|
||||
return st_default;
|
||||
}
|
||||
|
||||
void log_user_login(struct plugin_user* user)
|
||||
{
|
||||
printf("login: \"%s\"\n", user->nick);
|
||||
}
|
||||
|
||||
void log_user_logout(struct plugin_user* user)
|
||||
{
|
||||
printf("logout: \"%s\"\n", user->nick);
|
||||
}
|
||||
|
||||
plugin_st log_change_nick(struct plugin_user* user, const char* new_nick)
|
||||
{
|
||||
printf("\"%s\" -> \"%s\"\n", user->nick, new_nick);
|
||||
return st_default;
|
||||
}
|
||||
|
||||
|
||||
int plugin_register(struct uhub_plugin_handle* plugin, const char* config)
|
||||
{
|
||||
plugin->name = "Logging plugin";
|
||||
plugin->version = "1.0";
|
||||
plugin->description = "Logs users entering and leaving the hub.";
|
||||
plugin->ptr = NULL;
|
||||
plugin->plugin_api_version = PLUGIN_API_VERSION;
|
||||
plugin->plugin_funcs_size = sizeof(struct plugin_funcs);
|
||||
memset(&plugin->funcs, 0, sizeof(struct plugin_funcs));
|
||||
|
||||
plugin->funcs.on_connect = log_connect;
|
||||
plugin->funcs.on_user_login = log_user_login;
|
||||
plugin->funcs.on_user_logout = log_user_logout;
|
||||
plugin->funcs.on_user_change_nick = log_change_nick;
|
||||
|
||||
puts("* plugin register");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int plugin_unregister(struct uhub_plugin_handle* plugin)
|
||||
{
|
||||
/* No need to do anything! */
|
||||
puts("* plugin unregister");
|
||||
return 0;
|
||||
}
|
||||
|
||||
112
src/system.h
112
src/system.h
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, Jan Vidar Krey
|
||||
* Copyright (C) 2007-2009, Jan Vidar Krey
|
||||
*
|
||||
* 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
|
||||
@@ -20,6 +20,30 @@
|
||||
#ifndef HAVE_UHUB_SYSTEM_H
|
||||
#define HAVE_UHUB_SYSTEM_H
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#if USE_REGPARM && __GNUC__ >= 3
|
||||
#define REGPRM1 __attribute__((regparm(1)))
|
||||
#define REGPRM2 __attribute__((regparm(2)))
|
||||
#define REGPRM3 __attribute__((regparm(3)))
|
||||
#else
|
||||
#define REGPRM1
|
||||
#define REGPRM2
|
||||
#define REGPRM3
|
||||
#endif
|
||||
|
||||
#ifndef FORCEINLINE
|
||||
#if __GNUC__ < 3
|
||||
#define FORCEINLINE inline
|
||||
#else
|
||||
#define FORCEINLINE inline __attribute__((always_inline))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#define BSD_LIKE
|
||||
#endif
|
||||
@@ -30,6 +54,87 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WINSOCK
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef __sun__
|
||||
#include <getopt.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !defined(WIN32)
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/resource.h>
|
||||
#define HAVE_STRNDUP
|
||||
#define HAVE_DLOPEN
|
||||
#include <dlfcn.h>
|
||||
#ifndef __HAIKU__
|
||||
#define HAVE_MEMMEM
|
||||
#endif
|
||||
#define HAVE_GETRLIMIT
|
||||
#endif
|
||||
|
||||
/* printf and size_t support */
|
||||
#if defined(WIN32)
|
||||
/* Windows uses %Iu for size_t */
|
||||
#define PRINTF_SIZE_T "%Iu"
|
||||
#else
|
||||
#define PRINTF_SIZE_T "%zu"
|
||||
#endif
|
||||
|
||||
#ifdef SSL_SUPPORT
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#endif
|
||||
|
||||
#include "../version.h"
|
||||
|
||||
#define uhub_assert assert
|
||||
|
||||
#ifdef __linux__
|
||||
#define USE_EPOLL
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#ifdef BSD_LIKE
|
||||
#define USE_KQUEUE
|
||||
#include <sys/event.h>
|
||||
#endif
|
||||
|
||||
#define USE_SELECT
|
||||
#ifndef WINSOCK
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if defined(BSD_LIKE) || defined(__sun__)
|
||||
#undef HAVE_STRNDUP
|
||||
#undef HAVE_MEMMEM
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Detect operating system info.
|
||||
* See: http://predef.sourceforge.net/
|
||||
@@ -115,11 +220,6 @@
|
||||
#define CPUINFO "SuperH"
|
||||
#endif
|
||||
|
||||
/* System includes */
|
||||
#include "includes.h"
|
||||
#include "../version.h"
|
||||
|
||||
|
||||
/* Misc */
|
||||
#ifdef MSG_NOSIGNAL
|
||||
#define UHUB_SEND_SIGNAL MSG_NOSIGNAL
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#define MAX_CID_LEN 39
|
||||
#define MAX_NICK_LEN 64
|
||||
#define MAX_PASS_LEN 64
|
||||
#define MAX_UA_LEN 32
|
||||
#define TIGERSIZE 24
|
||||
|
||||
@@ -80,10 +81,13 @@ extern "C" {
|
||||
#include "core/user.h"
|
||||
#include "core/usermanager.h"
|
||||
#include "core/route.h"
|
||||
#include "core/pluginloader.h"
|
||||
#include "core/hub.h"
|
||||
#include "core/commands.h"
|
||||
#include "core/inf.h"
|
||||
#include "core/hubevent.h"
|
||||
#include "core/plugininvoke.h"
|
||||
#include "core/pluginloader.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -448,24 +448,3 @@ void strip_off_ini_line_comments(char* line, int line_count)
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
char* strip_off_quotes(char* line)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (!*line)
|
||||
return line;
|
||||
|
||||
len = strlen(line);
|
||||
if (len < 2)
|
||||
return line;
|
||||
|
||||
if ((line[0] == '"' && line[len - 1] == '"') ||
|
||||
(line[0] == '\'' && line[len - 1] == '\''))
|
||||
{
|
||||
line[len-1] = '\0';
|
||||
return line + 1;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ extern void base32_encode(const unsigned char* buffer, size_t len, char* result)
|
||||
extern void base32_decode(const char* src, unsigned char* dst, size_t len);
|
||||
extern char* strip_white_space(char* string);
|
||||
extern void strip_off_ini_line_comments(char* line, int line_count);
|
||||
extern char* strip_off_quotes(char* line);
|
||||
|
||||
extern int file_read_lines(const char* file, void* data, file_line_handler_t handler);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef VERSION
|
||||
#define VERSION "0.3.3"
|
||||
#define VERSION "0.3.1"
|
||||
#endif
|
||||
|
||||
#ifndef GIT_REVISION
|
||||
@@ -14,7 +14,7 @@
|
||||
#else
|
||||
#define REVISION "(git: " GIT_REVISION ")"
|
||||
#ifdef GIT_VERSION
|
||||
#define PRODUCT_STRING PRODUCT "/" VERSION " (" GIT_VERSION ")"
|
||||
#define PRODUCT_STRING PRODUCT "/" GIT_VERSION
|
||||
#else
|
||||
#define PRODUCT_STRING PRODUCT "/" VERSION " " REVISION
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user