Compare commits

..

13 Commits

Author SHA1 Message Date
Jan Vidar Krey
43375d8443 Shutdown SSL on close. 2010-09-01 23:57:55 +02:00
Jan Vidar Krey
0190c38c32 0.3.3 release candidate. 2010-08-24 23:36:30 +02:00
Jan Vidar Krey
25c03f5c96 Fix stupid mistake. 2010-08-24 23:22:37 +02:00
Jan Vidar Krey
f25cb7bd5d Don't do SSL_clear unless the SSL object is initialized. 2010-08-24 23:18:42 +02:00
Jan Vidar Krey
1e6d6cd1e7 Several SSL/TLS related memory leak fixes. 2010-08-24 23:10:23 +02:00
Jan Vidar Krey
f55243cf88 Fix SSL/TLS related memory leak. 2010-08-23 21:40:07 +02:00
Jan Vidar Krey
6e1de7329c Fix 100% CPU issue with SSL connections. 2010-08-19 11:37:18 +02:00
Jan Vidar Krey
f65a81a2aa Added option to redirect from adc:// to adcs:// if tls is required. 2010-08-18 23:32:53 +02:00
Jan Vidar Krey
6daa5ecf95 Added more informative error messages for the configuration file parser. 2010-08-10 23:20:56 +02:00
Jan Vidar Krey
23498e9ac8 Made sure logs can be rotated by sending a SIGHUP to the hub. 2010-07-12 16:56:55 +02:00
Jan Vidar Krey
c30b85bbcb Fix bug #139: Unable to use TLS - due to not handling quotes around configuration strings. 2010-07-07 18:53:39 +02:00
Jan Vidar Krey
0810982b57 Fix bug #136 - !broadcast does not report status back to to sender. 2010-06-07 15:41:07 +02:00
Jan Vidar Krey
ac5811633e Update to version 0.3.2 2010-05-31 17:13:40 +02:00
32 changed files with 244 additions and 769 deletions

View File

@@ -1,3 +1,23 @@
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.

View File

@@ -10,9 +10,8 @@ LD := $(CC)
MV := mv
RANLIB := ranlib
CFLAGS += -pipe -Wall
USE_SSL ?= NO
USE_SSL ?= YES
USE_BIGENDIAN ?= AUTO
USE_PLUGINS ?= YES
BITS ?= AUTO
SILENT ?= YES
TERSE ?= NO
@@ -43,7 +42,6 @@ UHUB_PREFIX ?= c:/uhub/
CFLAGS += -mno-cygwin
LDFLAGS += -mno-cygwin
BIN_EXT ?= .exe
USE_PLUGINS := NO
else
DESTDIR ?= /
UHUB_CONF_DIR ?= $(DESTDIR)/etc/uhub
@@ -120,12 +118,6 @@ 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 "\"")
@@ -146,8 +138,6 @@ 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 \
@@ -193,13 +183,6 @@ 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)
@@ -210,23 +193,14 @@ 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
View File

@@ -1,3 +1,15 @@
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.

View File

@@ -1,6 +1,6 @@
Summary: High performance ADC p2p hub.
Name: uhub
Version: 0.3.1
Version: 0.3.3
Release: 3
License: GPLv3
Group: Networking/File transfer

View File

@@ -452,6 +452,7 @@ 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
}

View File

@@ -110,6 +110,7 @@ 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)
{

View File

@@ -125,6 +125,7 @@ sub write_c_impl_apply(@)
my $min;
my $max;
my $regexp;
my $expect = "";
if (defined $p)
{
@@ -141,14 +142,21 @@ 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"
}
@@ -178,16 +186,27 @@ 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" .
"\t\t\treturn -1;\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}\n" .
"\t\treturn 0;\n" .
"\t}\n\n";

View File

@@ -417,6 +417,17 @@
<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[
@@ -490,19 +501,6 @@
]]></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>

View File

@@ -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,6 +96,7 @@ 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;
@@ -106,6 +107,7 @@ 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;
@@ -116,6 +118,7 @@ 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;
@@ -126,6 +129,7 @@ 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;
@@ -136,6 +140,7 @@ 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;
@@ -146,6 +151,7 @@ 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;
@@ -156,6 +162,7 @@ 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;
@@ -168,6 +175,7 @@ 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;
@@ -178,6 +186,7 @@ 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;
@@ -188,6 +197,7 @@ 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;
@@ -198,6 +208,7 @@ 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;
@@ -208,6 +219,7 @@ 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;
@@ -218,6 +230,7 @@ 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;
@@ -228,6 +241,7 @@ 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;
@@ -238,6 +252,7 @@ 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;
@@ -248,6 +263,7 @@ 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;
@@ -258,6 +274,7 @@ 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;
@@ -268,6 +285,7 @@ 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;
@@ -278,6 +296,7 @@ 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;
@@ -288,6 +307,7 @@ 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;
@@ -298,6 +318,7 @@ 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;
@@ -308,6 +329,7 @@ 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;
@@ -318,6 +340,7 @@ 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;
@@ -328,6 +351,7 @@ 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;
@@ -338,6 +362,7 @@ 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;
@@ -348,6 +373,7 @@ 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;
@@ -358,6 +384,7 @@ 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;
@@ -368,6 +395,7 @@ 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;
@@ -379,6 +407,7 @@ 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;
@@ -389,6 +418,7 @@ 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;
@@ -399,6 +429,7 @@ 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;
@@ -409,6 +440,7 @@ 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;
@@ -421,6 +453,7 @@ 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;
@@ -431,6 +464,7 @@ 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;
@@ -441,6 +475,7 @@ 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;
@@ -451,6 +486,7 @@ 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;
@@ -461,6 +497,7 @@ 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;
@@ -471,6 +508,7 @@ 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;
@@ -481,6 +519,7 @@ 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;
@@ -491,6 +530,18 @@ 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;
@@ -501,6 +552,7 @@ 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;
@@ -511,6 +563,7 @@ 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;
@@ -521,6 +574,7 @@ 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;
@@ -531,6 +585,7 @@ 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;
@@ -541,16 +596,7 @@ 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);
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);
LOG_ERROR("\"file_rules\" (file), default=\"\"");
return -1;
}
return 0;
@@ -561,6 +607,7 @@ 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;
@@ -571,6 +618,7 @@ 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;
@@ -581,6 +629,7 @@ 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;
@@ -591,6 +640,7 @@ 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;
@@ -601,6 +651,7 @@ 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;
@@ -611,6 +662,7 @@ 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;
@@ -621,6 +673,7 @@ 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;
@@ -631,6 +684,7 @@ 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;
@@ -641,6 +695,7 @@ 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;
@@ -651,6 +706,7 @@ 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;
@@ -661,6 +717,7 @@ 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;
@@ -671,6 +728,7 @@ 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;
@@ -681,6 +739,7 @@ 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;
@@ -691,6 +750,7 @@ 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;
@@ -701,6 +761,7 @@ 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;
@@ -711,6 +772,7 @@ 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;
@@ -721,6 +783,7 @@ 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;
@@ -731,6 +794,7 @@ 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;
@@ -741,6 +805,7 @@ 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;
@@ -751,6 +816,7 @@ 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;
@@ -761,6 +827,7 @@ 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;
@@ -771,6 +838,7 @@ 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;
@@ -781,6 +849,7 @@ 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;
@@ -791,6 +860,7 @@ 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;
@@ -801,6 +871,7 @@ 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;
@@ -811,6 +882,7 @@ 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;
@@ -821,6 +893,7 @@ 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;
@@ -831,6 +904,7 @@ 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;
@@ -841,6 +915,7 @@ 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;
@@ -851,6 +926,7 @@ 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;
@@ -861,6 +937,7 @@ 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;
@@ -871,6 +948,7 @@ 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;
@@ -881,6 +959,7 @@ 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;
@@ -891,6 +970,7 @@ 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;
@@ -901,6 +981,7 @@ 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;
@@ -911,6 +992,7 @@ 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;
@@ -933,6 +1015,8 @@ 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);
@@ -943,8 +1027,6 @@ 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);
@@ -1141,6 +1223,9 @@ 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);
@@ -1156,9 +1241,6 @@ 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);

View File

@@ -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" */

View File

@@ -662,6 +662,7 @@ 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)
{
@@ -791,7 +792,6 @@ 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,45 +806,6 @@ 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;
@@ -919,10 +880,6 @@ 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);
}
@@ -930,10 +887,6 @@ 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);

View File

@@ -114,10 +114,6 @@ 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;

View File

@@ -18,7 +18,6 @@
*/
#include "uhub.h"
#include "plugin_api/handle.h"
static void log_user_login(struct hub_user* u)
{
@@ -68,10 +67,6 @@ 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);
@@ -114,11 +109,6 @@ 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);
}

View File

@@ -115,6 +115,11 @@ 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)

View File

@@ -175,10 +175,8 @@ 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 (;;)
{
@@ -196,18 +194,19 @@ void net_on_accept(struct net_connection* con, int event, void *arg)
}
}
#ifdef PLUGIN_SUPPORT
status = plugin_check_ip_early(hub, &ipaddr);
if (status == st_deny)
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))
{
plugin_log_connection_denied(hub, &ipaddr);
LOG_INFO("Denied [%s] (IP banned)", addr);
net_close(fd);
continue;
}
plugin_log_connection_accepted(hub, &ipaddr);
#endif
probe = probe_create(hub, fd, &ipaddr);
if (!probe)
{

View File

@@ -1,89 +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/>.
*
*/
#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;
}

View File

@@ -1,46 +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_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

View File

@@ -1,187 +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/>.
*
*/
#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 */

View File

@@ -1,62 +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_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 */

View File

@@ -49,7 +49,17 @@ static void probe_net_event(struct net_connection* con, int events, void *arg)
#ifdef SSL_SUPPORT
if (probe->hub->config->tls_enable && probe->hub->config->tls_require)
{
LOG_TRACE("Not TLS connection - closing connection.");
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
@@ -60,9 +70,8 @@ static void probe_net_event(struct net_connection* con, int events, void *arg)
probe_destroy(probe);
return;
}
#ifdef SSL_SUPPORT
if (bytes >= 11 &&
else if (bytes >= 11 &&
probe_recvbuf[0] == 22 &&
probe_recvbuf[1] == 3 && /* protocol major version */
probe_recvbuf[5] == 1 && /* message type */
@@ -107,6 +116,8 @@ 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);
@@ -118,6 +129,7 @@ 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);

View File

@@ -71,6 +71,12 @@ 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);

View File

@@ -179,6 +179,14 @@ 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;
@@ -196,6 +204,7 @@ 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);
}

View File

@@ -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,6 +251,9 @@ 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);
}

View File

@@ -60,7 +60,6 @@ int net_initialize()
LOG_TRACE("Initializing OpenSSL...");
SSL_library_init();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
#endif /* SSL_SUPPORT */
net_initialized = 1;
@@ -100,7 +99,9 @@ int net_destroy()
net_backend_shutdown();
#ifdef SSL_SUPPORT
/* FIXME: Shutdown OpenSSL here. */
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
#endif
#ifdef WINSOCK

View File

@@ -1,153 +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_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 */

View File

@@ -1,28 +0,0 @@
/**
* 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;
}

View File

@@ -1,57 +0,0 @@
/**
* 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;
}

View File

@@ -89,8 +89,6 @@
#include <pwd.h>
#include <sys/resource.h>
#define HAVE_STRNDUP
#define HAVE_DLOPEN
#include <dlfcn.h>
#ifndef __HAIKU__
#define HAVE_MEMMEM
#endif

View File

@@ -45,7 +45,6 @@
#define MAX_CID_LEN 39
#define MAX_NICK_LEN 64
#define MAX_PASS_LEN 64
#define MAX_UA_LEN 32
#define TIGERSIZE 24
@@ -81,13 +80,10 @@ 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
}

View File

@@ -448,3 +448,24 @@ 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;
}

View File

@@ -34,6 +34,7 @@ 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);

View File

@@ -5,7 +5,7 @@
#endif
#ifndef VERSION
#define VERSION "0.3.1"
#define VERSION "0.3.3"
#endif
#ifndef GIT_REVISION
@@ -14,7 +14,7 @@
#else
#define REVISION "(git: " GIT_REVISION ")"
#ifdef GIT_VERSION
#define PRODUCT_STRING PRODUCT "/" GIT_VERSION
#define PRODUCT_STRING PRODUCT "/" VERSION " (" GIT_VERSION ")"
#else
#define PRODUCT_STRING PRODUCT "/" VERSION " " REVISION
#endif