From 7c093dc5da0b6b6d65ae32bf6bec2898dff15b00 Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Fri, 4 Dec 2009 08:12:54 +0100 Subject: [PATCH 1/6] Fix for very long messages that get dropped if they are sent alone (no other message before it) and does not fit inside one TCP packet. (Thanks FleetCommand!) --- src/core/netevent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/netevent.c b/src/core/netevent.c index 3631e27..e5f355c 100644 --- a/src/core/netevent.c +++ b/src/core/netevent.c @@ -121,11 +121,11 @@ int handle_net_read(struct hub_user* user) start = pos; } - if (lastPos) + if (lastPos || remaining) { if (remaining < g_hub->config->max_recv_buffer) { - hub_recvq_set(q, lastPos, remaining); + hub_recvq_set(q, lastPos ? lastPos : buf, remaining); } else { From 50f5ce9d321cc7853898b0b171c608dd72ec778e Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Wed, 9 Dec 2009 19:30:08 +0100 Subject: [PATCH 2/6] Fix bug #100 - Null pointer crash if sending a chat message without the message part. --- src/core/hub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/hub.c b/src/core/hub.c index dbf92e6..1946383 100644 --- a/src/core/hub.c +++ b/src/core/hub.c @@ -183,7 +183,10 @@ int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc char* message = adc_msg_get_argument(cmd, 0); int ret = 0; int relay = 1; - + + if (!message) + return 0; + if ((cmd->cache[0] == 'B') && (message[0] == '!' || message[0] == '+')) { /* From 1f9cfe58c4bd470fe477373189e09e11c71a11d4 Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Wed, 9 Dec 2009 19:40:12 +0100 Subject: [PATCH 3/6] No need to allow users not yet logged in to send special hub commands to the hub. Nothing bad will happen, except the hub will try to answer them even though the user is not yet fully logged in. This fix ensures that these messages are simply dropped instead. --- src/core/hub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/hub.c b/src/core/hub.c index 1946383..03d6c43 100644 --- a/src/core/hub.c +++ b/src/core/hub.c @@ -184,7 +184,7 @@ int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc int ret = 0; int relay = 1; - if (!message) + if (!message || !user_is_logged_in(u)) return 0; if ((cmd->cache[0] == 'B') && (message[0] == '!' || message[0] == '+')) @@ -211,7 +211,7 @@ int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc relay = 0; } - if (relay && user_is_logged_in(u)) + if (relay) { /* adc_msg_remove_named_argument(cmd, "PM"); */ if (cmd->cache[0] == 'B') From a643bb123dcd2653b8f7cc2f298c27defa1f1a25 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 13 Jan 2010 16:27:07 +0300 Subject: [PATCH 4/6] Add init.d files for RedHat\CentOS --- doc/init.d.RedHat/etc/init.d/uhub | 101 +++++++++++++++++++++++++++ doc/init.d.RedHat/etc/sysconfig/uhub | 15 ++++ 2 files changed, 116 insertions(+) create mode 100755 doc/init.d.RedHat/etc/init.d/uhub create mode 100644 doc/init.d.RedHat/etc/sysconfig/uhub diff --git a/doc/init.d.RedHat/etc/init.d/uhub b/doc/init.d.RedHat/etc/init.d/uhub new file mode 100755 index 0000000..f7db25c --- /dev/null +++ b/doc/init.d.RedHat/etc/init.d/uhub @@ -0,0 +1,101 @@ +#!/bin/sh +# +# chkconfig: - 91 35 +# description: Starts and stops the Uhub ( http://www.extatic.org/uhub ) daemons on RHEL\CentOS \ +# used to provide p2p network services. +# +# pidfile: /var/run/uhub.pid +# config: /etc/uhub/uhub.conf + + + +# Source function library. +if [ -f /etc/init.d/functions ] ; then + . /etc/init.d/functions +elif [ -f /etc/rc.d/init.d/functions ] ; then + . /etc/rc.d/init.d/functions +else + exit 1 +fi + +# Avoid using root's TMPDIR +unset TMPDIR + +# Source networking configuration. +. /etc/sysconfig/network + +if [ -f /etc/sysconfig/uhub ]; then + . /etc/sysconfig/uhub +fi + +# Check that networking is up. +[ ${NETWORKING} = "no" ] && exit 1 + +# Check that uhub.conf exists. +[ -f /etc/uhub/uhub.conf ] || exit 6 + +RETVAL=0 + + +start() { + KIND="UHUB" + echo -n $"Starting $KIND services: " + daemon uhub $UHUBOPTIONS + RETVAL=$? + echo "" + return $RETVAL +} + +stop() { + KIND="UHUB" + echo -n $"Shutting down $KIND services: " + killproc uhub + RETVAL=$? + echo "" + return $RETVAL +} + +restart() { + stop + start +} + +reload() { + echo -n $"Reloading uhub.conf / user.conf file: " + killproc uhub -HUP + RETVAL=$? + echo "" + return $RETVAL +} + +rhstatus() { + status uhub + RETVAL=$? + if [ $RETVAL -ne 0 ] ; then + return $RETVAL + fi +} + + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + reload) + reload + ;; + status) + rhstatus + ;; + *) + echo $"Usage: $0 {start|stop|restart|reload|status}" + exit 2 +esac + +exit $? diff --git a/doc/init.d.RedHat/etc/sysconfig/uhub b/doc/init.d.RedHat/etc/sysconfig/uhub new file mode 100644 index 0000000..cb5f6d3 --- /dev/null +++ b/doc/init.d.RedHat/etc/sysconfig/uhub @@ -0,0 +1,15 @@ +# Options to UHUB +# -v Verbose mode. Add more -v's for higher verbosity. +# -q Quiet mode - no output +# -f Fork to background +# -l Log messages to given file (default: stderr) +# -L Log messages to syslog +# -c Specify configuration file (default: /etc/uhub/uhub.conf) +# -S Show configuration parameters, but ignore defaults +# -u Run as given user +# -g Run with given group permissions +# -p Store pid in file (process id) + + +UHUBOPTIONS=" -u uhub -f -p /var/run/uhub.pid -l /var/log/uhub.log" + From 23daa42b72b81a1c68e911c1f01e2d7145b7792b Mon Sep 17 00:00:00 2001 From: lv77 Date: Thu, 14 Jan 2010 09:46:55 +0300 Subject: [PATCH 5/6] Add TODO file. Some modify example uhub.conf --- TODO | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..e69de29 From eb5d3936a9234dc413bdc622d228db97c4b04c96 Mon Sep 17 00:00:00 2001 From: lv77 Date: Thu, 14 Jan 2010 09:49:03 +0300 Subject: [PATCH 6/6] Add TODO file. Some modify example uhub.conf --- doc/uhub.conf | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/uhub.conf b/doc/uhub.conf index 4539108..eaf234f 100644 --- a/doc/uhub.conf +++ b/doc/uhub.conf @@ -4,7 +4,8 @@ # # This file is read only to the uhub deamon, and if you # make changes to it while uhub is running you can send a -# HUP signal to it, to reparse configuration (only on UNIX). +# HUP signal to it ( $ killall -HUP uhub ), to reparse configuration (only on UNIX). +# All configuration directives: http://www.uhub.org/config.php # Bind to this port and address # server_bind_addr=any means listen to "::" if IPv6 is supported @@ -38,6 +39,23 @@ file_acl=/etc/uhub/users.conf # Normally this message is sent to clients when connecting. file_motd=/etc/uhub/motd.txt +# Slots\share\hubs limits +limit_max_hubs_user = 0 +limit_max_hubs_reg = 0 +limit_max_hubs_op = 0 +limit_max_hubs = 0 +limit_min_hubs_user = 0 +limit_min_hubs_reg = 0 +limit_min_hubs_op = 0 +limit_min_share = 0 +# Example: +# To require users to share at least 1 GB in order to enter the hub: +# limit_min_share = 1024 +limit_max_share = 0 +limit_min_slots = 0 +limit_max_slots = 0 + + # Configure status message as sent to clients in different circumstances. msg_hub_full = Hub is full msg_hub_disabled = Hub is disabled @@ -61,6 +79,12 @@ msg_ban_permanently = Banned permanently msg_ban_temporarily = Banned temporarily msg_auth_invalid_password = Password is wrong msg_auth_user_not_found = User not found in password database +msg_user_share_size_low = User is not sharing enough +msg_user_share_size_high = User is sharing too much +msg_user_slots_low = User have too few upload slots +msg_user_slots_high = User have too many upload slots +msg_user_hub_limit_low = User is on too few hubs +msg_user_hub_limit_high = User is on too many hubs msg_error_no_memory = No memory