Compare commits
58 Commits
event_queu
...
libevent_w
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
478d8b9dd2 | ||
|
|
904288a2a2 | ||
|
|
de95d4ed85 | ||
|
|
97b53a99fb | ||
|
|
ae017af758 | ||
|
|
7a02f92a4c | ||
|
|
adeebb92a0 | ||
|
|
26f1864c1f | ||
|
|
c14fa3c3a9 | ||
|
|
dfd2191103 | ||
|
|
0042344054 | ||
|
|
8af965c0ca | ||
|
|
b3d3dcdb44 | ||
|
|
cb6190c5b4 | ||
|
|
82ad62602d | ||
|
|
6d34bdd7e2 | ||
|
|
c2832e59c0 | ||
|
|
cf23c82c16 | ||
|
|
8bf0fd424a | ||
|
|
8f8284eb29 | ||
|
|
015c3368bd | ||
|
|
9186b441aa | ||
|
|
74af392e80 | ||
|
|
3a270564d2 | ||
|
|
f0938e8afa | ||
|
|
156c137237 | ||
|
|
7aeb8651ba | ||
|
|
ab4eb6db3d | ||
|
|
13a8700554 | ||
|
|
5d5dda2f9b | ||
|
|
95b741bb5e | ||
|
|
90abf64e3a | ||
|
|
e9915df87c | ||
|
|
408829e330 | ||
|
|
1a1b5bdb38 | ||
|
|
abedec692a | ||
|
|
7738baf38e | ||
|
|
3c4c52d0f9 | ||
|
|
76588fb1bd | ||
|
|
f9e95ec582 | ||
|
|
7985d4fed0 | ||
|
|
77343d3c21 | ||
|
|
f8d5b72a89 | ||
|
|
cf2994b570 | ||
|
|
7a9d40d8dd | ||
|
|
b1f84b5b4a | ||
|
|
998c6c36ce | ||
|
|
4112b8111a | ||
|
|
1929f2fae7 | ||
|
|
77e41371b5 | ||
|
|
0266c8bb9c | ||
|
|
5e3eabb677 | ||
|
|
669ab14022 | ||
|
|
1d491055c5 | ||
|
|
08351ea8e7 | ||
|
|
e2ac690164 | ||
|
|
3bb563b432 | ||
|
|
e10582fec2 |
15
ChangeLog
15
ChangeLog
@@ -1,4 +1,19 @@
|
|||||||
|
0.2.8:
|
||||||
|
- Fix bug #13: getsockname() failure, use sockaddr from accept() instead.
|
||||||
|
- Fix bug #10: Improve logging, ensure logs are machine readable.
|
||||||
|
- Fix bug #12: asserts in adc_msg_parse -> enabled strict utf8 parsing.
|
||||||
|
|
||||||
|
|
||||||
0.2.7:
|
0.2.7:
|
||||||
|
- Fixed a nasty crash (bug #11), Thanks Toast for finding it.
|
||||||
|
- Fix bug #9 - net_get_peer_address() failure on CentOS/Xen configurations.
|
||||||
|
- Write a log message if an operator reloads the config file.
|
||||||
|
- Don't print OK or ERROR when using '-s' or '-S' show the configuration.
|
||||||
|
- Cleanup credential string handling
|
||||||
|
- Made sure "!help" only display accessible commands.
|
||||||
|
- Cleanup in-hub command parsing
|
||||||
|
- Fix a possible crash if multiple INF messages are sent during login.
|
||||||
|
- Rewrote the mainloop to not use a timer.
|
||||||
|
|
||||||
|
|
||||||
0.2.6:
|
0.2.6:
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ BIN_EXT ?= .exe
|
|||||||
else
|
else
|
||||||
DESTDIR ?= /
|
DESTDIR ?= /
|
||||||
UHUB_CONF_DIR ?= $(DESTDIR)/etc/uhub
|
UHUB_CONF_DIR ?= $(DESTDIR)/etc/uhub
|
||||||
UHUB_PREFIX ?= $(DESTDIR)/usr/
|
UHUB_PREFIX ?= $(DESTDIR)/usr/local
|
||||||
CFLAGS += -I/usr/local/include
|
CFLAGS += -I/usr/local/include
|
||||||
LDFLAGS += -L/usr/local/lib
|
LDFLAGS += -L/usr/local/lib
|
||||||
BIN_EXT ?=
|
BIN_EXT ?=
|
||||||
|
|||||||
@@ -6,25 +6,30 @@ else
|
|||||||
HOST_MACHINE=`uname -m | tr [:upper:] [:lower:] | sed s/i686/i386/ | sed s/x86_64/amd64/ | sed s/ppc64/powerpc/`
|
HOST_MACHINE=`uname -m | tr [:upper:] [:lower:] | sed s/i686/i386/ | sed s/x86_64/amd64/ | sed s/ppc64/powerpc/`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
BINSUFFIX=
|
||||||
|
MAKEARGS=
|
||||||
|
MAKE=make
|
||||||
|
WANTZIP=0
|
||||||
|
|
||||||
if [ "${HOST_SYSTEM}" = "mingw32_nt-5.1" ]; then
|
if [ "${HOST_SYSTEM}" = "mingw32_nt-5.1" ]; then
|
||||||
HOST_SYSTEM=win32
|
HOST_SYSTEM=win32
|
||||||
BINARY=uhub.exe
|
BINSUFFIX=.exe
|
||||||
WANTZIP=1
|
WANTZIP=1
|
||||||
else
|
MAKEARGS="USE_BIGENDIAN=NO"
|
||||||
WANTZIP=0
|
|
||||||
BINARY=uhub
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
BINARY=uhub${BINSUFFIX}
|
||||||
|
|
||||||
|
if [ "${HOST_SYSTEM}" = "freebsd" ]; then
|
||||||
|
MAKE=gmake
|
||||||
|
fi
|
||||||
|
|
||||||
VERSION=`grep define\ VERSION version.h | cut -f 3 -d " " | tr -d [=\"=]`
|
VERSION=`grep define\ VERSION version.h | cut -f 3 -d " " | tr -d [=\"=]`
|
||||||
SNAPSHOT=`date '+%Y%m%d'`
|
SNAPSHOT=`date '+%Y%m%d'`
|
||||||
PACKAGE=uhub-${VERSION}
|
PACKAGE=uhub-${VERSION}
|
||||||
PACKAGE_SRC=${PACKAGE}-src
|
PACKAGE_SRC=${PACKAGE}-src
|
||||||
PACKAGE_BIN=${PACKAGE}-${HOST_SYSTEM}-${HOST_MACHINE}
|
PACKAGE_BIN=${PACKAGE}-${HOST_SYSTEM}-${HOST_MACHINE}
|
||||||
|
ARCHIVE='build-archive:~/www/downloads/uhub/'
|
||||||
URL_ARCHIVE='build-archive:~/uhub/'
|
|
||||||
URL_PUBLISH='domeneshop:~/www/downloads/uhub/'
|
|
||||||
URL_SNAPSHOT='domeneshop:~/www/downloads/uhub/snapshots/'
|
|
||||||
|
|
||||||
function export_source_directory
|
function export_source_directory
|
||||||
{
|
{
|
||||||
@@ -51,45 +56,85 @@ function package_zips
|
|||||||
gzip -c -9 $1.tar > $1.tar.gz
|
gzip -c -9 $1.tar > $1.tar.gz
|
||||||
bzip2 -c -9 $1.tar > $1.tar.bz2
|
bzip2 -c -9 $1.tar > $1.tar.bz2
|
||||||
rm -f $1.tar
|
rm -f $1.tar
|
||||||
|
|
||||||
|
if [ $WANTZIP -eq 1 ]; then
|
||||||
zip -q -9 -r $1.zip $2
|
zip -q -9 -r $1.zip $2
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function export_sources
|
function export_sources
|
||||||
{
|
{
|
||||||
|
if [ ! -d ${PACKAGE} ]; then
|
||||||
export_source_directory
|
export_source_directory
|
||||||
make autotest.c && cp autotest.c ${PACKAGE}/autotest.c
|
fi
|
||||||
rm -Rf ${PACKAGE}/admin
|
|
||||||
|
|
||||||
|
cd ${PACKAGE}
|
||||||
|
${MAKE} ${MAKEARGS} autotest.c
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
if [ ! -f ${PACKAGE}/autotest.c ]; then
|
||||||
|
echo "Unable to create autotest.c, aborting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -Rf ${PACKAGE}/admin
|
||||||
package_zips ${PACKAGE_SRC} ${PACKAGE}
|
package_zips ${PACKAGE_SRC} ${PACKAGE}
|
||||||
|
|
||||||
rm -Rf ${PACKAGE};
|
rm -Rf ${PACKAGE};
|
||||||
cp ChangeLog ChangeLog-${VERSION}
|
cp ChangeLog ChangeLog-${VERSION}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function build_binaries
|
||||||
|
{
|
||||||
|
if [ ! -d ${PACKAGE} ]; then
|
||||||
|
export_source_directory
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ${PACKAGE}
|
||||||
|
${MAKE} ${MAKEARGS} RELEASE=YES
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
if [ ! -x ${PACKAGE}/${BINARY} ]; then
|
||||||
|
echo "Build failed, no binary found..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function export_binaries
|
function export_binaries
|
||||||
{
|
{
|
||||||
export_source_directory
|
build_binaries
|
||||||
|
|
||||||
rm -Rf ${PACKAGE}/admin
|
rm -Rf ${PACKAGE}/admin
|
||||||
rm -Rf ${PACKAGE}/autotest
|
rm -Rf ${PACKAGE}/autotest
|
||||||
rm -Rf ${PACKAGE}/src
|
rm -Rf ${PACKAGE}/src
|
||||||
|
rm -Rf ${PACKAGE}/debian
|
||||||
rm -f ${PACKAGE}/autotest.c
|
rm -f ${PACKAGE}/autotest.c
|
||||||
rm -f ${PACKAGE}/*akefile
|
rm -f ${PACKAGE}/*akefile
|
||||||
rm -f ${PACKAGE}/version.h
|
rm -f ${PACKAGE}/version.h
|
||||||
rm -f ${PACKAGE}/doc/Doxyfile
|
rm -f ${PACKAGE}/doc/Doxyfile
|
||||||
rm -f ${PACKAGE}/doc/uhub.dot
|
rm -f ${PACKAGE}/doc/uhub.dot
|
||||||
|
rm -f ${PACKAGE}/libuhub*
|
||||||
make
|
|
||||||
|
|
||||||
if [ -x ${BINARY} ]; then
|
|
||||||
cp ${BINARY} ${PACKAGE}
|
|
||||||
else
|
|
||||||
echo "No binary found!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
package_zips ${PACKAGE_BIN} ${PACKAGE}
|
package_zips ${PACKAGE_BIN} ${PACKAGE}
|
||||||
|
rm -Rf ${PACKAGE}
|
||||||
|
}
|
||||||
|
|
||||||
rm -Rf ${PACKAGE};
|
function upload_pkg
|
||||||
|
{
|
||||||
|
if [ -f $1 ]; then
|
||||||
|
scp $1 ${ARCHIVE}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function upload_packages
|
||||||
|
{
|
||||||
|
upload_pkg ${PACKAGE_SRC}.tar.gz
|
||||||
|
upload_pkg ${PACKAGE_SRC}.tar.bz2
|
||||||
|
upload_pkg ${PACKAGE_SRC}.zip
|
||||||
|
upload_pkg ChangeLog-${VERSION}
|
||||||
|
upload_pkg ${PACKAGE_BIN}.tar.gz
|
||||||
|
upload_pkg ${PACKAGE_BIN}.tar.bz2
|
||||||
|
upload_pkg ${PACKAGE_BIN}.zip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
admin/export.sh
Executable file
3
admin/export.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
. admin/common.sh
|
||||||
|
export_source_directory
|
||||||
95
admin/make_pkg_deb.sh
Executable file
95
admin/make_pkg_deb.sh
Executable file
@@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
. admin/common.sh
|
||||||
|
|
||||||
|
export_source_directory
|
||||||
|
build_binaries
|
||||||
|
|
||||||
|
DEB_REVISION=1
|
||||||
|
|
||||||
|
if [ -d deb ]; then
|
||||||
|
rm -Rf deb
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p \
|
||||||
|
deb/DEBIAN \
|
||||||
|
deb/usr/bin \
|
||||||
|
deb/usr/share/man/man1/ \
|
||||||
|
deb/usr/share/doc/uhub \
|
||||||
|
deb/etc/uhub \
|
||||||
|
|| exit 1
|
||||||
|
|
||||||
|
find deb -type d | xargs chmod 755
|
||||||
|
|
||||||
|
# Copy binaries...
|
||||||
|
cp ${PACKAGE}/${BINARY} deb/usr/bin
|
||||||
|
strip deb/usr/bin/${BINARY}
|
||||||
|
|
||||||
|
# Copy configuration files...
|
||||||
|
cp ${PACKAGE}/doc/uhub.conf deb/etc/uhub
|
||||||
|
cp ${PACKAGE}/doc/users.conf deb/etc/uhub
|
||||||
|
echo "Welcome to uHub" > deb/etc/uhub/motd.txt
|
||||||
|
|
||||||
|
# Copy other files
|
||||||
|
cp ${PACKAGE}/README deb/usr/share/doc/uhub
|
||||||
|
cp ${PACKAGE}/AUTHORS deb/usr/share/doc/uhub
|
||||||
|
gzip -c --best < ${PACKAGE}/ChangeLog > deb/usr/share/doc/uhub/changelog.gz
|
||||||
|
gzip -c --best < ${PACKAGE}/doc/uhub.1 > deb/usr/share/man/man1/uhub.1.gz
|
||||||
|
|
||||||
|
cat > deb/usr/share/doc/uhub/copyright <<EOF
|
||||||
|
uHub - a high performance hub for the ADC peer-to-peer network
|
||||||
|
|
||||||
|
Copyright (C) 2007-2009 Jan Vidar Krey <janvidar@extatic.org>
|
||||||
|
|
||||||
|
uHub is free and open source software, licensed under the
|
||||||
|
GNU General Public License version 3.
|
||||||
|
|
||||||
|
For details, see /usr/share/common-licenses/GPL-3
|
||||||
|
EOF
|
||||||
|
|
||||||
|
gzip -c --best > deb/usr/share/doc/uhub/changelog.Debian.gz <<EOF
|
||||||
|
uhub (${VERSION}) stable; urgency=low
|
||||||
|
|
||||||
|
* See changelog.gz for details.
|
||||||
|
|
||||||
|
-- Jan Vidar Krey <janvidar@extatic.org> `date -R`
|
||||||
|
EOF
|
||||||
|
|
||||||
|
### Write control files
|
||||||
|
cd deb
|
||||||
|
echo "/etc/uhub/uhub.conf" > DEBIAN/conffiles
|
||||||
|
echo "/etc/uhub/users.conf" >> DEBIAN/conffiles
|
||||||
|
echo "/etc/uhub/motd.txt" >> DEBIAN/conffiles
|
||||||
|
|
||||||
|
md5sum `find usr -type f` > DEBIAN/md5sums
|
||||||
|
|
||||||
|
INSTALL_SIZE=`du -s | cut -f 1`
|
||||||
|
|
||||||
|
cat > DEBIAN/control <<EOF
|
||||||
|
Package: uhub
|
||||||
|
Version: ${VERSION}-${DEB_REVISION}
|
||||||
|
Architecture: ${HOST_MACHINE}
|
||||||
|
Maintainer: Jan Vidar Krey <janvidar@extatic.org>
|
||||||
|
Installed-Size: ${INSTALL_SIZE}
|
||||||
|
Depends: libc6 (>= 2.7-1), libevent1 (>= 1.3e-1)
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Description: a high performance hub for the ADC peer-to-peer network
|
||||||
|
uHub is a high performance peer-to-peer hub for the ADC network.
|
||||||
|
Its low memory footprint allows it to handle several thousand users
|
||||||
|
on high-end servers, or a small private hub on embedded hardware.
|
||||||
|
.
|
||||||
|
Homepage: http://www.extatic.org/uhub/
|
||||||
|
EOF
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
### Create deb file
|
||||||
|
fakeroot dpkg-deb --build deb
|
||||||
|
mv deb.deb uhub_${VERSION}-${DEB_REVISION}_${HOST_MACHINE}.deb
|
||||||
|
|
||||||
|
### Check for errors
|
||||||
|
lintian uhub_${VERSION}-${DEB_REVISION}_${HOST_MACHINE}.deb
|
||||||
|
|
||||||
|
### Cleanup
|
||||||
|
rm -Rf deb
|
||||||
|
rm -Rf ${PACKAGE}
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# set -x
|
|
||||||
|
|
||||||
ME=`dirname $0`
|
|
||||||
. ${ME}/common.sh
|
|
||||||
|
|
||||||
# Git Export
|
|
||||||
export_sources
|
|
||||||
export_binaries
|
|
||||||
|
|
||||||
3
admin/release_binaries.sh
Executable file
3
admin/release_binaries.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
. admin/common.sh
|
||||||
|
export_binaries
|
||||||
4
admin/release_sources.sh
Executable file
4
admin/release_sources.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
. admin/common.sh
|
||||||
|
WANTZIP=1
|
||||||
|
export_sources
|
||||||
26
admin/setup_archive.sh
Executable file
26
admin/setup_archive.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PUB="${HOME}/.ssh/id_rsa.pub"
|
||||||
|
CFG="${HOME}/.ssh/config"
|
||||||
|
|
||||||
|
if [ ! "`grep build-archive ${CFG}`" ]; then
|
||||||
|
echo "Updating ssh config (${CFG})..."
|
||||||
|
cat >> ${CFG} <<EOF
|
||||||
|
|
||||||
|
Host build-archive
|
||||||
|
ForwardX11 no
|
||||||
|
HostName login.domeneshop.no
|
||||||
|
User extatic
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
echo "ssh config seems OK (${CFG})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f ${PUB} ]; then
|
||||||
|
echo "No id_rsa.pub - run ssh-keygen"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Copying public key (${PUB})..."
|
||||||
|
cat ${PUB} | ssh build-archive "cat >> .ssh/authorized_keys"
|
||||||
|
|
||||||
3
admin/upload.sh
Executable file
3
admin/upload.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
. admin/common.sh
|
||||||
|
upload_packages
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
static struct event_queue* eq;
|
static struct event_queue* eq;
|
||||||
static int eq_val;
|
static int eq_val;
|
||||||
struct event* libevent_handle;
|
|
||||||
|
|
||||||
static void eq_callback(void* callback_data, struct event_data* event_data)
|
static void eq_callback(void* callback_data, struct event_data* event_data)
|
||||||
{
|
{
|
||||||
@@ -17,8 +16,6 @@ EXO_TEST(eventqueue_init_1, {
|
|||||||
|
|
||||||
EXO_TEST(eventqueue_init_2, {
|
EXO_TEST(eventqueue_init_2, {
|
||||||
/* hack */
|
/* hack */
|
||||||
libevent_handle = eq->event;
|
|
||||||
eq->event = 0;
|
|
||||||
return eq->callback_data == &eq_val && eq->callback == eq_callback && eq->q1 && eq->q2 && !eq->locked;
|
return eq->callback_data == &eq_val && eq->callback == eq_callback && eq->q1 && eq->q2 && !eq->locked;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,7 +78,6 @@ EXO_TEST(eventqueue_size_4, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
EXO_TEST(eventqueue_shutdown_1, {
|
EXO_TEST(eventqueue_shutdown_1, {
|
||||||
eq->event = libevent_handle;
|
|
||||||
event_queue_shutdown(eq);
|
event_queue_shutdown(eq);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -144,12 +144,29 @@ EXO_TEST(adc_message_parse_20, {
|
|||||||
return ok;
|
return ok;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
EXO_TEST(adc_message_parse_21, {
|
EXO_TEST(adc_message_parse_21, {
|
||||||
struct adc_message* msg = adc_msg_parse_verify(g_user, "EMSG AAAC AAAB Hello\\sthere!\n", 29);
|
struct adc_message* msg = adc_msg_parse_verify(g_user, "EMSG AAAC AAAB Hello\\sthere!\n", 29);
|
||||||
return msg == NULL;
|
return msg == NULL;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EXO_TEST(adc_message_parse_22, {
|
||||||
|
struct adc_message* msg = adc_msg_parse_verify(g_user, "\n", 0);
|
||||||
|
return msg == NULL;
|
||||||
|
});
|
||||||
|
|
||||||
|
EXO_TEST(adc_message_parse_23, {
|
||||||
|
struct adc_message* msg = adc_msg_parse_verify(g_user, "\r\n", 1);
|
||||||
|
return msg == NULL;
|
||||||
|
});
|
||||||
|
|
||||||
|
EXO_TEST(adc_message_parse_24, {
|
||||||
|
struct adc_message* msg = adc_msg_parse_verify(g_user, "EMSG AAAC\0AAAB Hello\\sthere!\n", 29);
|
||||||
|
return msg == NULL;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EXO_TEST(adc_message_add_arg_1, {
|
EXO_TEST(adc_message_add_arg_1, {
|
||||||
struct adc_message* msg = adc_msg_create(test_string1);
|
struct adc_message* msg = adc_msg_create(test_string1);
|
||||||
adc_msg_add_argument(msg, "XXwtf?");
|
adc_msg_add_argument(msg, "XXwtf?");
|
||||||
|
|||||||
@@ -100,4 +100,12 @@ EXO_TEST(utf8_valid_3, { return is_valid_utf8("0123456789"); });
|
|||||||
EXO_TEST(utf8_valid_4, { return is_valid_utf8( (char[]) { 0x65, 0x00} ); });
|
EXO_TEST(utf8_valid_4, { return is_valid_utf8( (char[]) { 0x65, 0x00} ); });
|
||||||
EXO_TEST(utf8_valid_5, { return !is_valid_utf8( (char[]) { 0xD8, 0x00} ); });
|
EXO_TEST(utf8_valid_5, { return !is_valid_utf8( (char[]) { 0xD8, 0x00} ); });
|
||||||
|
|
||||||
|
EXO_TEST(utf8_valid_6, { return is_valid_utf8( (char[]) { 0x24, 0x00} ); });
|
||||||
|
EXO_TEST(utf8_valid_7, { return !is_valid_utf8( (char[]) { 0xC2, 0x24, 0x00} ); });
|
||||||
|
EXO_TEST(utf8_valid_8, { return is_valid_utf8( (char[]) { 0xC2, 0xA2, 0x00} ); });
|
||||||
|
EXO_TEST(utf8_valid_9, { return is_valid_utf8( (char[]) { 0xE2, 0x82, 0xAC, 0x00} ); });
|
||||||
|
EXO_TEST(utf8_valid_10, { return !is_valid_utf8( (char[]) { 0xC2, 0x32, 0x00} ); });
|
||||||
|
EXO_TEST(utf8_valid_11, { return !is_valid_utf8( (char[]) { 0xE2, 0x82, 0x32, 0x00} ); });
|
||||||
|
EXO_TEST(utf8_valid_12, { return !is_valid_utf8( (char[]) { 0xE2, 0x32, 0x82, 0x00} ); });
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
debian/changelog
vendored
5
debian/changelog
vendored
@@ -1,5 +0,0 @@
|
|||||||
uhub (0.2.6-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
|
|
||||||
|
|
||||||
-- Jan Vidar Krey <janvidar@extatic.org> Tue, 17 Mar 2009 00:38:12 +0100
|
|
||||||
1
debian/compat
vendored
1
debian/compat
vendored
@@ -1 +0,0 @@
|
|||||||
7
|
|
||||||
3
debian/conffiles
vendored
3
debian/conffiles
vendored
@@ -1,3 +0,0 @@
|
|||||||
etc/uhub/uhub.conf
|
|
||||||
etc/uhub/users.conf
|
|
||||||
etc/uhub/motd.txt
|
|
||||||
15
debian/control
vendored
15
debian/control
vendored
@@ -1,15 +0,0 @@
|
|||||||
Source: uhub
|
|
||||||
Section: net
|
|
||||||
Priority: extra
|
|
||||||
Maintainer: Jan Vidar Krey <janvidar@extatic.org>
|
|
||||||
Build-Depends: debhelper (>= 7)
|
|
||||||
Standards-Version: 3.8.1
|
|
||||||
Homepage: http://www.extatic.org/uhub/
|
|
||||||
|
|
||||||
Package: uhub
|
|
||||||
Architecture: any
|
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
|
||||||
Description: uHub is a high performance peer-to-peer hub for the ADC network.
|
|
||||||
Its low memory footprint allows it to handle several thousand users on high-end servers,
|
|
||||||
or a small private hub on embedded hardware.
|
|
||||||
uHub uses the ADC protocol, and is compatible with DC++, jUCy and other ADC clients.
|
|
||||||
9
debian/copyright
vendored
9
debian/copyright
vendored
@@ -1,9 +0,0 @@
|
|||||||
Copyright:
|
|
||||||
|
|
||||||
Copyright (C) 2008-2009 Jan Vidar Krey <janvidar@extatic.org>
|
|
||||||
|
|
||||||
License:
|
|
||||||
|
|
||||||
Licensed under the GPL version 3,
|
|
||||||
see `/usr/share/common-licenses/GPL-3'.
|
|
||||||
|
|
||||||
1
debian/dirs
vendored
1
debian/dirs
vendored
@@ -1 +0,0 @@
|
|||||||
usr/bin
|
|
||||||
3
debian/docs
vendored
3
debian/docs
vendored
@@ -1,3 +0,0 @@
|
|||||||
BUGS
|
|
||||||
README
|
|
||||||
AUTHORS
|
|
||||||
1
debian/files
vendored
1
debian/files
vendored
@@ -1 +0,0 @@
|
|||||||
uhub_0.2.6-1_amd64.deb net extra
|
|
||||||
157
debian/init.d
vendored
157
debian/init.d
vendored
@@ -1,157 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
#
|
|
||||||
# skeleton example file to build /etc/init.d/ scripts.
|
|
||||||
# This file should be used to construct scripts for /etc/init.d.
|
|
||||||
#
|
|
||||||
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
|
|
||||||
# Modified for Debian
|
|
||||||
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
|
|
||||||
# Further changes by Javier Fernandez-Sanguino <jfs@debian.org>
|
|
||||||
#
|
|
||||||
# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
|
|
||||||
#
|
|
||||||
|
|
||||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
||||||
DAEMON=/usr/bin/uhub
|
|
||||||
NAME=uhub
|
|
||||||
DESC=uhub
|
|
||||||
|
|
||||||
test -x $DAEMON || exit 0
|
|
||||||
|
|
||||||
LOGDIR=/var/log/uhub
|
|
||||||
PIDFILE=/var/run/$NAME.pid
|
|
||||||
DODTIME=1 # Time to wait for the server to die, in seconds
|
|
||||||
# If this value is set too low you might not
|
|
||||||
# let some servers to die gracefully and
|
|
||||||
# 'restart' will not work
|
|
||||||
|
|
||||||
# Include uhub defaults if available
|
|
||||||
if [ -f /etc/default/uhub ] ; then
|
|
||||||
. /etc/default/uhub
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
running_pid()
|
|
||||||
{
|
|
||||||
# Check if a given process pid's cmdline matches a given name
|
|
||||||
pid=$1
|
|
||||||
name=$2
|
|
||||||
[ -z "$pid" ] && return 1
|
|
||||||
[ ! -d /proc/$pid ] && return 1
|
|
||||||
cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
|
|
||||||
# Is this the expected child?
|
|
||||||
[ "$cmd" != "$name" ] && return 1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
running()
|
|
||||||
{
|
|
||||||
# Check if the process is running looking at /proc
|
|
||||||
# (works for all users)
|
|
||||||
|
|
||||||
# No pidfile, probably no daemon present
|
|
||||||
[ ! -f "$PIDFILE" ] && return 1
|
|
||||||
# Obtain the pid and check it against the binary name
|
|
||||||
pid=`cat $PIDFILE`
|
|
||||||
running_pid $pid $DAEMON || return 1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
force_stop() {
|
|
||||||
# Forcefully kill the process
|
|
||||||
[ ! -f "$PIDFILE" ] && return
|
|
||||||
if running ; then
|
|
||||||
kill -15 $pid
|
|
||||||
# Is it really dead?
|
|
||||||
[ -n "$DODTIME" ] && sleep "$DODTIME"s
|
|
||||||
if running ; then
|
|
||||||
kill -9 $pid
|
|
||||||
[ -n "$DODTIME" ] && sleep "$DODTIME"s
|
|
||||||
if running ; then
|
|
||||||
echo "Cannot kill $LABEL (pid=$pid)!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
rm -f $PIDFILE
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
echo -n "Starting $DESC: "
|
|
||||||
start-stop-daemon --start --quiet --pidfile $PIDFILE \
|
|
||||||
--exec $DAEMON -- $DAEMON_OPTS
|
|
||||||
if running ; then
|
|
||||||
echo "$NAME."
|
|
||||||
else
|
|
||||||
echo " ERROR."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
echo -n "Stopping $DESC: "
|
|
||||||
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
|
|
||||||
--exec $DAEMON
|
|
||||||
echo "$NAME."
|
|
||||||
;;
|
|
||||||
force-stop)
|
|
||||||
echo -n "Forcefully stopping $DESC: "
|
|
||||||
force_stop
|
|
||||||
if ! running ; then
|
|
||||||
echo "$NAME."
|
|
||||||
else
|
|
||||||
echo " ERROR."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
reload)
|
|
||||||
#
|
|
||||||
# If the daemon can reload its config files on the fly
|
|
||||||
# for example by sending it SIGHUP, do it here.
|
|
||||||
#
|
|
||||||
# If the daemon responds to changes in its config file
|
|
||||||
# directly anyway, make this a do-nothing entry.
|
|
||||||
#
|
|
||||||
echo "Reloading $DESC configuration files."
|
|
||||||
start-stop-daemon --stop --signal 1 --quiet --pidfile \
|
|
||||||
/var/run/$NAME.pid --exec $DAEMON
|
|
||||||
#;;
|
|
||||||
force-reload)
|
|
||||||
#
|
|
||||||
# If the "reload" option is implemented, move the "force-reload"
|
|
||||||
# option to the "reload" entry above. If not, "force-reload" is
|
|
||||||
# just the same as "restart" except that it does nothing if the
|
|
||||||
# daemon isn't already running.
|
|
||||||
# check wether $DAEMON is running. If so, restart
|
|
||||||
start-stop-daemon --stop --test --quiet --pidfile \
|
|
||||||
/var/run/$NAME.pid --exec $DAEMON \
|
|
||||||
&& $0 restart \
|
|
||||||
|| exit 0
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
echo -n "Restarting $DESC: "
|
|
||||||
start-stop-daemon --stop --quiet --pidfile \
|
|
||||||
/var/run/$NAME.pid --exec $DAEMON
|
|
||||||
[ -n "$DODTIME" ] && sleep $DODTIME
|
|
||||||
start-stop-daemon --start --quiet --pidfile \
|
|
||||||
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
|
|
||||||
echo "$NAME."
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
echo -n "$LABEL is "
|
|
||||||
if running ; then
|
|
||||||
echo "running"
|
|
||||||
else
|
|
||||||
echo " not running."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
N=/etc/init.d/$NAME
|
|
||||||
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
|
|
||||||
echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
39
debian/postinst
vendored
39
debian/postinst
vendored
@@ -1,39 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# postinst script for uhub
|
|
||||||
#
|
|
||||||
# see: dh_installdeb(1)
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# summary of how this script can be called:
|
|
||||||
# * <postinst> `configure' <most-recently-configured-version>
|
|
||||||
# * <old-postinst> `abort-upgrade' <new version>
|
|
||||||
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
||||||
# <new-version>
|
|
||||||
# * <postinst> `abort-remove'
|
|
||||||
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
||||||
# <failed-install-package> <version> `removing'
|
|
||||||
# <conflicting-package> <version>
|
|
||||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
||||||
# the debian-policy package
|
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
configure)
|
|
||||||
;;
|
|
||||||
|
|
||||||
abort-upgrade|abort-remove|abort-deconfigure)
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "postinst called with unknown argument \`$1'" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# dh_installdeb will replace this with shell code automatically
|
|
||||||
# generated by other debhelper scripts.
|
|
||||||
|
|
||||||
#DEBHELPER#
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
37
debian/postrm
vendored
37
debian/postrm
vendored
@@ -1,37 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# postrm script for uhub
|
|
||||||
#
|
|
||||||
# see: dh_installdeb(1)
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# summary of how this script can be called:
|
|
||||||
# * <postrm> `remove'
|
|
||||||
# * <postrm> `purge'
|
|
||||||
# * <old-postrm> `upgrade' <new-version>
|
|
||||||
# * <new-postrm> `failed-upgrade' <old-version>
|
|
||||||
# * <new-postrm> `abort-install'
|
|
||||||
# * <new-postrm> `abort-install' <old-version>
|
|
||||||
# * <new-postrm> `abort-upgrade' <old-version>
|
|
||||||
# * <disappearer's-postrm> `disappear' <overwriter>
|
|
||||||
# <overwriter-version>
|
|
||||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
||||||
# the debian-policy package
|
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "postrm called with unknown argument \`$1'" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# dh_installdeb will replace this with shell code automatically
|
|
||||||
# generated by other debhelper scripts.
|
|
||||||
|
|
||||||
#DEBHELPER#
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
35
debian/preinst
vendored
35
debian/preinst
vendored
@@ -1,35 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# preinst script for uhub
|
|
||||||
#
|
|
||||||
# see: dh_installdeb(1)
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# summary of how this script can be called:
|
|
||||||
# * <new-preinst> `install'
|
|
||||||
# * <new-preinst> `install' <old-version>
|
|
||||||
# * <new-preinst> `upgrade' <old-version>
|
|
||||||
# * <old-preinst> `abort-upgrade' <new-version>
|
|
||||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
||||||
# the debian-policy package
|
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
install|upgrade)
|
|
||||||
;;
|
|
||||||
|
|
||||||
abort-upgrade)
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "preinst called with unknown argument \`$1'" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# dh_installdeb will replace this with shell code automatically
|
|
||||||
# generated by other debhelper scripts.
|
|
||||||
|
|
||||||
#DEBHELPER#
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
38
debian/prerm
vendored
38
debian/prerm
vendored
@@ -1,38 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# prerm script for uhub
|
|
||||||
#
|
|
||||||
# see: dh_installdeb(1)
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# summary of how this script can be called:
|
|
||||||
# * <prerm> `remove'
|
|
||||||
# * <old-prerm> `upgrade' <new-version>
|
|
||||||
# * <new-prerm> `failed-upgrade' <old-version>
|
|
||||||
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
|
|
||||||
# * <deconfigured's-prerm> `deconfigure' `in-favour'
|
|
||||||
# <package-being-installed> <version> `removing'
|
|
||||||
# <conflicting-package> <version>
|
|
||||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
||||||
# the debian-policy package
|
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
remove|upgrade|deconfigure)
|
|
||||||
;;
|
|
||||||
|
|
||||||
failed-upgrade)
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "prerm called with unknown argument \`$1'" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# dh_installdeb will replace this with shell code automatically
|
|
||||||
# generated by other debhelper scripts.
|
|
||||||
|
|
||||||
#DEBHELPER#
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
91
debian/rules
vendored
91
debian/rules
vendored
@@ -1,91 +0,0 @@
|
|||||||
#!/usr/bin/make -f
|
|
||||||
# -*- makefile -*-
|
|
||||||
# Sample debian/rules that uses debhelper.
|
|
||||||
# This file was originally written by Joey Hess and Craig Small.
|
|
||||||
# As a special exception, when this file is copied by dh-make into a
|
|
||||||
# dh-make output file, you may use that output file without restriction.
|
|
||||||
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
|
||||||
|
|
||||||
# Uncomment this to turn on verbose mode.
|
|
||||||
#export DH_VERBOSE=1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
configure: configure-stamp
|
|
||||||
configure-stamp:
|
|
||||||
dh_testdir
|
|
||||||
# Add here commands to configure the package.
|
|
||||||
|
|
||||||
touch configure-stamp
|
|
||||||
|
|
||||||
|
|
||||||
build: build-stamp
|
|
||||||
|
|
||||||
build-stamp: configure-stamp
|
|
||||||
dh_testdir
|
|
||||||
|
|
||||||
# Add here commands to compile the package.
|
|
||||||
$(MAKE)
|
|
||||||
#docbook-to-man debian/uhub.sgml > uhub.1
|
|
||||||
|
|
||||||
touch $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
dh_testdir
|
|
||||||
dh_testroot
|
|
||||||
rm -f build-stamp configure-stamp
|
|
||||||
|
|
||||||
# Add here commands to clean up after the build process.
|
|
||||||
$(MAKE) clean
|
|
||||||
|
|
||||||
dh_clean
|
|
||||||
|
|
||||||
install: build
|
|
||||||
dh_testdir
|
|
||||||
dh_testroot
|
|
||||||
dh_prep
|
|
||||||
dh_installdirs
|
|
||||||
|
|
||||||
# Add here commands to install the package into debian/uhub.
|
|
||||||
$(MAKE) DESTDIR=$(CURDIR)/debian/uhub install
|
|
||||||
|
|
||||||
|
|
||||||
# Build architecture-independent files here.
|
|
||||||
binary-indep: install
|
|
||||||
# We have nothing to do by default.
|
|
||||||
|
|
||||||
# Build architecture-dependent files here.
|
|
||||||
binary-arch: install
|
|
||||||
dh_testdir
|
|
||||||
dh_testroot
|
|
||||||
dh_installchangelogs ChangeLog
|
|
||||||
dh_installdocs
|
|
||||||
dh_installexamples
|
|
||||||
# dh_install
|
|
||||||
# dh_installmenu
|
|
||||||
# dh_installdebconf
|
|
||||||
# dh_installlogrotate
|
|
||||||
# dh_installemacsen
|
|
||||||
# dh_installpam
|
|
||||||
# dh_installmime
|
|
||||||
# dh_python
|
|
||||||
# dh_installinit
|
|
||||||
# dh_installcron
|
|
||||||
# dh_installinfo
|
|
||||||
dh_installman
|
|
||||||
dh_link
|
|
||||||
dh_strip
|
|
||||||
dh_compress
|
|
||||||
dh_fixperms
|
|
||||||
# dh_perl
|
|
||||||
# dh_makeshlibs
|
|
||||||
dh_installdeb
|
|
||||||
dh_shlibdeps
|
|
||||||
dh_gencontrol
|
|
||||||
dh_md5sums
|
|
||||||
dh_builddeb
|
|
||||||
|
|
||||||
binary: binary-indep binary-arch
|
|
||||||
.PHONY: build clean binary-indep binary-arch binary install configure
|
|
||||||
10
debian/uhub.default
vendored
10
debian/uhub.default
vendored
@@ -1,10 +0,0 @@
|
|||||||
# Defaults for uhub initscript
|
|
||||||
# sourced by /etc/init.d/uhub
|
|
||||||
# installed at /etc/default/uhub by the maintainer scripts
|
|
||||||
|
|
||||||
# Additional options that are passed to the Daemon.
|
|
||||||
ENABLED=1
|
|
||||||
LOGFILE="/var/log/uhug.log"
|
|
||||||
USER=nobody
|
|
||||||
GROUP=nogroup
|
|
||||||
DAEMON_OPTS="-f -l ${LOGFILE} -u ${USER} -g {GROUP}"
|
|
||||||
72
doc/uhub.1
Normal file
72
doc/uhub.1
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
.TH UHUB 1 "March 2009"
|
||||||
|
.\" Please adjust this date whenever revising the manpage.
|
||||||
|
.\"
|
||||||
|
.\" Some roff macros, for reference:
|
||||||
|
.\" .nh disable hyphenation
|
||||||
|
.\" .hy enable hyphenation
|
||||||
|
.\" .ad l left justify
|
||||||
|
.\" .ad b justify to both left and right margins
|
||||||
|
.\" .nf disable filling
|
||||||
|
.\" .fi enable filling
|
||||||
|
.\" .br insert line break
|
||||||
|
.\" .sp <n> insert n+1 empty lines
|
||||||
|
.\" for manpage-specific macros, see man(7)
|
||||||
|
.SH NAME
|
||||||
|
uhub \- a high performance ADC peer-to-peer hub
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B uhub
|
||||||
|
.RI [ options ]
|
||||||
|
.SH DESCRIPTION
|
||||||
|
uHub is a high performance peer-to-peer hub for the ADC network.
|
||||||
|
Its low memory footprint allows it to handle several thousand users
|
||||||
|
on high-end servers, or a small private hub on embedded hardware.
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.TP
|
||||||
|
.BI \^\-v
|
||||||
|
Verbose mode, add more -v's for higher verbosity.
|
||||||
|
.TP
|
||||||
|
.BI \^\-q
|
||||||
|
Quiet mode, if quiet mode is enabled no output or logs are made.
|
||||||
|
.TP
|
||||||
|
.BI \^\-f
|
||||||
|
Fork uhub to background in order to run it as a daemon.
|
||||||
|
.TP
|
||||||
|
.BI \^\-l " logfile"
|
||||||
|
Log messages to the given logfile (default: stderr)
|
||||||
|
.TP
|
||||||
|
.BI \^\-L
|
||||||
|
Log messages to syslog.
|
||||||
|
.TP
|
||||||
|
.BI \^\-c " config"
|
||||||
|
Specify configuration file (default: /etc/uhub/uhub.conf)
|
||||||
|
.TP
|
||||||
|
.BI \^\-C
|
||||||
|
Check configuration files and return. Will print either \"OK\" or \"ERROR\".
|
||||||
|
.TP
|
||||||
|
.BI \^\-s
|
||||||
|
Show all configuration parameters. In a format that is compatible with
|
||||||
|
the configuration files.
|
||||||
|
.TP
|
||||||
|
.BI \^\-S
|
||||||
|
Show all non-default configuration parameters.
|
||||||
|
.TP
|
||||||
|
.BI \^\-h
|
||||||
|
Show the help message.
|
||||||
|
.TP
|
||||||
|
.BI \^\-u " user"
|
||||||
|
Drop privileges and run as the given user.
|
||||||
|
.TP
|
||||||
|
.BI \^\-g " group"
|
||||||
|
Drop privileges and run with the given group permissions.
|
||||||
|
.TP
|
||||||
|
.BI \^\-V
|
||||||
|
Show the version number
|
||||||
|
.SH EXAMPLES
|
||||||
|
To run uhub as a daemon, and log to a file:
|
||||||
|
.TP
|
||||||
|
.B uhub " -f -l /var/log/uhub/uhub.log"
|
||||||
|
.SH AUTHOR
|
||||||
|
This program was written by Jan Vidar Krey <janvidar@extatic.org>
|
||||||
|
.SH "BUG REPORTS"
|
||||||
|
If you find a bug in uhub please report it to
|
||||||
|
.B http://bugs.extatic.org/
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#define ACL_ADD_BOOL(S, L) do { ret = check_cmd_bool(S, L, line, line_count); if (ret != 0) return ret; } while(0)
|
#define ACL_ADD_BOOL(S, L) do { ret = check_cmd_bool(S, L, line, line_count); if (ret != 0) return ret; } while(0)
|
||||||
#define ACL_ADD_ADDR(S, L) do { ret = check_cmd_addr(S, L, line, line_count); if (ret != 0) return ret; } while(0)
|
#define ACL_ADD_ADDR(S, L) do { ret = check_cmd_addr(S, L, line, line_count); if (ret != 0) return ret; } while(0)
|
||||||
|
|
||||||
static const char* get_user_credential_string(enum user_credentials cred)
|
const char* get_user_credential_string(enum user_credentials cred)
|
||||||
{
|
{
|
||||||
switch (cred)
|
switch (cred)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ enum user_credentials
|
|||||||
cred_link, /**<<< "User is a link (not used currently)" */
|
cred_link, /**<<< "User is a link (not used currently)" */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* get_user_credential_string(enum user_credentials cred);
|
||||||
|
|
||||||
struct user_access_info
|
struct user_access_info
|
||||||
{
|
{
|
||||||
char* username; /* name of user, cid or IP range */
|
char* username; /* name of user, cid or IP range */
|
||||||
|
|||||||
162
src/commands.c
162
src/commands.c
@@ -19,28 +19,41 @@
|
|||||||
|
|
||||||
#include "uhub.h"
|
#include "uhub.h"
|
||||||
|
|
||||||
static int command_access_denied(struct user* user)
|
typedef int (*command_handler)(struct user* user, const char* message);
|
||||||
|
|
||||||
|
struct commands_handler
|
||||||
{
|
{
|
||||||
struct adc_message* command;
|
const char* prefix;
|
||||||
char* buffer = adc_msg_escape("Access denied.");
|
size_t length;
|
||||||
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
enum user_credentials cred;
|
||||||
|
command_handler handler;
|
||||||
|
const char* description;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct commands_handler command_handlers[];
|
||||||
|
|
||||||
|
static void send_message(struct user* user, const char* message)
|
||||||
|
{
|
||||||
|
char* buffer = adc_msg_escape(message);
|
||||||
|
struct adc_message* command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
||||||
adc_msg_add_argument(command, buffer);
|
adc_msg_add_argument(command, buffer);
|
||||||
route_to_user(user, command);
|
route_to_user(user, command);
|
||||||
adc_msg_free(command);
|
adc_msg_free(command);
|
||||||
hub_free(buffer);
|
hub_free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int command_access_denied(struct user* user, const char* command)
|
||||||
|
{
|
||||||
|
char temp[64];
|
||||||
|
snprintf(temp, 64, "*** Access denied: \"%s\"", command);
|
||||||
|
send_message(user, temp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int command_stats(struct user* user, const char* message)
|
static int command_stats(struct user* user, const char* message)
|
||||||
{
|
{
|
||||||
struct adc_message* command;
|
|
||||||
|
|
||||||
if (user->credentials < cred_super)
|
|
||||||
return command_access_denied(user);
|
|
||||||
|
|
||||||
char temp[128];
|
char temp[128];
|
||||||
|
|
||||||
snprintf(temp, 128, "*** Stats: %zu users, peak: %zu. Network (up/down): %d/%d KB/s, peak: %d/%d KB/s",
|
snprintf(temp, 128, "*** Stats: %zu users, peak: %zu. Network (up/down): %d/%d KB/s, peak: %d/%d KB/s",
|
||||||
user->hub->users->count,
|
user->hub->users->count,
|
||||||
user->hub->users->count_peak,
|
user->hub->users->count_peak,
|
||||||
@@ -49,39 +62,35 @@ static int command_stats(struct user* user, const char* message)
|
|||||||
(int) user->hub->stats.net_tx_peak / 1024,
|
(int) user->hub->stats.net_tx_peak / 1024,
|
||||||
(int) user->hub->stats.net_rx_peak / 1024);
|
(int) user->hub->stats.net_rx_peak / 1024);
|
||||||
|
|
||||||
char* buffer = adc_msg_escape(temp);
|
send_message(user, temp);
|
||||||
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
|
||||||
adc_msg_add_argument(command, buffer);
|
|
||||||
route_to_user(user, command);
|
|
||||||
adc_msg_free(command);
|
|
||||||
hub_free(buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int command_help(struct user* user, const char* message)
|
static int command_help(struct user* user, const char* message)
|
||||||
{
|
{
|
||||||
struct adc_message* command;
|
#define MAX_HELP_MSG 1024
|
||||||
char* buffer = adc_msg_escape("\n"
|
size_t n;
|
||||||
"*** Available commands:\n"
|
char msg[MAX_HELP_MSG];
|
||||||
"!help - Show this help message\n"
|
msg[0] = 0;
|
||||||
"!stats - Show hub stats (super)\n"
|
strcat(msg, "\n*** Available commands:\n");
|
||||||
"!version - Show this help message\n"
|
|
||||||
"!uptime - Display hub uptime\n"
|
|
||||||
"!kick <user> - Kick user (operator)\n"
|
|
||||||
);
|
|
||||||
|
|
||||||
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
for (n = 0; command_handlers[n].prefix; n++)
|
||||||
adc_msg_add_argument(command, buffer);
|
{
|
||||||
route_to_user(user, command);
|
if (command_handlers[n].cred <= user->credentials)
|
||||||
adc_msg_free(command);
|
{
|
||||||
hub_free(buffer);
|
strcat(msg, command_handlers[n].prefix);
|
||||||
|
strcat(msg, " - ");
|
||||||
|
strcat(msg, command_handlers[n].description);
|
||||||
|
strcat(msg, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
send_message(user, msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int command_uptime(struct user* user, const char* message)
|
static int command_uptime(struct user* user, const char* message)
|
||||||
{
|
{
|
||||||
struct adc_message* command;
|
|
||||||
char tmp[128];
|
char tmp[128];
|
||||||
size_t d;
|
size_t d;
|
||||||
size_t h;
|
size_t h;
|
||||||
@@ -111,73 +120,74 @@ static int command_uptime(struct user* user, const char* message)
|
|||||||
if (m < 10) strcat(tmp, "0");
|
if (m < 10) strcat(tmp, "0");
|
||||||
strcat(tmp, uhub_itoa((int) m));
|
strcat(tmp, uhub_itoa((int) m));
|
||||||
|
|
||||||
char* buffer = adc_msg_escape(tmp);
|
send_message(user, tmp);
|
||||||
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
|
||||||
adc_msg_add_argument(command, buffer);
|
|
||||||
route_to_user(user, command);
|
|
||||||
adc_msg_free(command);
|
|
||||||
hub_free(buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int command_kick(struct user* user, const char* message)
|
static int command_kick(struct user* user, const char* message)
|
||||||
{
|
{
|
||||||
struct adc_message* command;
|
send_message(user, "*** Kick not implemented!");
|
||||||
|
|
||||||
if (user->credentials < cred_operator)
|
|
||||||
return command_access_denied(user);
|
|
||||||
|
|
||||||
char* buffer = adc_msg_escape("*** Kick not implemented!");
|
|
||||||
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
|
||||||
adc_msg_add_argument(command, buffer);
|
|
||||||
route_to_user(user, command);
|
|
||||||
adc_msg_free(command);
|
|
||||||
hub_free(buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int command_reload(struct user* user, const char* message)
|
||||||
|
{
|
||||||
|
send_message(user, "*** Reloading configuration");
|
||||||
|
user->hub->status = hub_status_restart;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int command_shutdown(struct user* user, const char* message)
|
||||||
|
{
|
||||||
|
send_message(user, "*** Hub shuting down...");
|
||||||
|
user->hub->status = hub_status_shutdown;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int command_version(struct user* user, const char* message)
|
static int command_version(struct user* user, const char* message)
|
||||||
{
|
{
|
||||||
struct adc_message* command;
|
send_message(user, "*** Powered by " PRODUCT "/" VERSION);
|
||||||
char* buffer = adc_msg_escape("*** Powered by " PRODUCT "/" VERSION);
|
|
||||||
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
|
||||||
adc_msg_add_argument(command, buffer);
|
|
||||||
route_to_user(user, command);
|
|
||||||
adc_msg_free(command);
|
|
||||||
hub_free(buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int command_myip(struct user* user, const char* message)
|
static int command_myip(struct user* user, const char* message)
|
||||||
{
|
{
|
||||||
struct adc_message* command;
|
|
||||||
char tmp[128];
|
char tmp[128];
|
||||||
char* buffer;
|
snprintf(tmp, 128, "*** Your IP: %s", ip_convert_to_string(&user->ipaddr));
|
||||||
|
send_message(user, tmp);
|
||||||
tmp[0] = 0;
|
|
||||||
strcat(tmp, "*** Your IP: ");
|
|
||||||
strcat(tmp, ip_convert_to_string(&user->ipaddr));
|
|
||||||
|
|
||||||
buffer = adc_msg_escape(tmp);
|
|
||||||
command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
|
||||||
adc_msg_add_argument(command, buffer);
|
|
||||||
route_to_user(user, command);
|
|
||||||
adc_msg_free(command);
|
|
||||||
hub_free(buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int command_dipatcher(struct user* user, const char* message)
|
int command_dipatcher(struct user* user, const char* message)
|
||||||
{
|
{
|
||||||
if (!strncmp(message, "!stats", 6)) command_stats(user, message);
|
size_t n = 0;
|
||||||
else if (!strncmp(message, "!help", 5)) command_help(user, message);
|
for (n = 0; command_handlers[n].prefix; n++)
|
||||||
else if (!strncmp(message, "!kick", 5)) command_kick(user, message);
|
{
|
||||||
else if (!strncmp(message, "!version", 8)) command_version(user, message);
|
if (!strncmp(message, command_handlers[n].prefix, command_handlers[n].length))
|
||||||
else if (!strncmp(message, "!uptime", 7)) command_uptime(user, message);
|
{
|
||||||
else if (!strncmp(message, "+myip", 5)) command_myip(user, message);
|
if (command_handlers[n].cred <= user->credentials)
|
||||||
|
{
|
||||||
|
return command_handlers[n].handler(user, message);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
return command_access_denied(user, &command_handlers[n].prefix[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct commands_handler command_handlers[] = {
|
||||||
|
{ "!help", 5, cred_guest, command_help, "Show this help message." },
|
||||||
|
{ "!stats", 6, cred_super, command_stats, "Show hub statistics." },
|
||||||
|
{ "!version", 8, cred_guest, command_version, "Show hub version info." },
|
||||||
|
{ "!uptime", 7, cred_guest, command_uptime, "Display hub uptime info." },
|
||||||
|
{ "!kick", 5, cred_operator, command_kick, "Kick a user" },
|
||||||
|
{ "!reload", 7, cred_admin, command_reload, "Reload configuration files." },
|
||||||
|
{ "!shutdown", 9, cred_admin, command_shutdown, "Shutdown hub." },
|
||||||
|
{ "+myip", 5, cred_guest, command_myip, "Show your own IP." },
|
||||||
|
{ 0, 0, cred_none, command_help, "{ Last dummy option }" }
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
62
src/hub.c
62
src/hub.c
@@ -146,8 +146,8 @@ int hub_handle_support(struct user* u, struct adc_message* cmd)
|
|||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
hub_send_handshake(u);
|
hub_send_handshake(u);
|
||||||
if (u->ev_read)
|
if (u->ev_handle)
|
||||||
event_add(u->ev_read, &timeout);
|
event_add(u->ev_handle, &timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -479,7 +479,11 @@ struct hub_info* hub_start_service(struct hub_config* config)
|
|||||||
net_address_to_string(AF_INET6, &((struct sockaddr_in6*) &addr)->sin6_addr, address_buf, INET6_ADDRSTRLEN);
|
net_address_to_string(AF_INET6, &((struct sockaddr_in6*) &addr)->sin6_addr, address_buf, INET6_ADDRSTRLEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIBEVENT_1_4
|
||||||
hub->evbase = event_base_new();
|
hub->evbase = event_base_new();
|
||||||
|
#else
|
||||||
|
hub->evbase = event_init();
|
||||||
|
#endif
|
||||||
if (!hub->evbase)
|
if (!hub->evbase)
|
||||||
{
|
{
|
||||||
hub_log(log_error, "Unable to initialize libevent.");
|
hub_log(log_error, "Unable to initialize libevent.");
|
||||||
@@ -487,7 +491,8 @@ struct hub_info* hub_start_service(struct hub_config* config)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hub_log(log_info, "Starting server, listening on %s:%d...", address_buf, config->server_port);
|
hub_log(log_info, "Starting " PRODUCT "/" VERSION ", listening on %s:%d...", address_buf, config->server_port);
|
||||||
|
hub_log(log_debug, "Using libevent %s, backend: %s", event_get_version(), event_get_method());
|
||||||
|
|
||||||
server_tcp = net_socket_create(af, SOCK_STREAM, IPPROTO_TCP);
|
server_tcp = net_socket_create(af, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (server_tcp == -1)
|
if (server_tcp == -1)
|
||||||
@@ -894,6 +899,46 @@ const char* hub_get_status_message(struct hub_info* hub, enum status_message msg
|
|||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* hub_get_status_message_log(struct hub_info* hub, enum status_message msg)
|
||||||
|
{
|
||||||
|
#define STATUS(MSG) case status_ ## MSG : return #MSG; break
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
STATUS(msg_hub_full);
|
||||||
|
STATUS(msg_hub_disabled);
|
||||||
|
STATUS(msg_hub_registered_users_only);
|
||||||
|
STATUS(msg_inf_error_nick_missing);
|
||||||
|
STATUS(msg_inf_error_nick_multiple);
|
||||||
|
STATUS(msg_inf_error_nick_invalid);
|
||||||
|
STATUS(msg_inf_error_nick_long);
|
||||||
|
STATUS(msg_inf_error_nick_short);
|
||||||
|
STATUS(msg_inf_error_nick_spaces);
|
||||||
|
STATUS(msg_inf_error_nick_bad_chars);
|
||||||
|
STATUS(msg_inf_error_nick_not_utf8);
|
||||||
|
STATUS(msg_inf_error_nick_taken);
|
||||||
|
STATUS(msg_inf_error_nick_restricted);
|
||||||
|
STATUS(msg_inf_error_cid_invalid);
|
||||||
|
STATUS(msg_inf_error_cid_missing);
|
||||||
|
STATUS(msg_inf_error_cid_taken);
|
||||||
|
STATUS(msg_inf_error_pid_missing);
|
||||||
|
STATUS(msg_inf_error_pid_invalid);
|
||||||
|
STATUS(msg_ban_permanently);
|
||||||
|
STATUS(msg_ban_temporarily);
|
||||||
|
STATUS(msg_auth_invalid_password);
|
||||||
|
STATUS(msg_auth_user_not_found);
|
||||||
|
STATUS(msg_error_no_memory);
|
||||||
|
STATUS(msg_user_share_size_low);
|
||||||
|
STATUS(msg_user_share_size_high);
|
||||||
|
STATUS(msg_user_slots_low);
|
||||||
|
STATUS(msg_user_slots_high);
|
||||||
|
STATUS(msg_user_hub_limit_low);
|
||||||
|
STATUS(msg_user_hub_limit_high);
|
||||||
|
}
|
||||||
|
#undef STATUS
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t hub_get_user_count(struct hub_info* hub)
|
size_t hub_get_user_count(struct hub_info* hub)
|
||||||
{
|
{
|
||||||
return hub->users->count;
|
return hub->users->count;
|
||||||
@@ -972,17 +1017,20 @@ size_t hub_get_min_hubs_op(struct hub_info* hub)
|
|||||||
|
|
||||||
void hub_event_loop(struct hub_info* hub)
|
void hub_event_loop(struct hub_info* hub)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
event_dispatch();
|
|
||||||
#endif
|
|
||||||
int ret;
|
int ret;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = event_base_loop(hub->evbase, EVLOOP_ONCE);
|
ret = event_base_loop(hub->evbase, EVLOOP_ONCE);
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
hub_log(log_debug, "event_base_loop returned: %d", (int) ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
event_queue_process(hub->queue);
|
event_queue_process(hub->queue);
|
||||||
}
|
}
|
||||||
while (hub->status == hub_status_running);
|
while (hub->status == hub_status_running || hub->status == hub_status_disabled);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,6 +238,8 @@ extern void hub_free_variables(struct hub_info* hub);
|
|||||||
* Returns a string for the given status_message (See enum status_message).
|
* Returns a string for the given status_message (See enum status_message).
|
||||||
*/
|
*/
|
||||||
extern const char* hub_get_status_message(struct hub_info* hub, enum status_message msg);
|
extern const char* hub_get_status_message(struct hub_info* hub, enum status_message msg);
|
||||||
|
extern const char* hub_get_status_message_log(struct hub_info* hub, enum status_message msg);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a status_message to a user.
|
* Sends a status_message to a user.
|
||||||
|
|||||||
@@ -19,14 +19,36 @@
|
|||||||
|
|
||||||
#include "uhub.h"
|
#include "uhub.h"
|
||||||
|
|
||||||
|
static void log_user_login(struct user* u)
|
||||||
|
{
|
||||||
|
const char* cred = get_user_credential_string(u->credentials);
|
||||||
|
const char* addr = ip_convert_to_string(&u->ipaddr);
|
||||||
|
hub_log(log_user, "LoginOK %s/%s %s \"%s\" (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, cred, u->user_agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void log_user_login_error(struct user* u, enum status_message msg)
|
||||||
|
{
|
||||||
|
const char* addr = ip_convert_to_string(&u->ipaddr);
|
||||||
|
const char* message = hub_get_status_message_log(u->hub, msg);
|
||||||
|
hub_log(log_user, "LoginError %s/%s %s \"%s\" (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, message, u->user_agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void log_user_logout(struct user* u, const char* message)
|
||||||
|
{
|
||||||
|
const char* addr = ip_convert_to_string(&u->ipaddr);
|
||||||
|
hub_log(log_user, "Logout %s/%s %s \"%s\" (%s)", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void log_user_nick_change(struct user* u, const char* nick)
|
||||||
|
{
|
||||||
|
const char* addr = ip_convert_to_string(&u->ipaddr);
|
||||||
|
hub_log(log_user, "NickChange %s/%s %s \"%s\" -> \"%s\"", sid_to_string(u->id.sid), u->id.cid, addr, u->id.nick, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Send MOTD, do logging etc */
|
/* Send MOTD, do logging etc */
|
||||||
void on_login_success(struct user* u)
|
void on_login_success(struct user* u)
|
||||||
{
|
{
|
||||||
/* Logging - FIXME: Move this to a plugin */
|
|
||||||
const char* addr = ip_convert_to_string(&u->ipaddr);
|
|
||||||
const char* credentials_string[] = { "!none!", "link", "guest", "user", "operator", "super", "admin" };
|
|
||||||
struct timeval timeout = { TIMEOUT_IDLE, 0 };
|
|
||||||
|
|
||||||
/* Send user list of all existing users */
|
/* Send user list of all existing users */
|
||||||
if (!send_user_list(u))
|
if (!send_user_list(u))
|
||||||
return;
|
return;
|
||||||
@@ -36,7 +58,7 @@ void on_login_success(struct user* u)
|
|||||||
user_manager_add(u);
|
user_manager_add(u);
|
||||||
|
|
||||||
/* Print log message */
|
/* Print log message */
|
||||||
hub_log(log_user, "Login OK %s/%s \"%s\" [%s] (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, u->id.nick, addr, credentials_string[u->credentials], u->user_agent);
|
log_user_login(u);
|
||||||
|
|
||||||
/* Announce new user to all connected users */
|
/* Announce new user to all connected users */
|
||||||
if (user_is_logged_in(u))
|
if (user_is_logged_in(u))
|
||||||
@@ -45,37 +67,26 @@ void on_login_success(struct user* u)
|
|||||||
/* Send message of the day (if any) */
|
/* Send message of the day (if any) */
|
||||||
if (user_is_logged_in(u)) /* Previous send() can fail! */
|
if (user_is_logged_in(u)) /* Previous send() can fail! */
|
||||||
hub_send_motd(u);
|
hub_send_motd(u);
|
||||||
|
|
||||||
/* reset to idle timeout */
|
|
||||||
if (u->ev_read)
|
|
||||||
event_add(u->ev_read, &timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void on_login_failure(struct user* u, enum status_message msg)
|
void on_login_failure(struct user* u, enum status_message msg)
|
||||||
{
|
{
|
||||||
const char* addr = ip_convert_to_string(&u->ipaddr);
|
log_user_login_error(u, msg);
|
||||||
const char* message = hub_get_status_message(u->hub, msg);
|
|
||||||
hub_log(log_user, "Login FAIL %s/%s \"%s\" [%s] (%s) \"%s\"", sid_to_string(u->id.sid), u->id.cid, u->id.nick, addr, message, u->user_agent);
|
|
||||||
|
|
||||||
hub_send_status(u, msg, status_level_fatal);
|
hub_send_status(u, msg, status_level_fatal);
|
||||||
user_disconnect(u, quit_logon_error);
|
user_disconnect(u, quit_logon_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void on_nick_change(struct user* u, const char* nick)
|
void on_nick_change(struct user* u, const char* nick)
|
||||||
{
|
{
|
||||||
if (user_is_logged_in(u))
|
if (user_is_logged_in(u))
|
||||||
{
|
{
|
||||||
hub_log(log_user, "Nick change %s/%s \"%s\" -> \"%s\"", sid_to_string(u->id.sid), u->id.cid, u->id.nick, nick);
|
log_user_nick_change(u, nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void on_logout_user(struct user* user)
|
void on_logout_user(struct user* user)
|
||||||
{
|
{
|
||||||
const char* reason = "";
|
const char* reason = "";
|
||||||
const char* addr;
|
|
||||||
|
|
||||||
/* These are used for logging purposes */
|
/* These are used for logging purposes */
|
||||||
switch (user->quit_reason)
|
switch (user->quit_reason)
|
||||||
@@ -90,6 +101,7 @@ void on_logout_user(struct user* user)
|
|||||||
case quit_protocol_error: reason = "protocol error"; break;
|
case quit_protocol_error: reason = "protocol error"; break;
|
||||||
case quit_logon_error: reason = "login error"; break;
|
case quit_logon_error: reason = "login error"; break;
|
||||||
case quit_hub_disabled: reason = "hub disabled"; break;
|
case quit_hub_disabled: reason = "hub disabled"; break;
|
||||||
|
case quit_ghost_timeout: reason = "ghost"; break;
|
||||||
default:
|
default:
|
||||||
if (user->hub->status == hub_status_shutdown)
|
if (user->hub->status == hub_status_shutdown)
|
||||||
reason = "hub shutdown";
|
reason = "hub shutdown";
|
||||||
@@ -98,10 +110,7 @@ void on_logout_user(struct user* user)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = ip_convert_to_string(&user->ipaddr);
|
log_user_logout(user, reason);
|
||||||
hub_log(log_user, "Logout %s/%s \"%s\" [%s] (%s)", sid_to_string(user->id.sid), user->id.cid, user->id.nick, addr, reason);
|
|
||||||
|
|
||||||
|
|
||||||
user->quit_reason = 0;
|
user->quit_reason = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
src/inf.c
15
src/inf.c
@@ -332,7 +332,7 @@ static int check_logged_in(struct user* user, struct adc_message* cmd)
|
|||||||
if (lookup1 == lookup2)
|
if (lookup1 == lookup2)
|
||||||
{
|
{
|
||||||
hub_log(log_debug, "check_logged_in: exact same user is logged in: %s", user->id.nick);
|
hub_log(log_debug, "check_logged_in: exact same user is logged in: %s", user->id.nick);
|
||||||
user_disconnect(lookup1, quit_timeout);
|
user_disconnect(lookup1, quit_ghost_timeout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -645,6 +645,7 @@ void update_user_info(struct user* u, struct adc_message* cmd)
|
|||||||
argument = adc_msg_get_argument(cmd, n++);
|
argument = adc_msg_get_argument(cmd, n++);
|
||||||
}
|
}
|
||||||
user_set_info(u, cmd_new);
|
user_set_info(u, cmd_new);
|
||||||
|
adc_msg_free(cmd_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -766,7 +767,7 @@ int hub_handle_info_login(struct user* user, struct adc_message* cmd)
|
|||||||
*/
|
*/
|
||||||
int hub_handle_info(struct user* user, const struct adc_message* cmd_unmodified)
|
int hub_handle_info(struct user* user, const struct adc_message* cmd_unmodified)
|
||||||
{
|
{
|
||||||
struct adc_message* cmd = adc_msg_copy(cmd_unmodified); /* FIXME: Have a small memory leak here! */
|
struct adc_message* cmd = adc_msg_copy(cmd_unmodified);
|
||||||
if (!cmd) return -1; /* OOM */
|
if (!cmd) return -1; /* OOM */
|
||||||
|
|
||||||
cmd->priority = 1;
|
cmd->priority = 1;
|
||||||
@@ -778,6 +779,16 @@ int hub_handle_info(struct user* user, const struct adc_message* cmd_unmodified)
|
|||||||
*/
|
*/
|
||||||
if (user_is_connecting(user))
|
if (user_is_connecting(user))
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Don't allow the user to send multiple INF messages in this stage!
|
||||||
|
* Since that can have serious side-effects.
|
||||||
|
*/
|
||||||
|
if (user->info)
|
||||||
|
{
|
||||||
|
adc_msg_free(cmd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ret = hub_handle_info_login(user, cmd);
|
int ret = hub_handle_info_login(user, cmd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -177,8 +177,8 @@ void hub_log(int log_verbosity, const char *format, ...)
|
|||||||
if (log_verbosity < verbosity)
|
if (log_verbosity < verbosity)
|
||||||
{
|
{
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
tmp = gmtime(&t);
|
tmp = localtime(&t);
|
||||||
strftime(timestamp, 32, "%a, %d %b %Y %H:%M:%S +0000", tmp);
|
strftime(timestamp, 32, "%Y-%m-%d %H:%M:%S", tmp);
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsnprintf(logmsg, 1024, format, args);
|
vsnprintf(logmsg, 1024, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|||||||
32
src/main.c
32
src/main.c
@@ -37,47 +37,29 @@ void hub_handle_signal(int fd, short events, void* arg)
|
|||||||
{
|
{
|
||||||
struct hub_info* hub = (struct hub_info*) arg;
|
struct hub_info* hub = (struct hub_info*) arg;
|
||||||
int signal = fd;
|
int signal = fd;
|
||||||
struct timeval now = {0, 0};
|
|
||||||
|
|
||||||
switch (signal)
|
switch (signal)
|
||||||
{
|
{
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
hub_log(log_info, "Interrupted. Shutting down...");
|
hub_log(log_info, "Interrupted. Shutting down...");
|
||||||
hub->status = hub_status_shutdown;
|
hub->status = hub_status_shutdown;
|
||||||
event_loopexit(&now);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
hub_log(log_info, "Terminated. Shutting down...");
|
hub_log(log_info, "Terminated. Shutting down...");
|
||||||
hub->status = hub_status_shutdown;
|
hub->status = hub_status_shutdown;
|
||||||
event_loopexit(&now);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGPIPE:
|
case SIGPIPE:
|
||||||
hub_log(log_trace, "hub_handle_signal(): caught SIGPIPE (ignoring)");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
hub_log(log_info, "Caught hangup signal. Reloading configuration files...");
|
|
||||||
hub->status = hub_status_restart;
|
hub->status = hub_status_restart;
|
||||||
event_loopexit(&now);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SIGUSR1:
|
|
||||||
hub_log(log_trace, "hub_handle_signal(): caught SIGUSR1 -- FIXME");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SIGUSR2:
|
|
||||||
hub_log(log_trace, "hub_handle_signal(): caught SIGUSR2");
|
|
||||||
{
|
|
||||||
user_manager_print_stats(hub);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
hub_log(log_trace, "hub_handle_signal(): caught unknown signal: %d", signal);
|
hub_log(log_trace, "hub_handle_signal(): caught unknown signal: %d", signal);
|
||||||
hub->status = hub_status_shutdown;
|
hub->status = hub_status_shutdown;
|
||||||
event_loopexit(&now);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,8 +71,6 @@ static int signals[] =
|
|||||||
SIGTERM, /* Terminate the application */
|
SIGTERM, /* Terminate the application */
|
||||||
SIGPIPE, /* prevent sigpipe from kills the application */
|
SIGPIPE, /* prevent sigpipe from kills the application */
|
||||||
SIGHUP, /* reload configuration */
|
SIGHUP, /* reload configuration */
|
||||||
SIGUSR1, /* dump statistics */
|
|
||||||
SIGUSR2, /* (unused) */
|
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -131,6 +111,12 @@ int main_loop()
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if (hub)
|
||||||
|
{
|
||||||
|
hub_log(log_info, "Reloading configuration files...");
|
||||||
|
hub_log(log_debug, "Hub status: %d", (int) hub->status);
|
||||||
|
}
|
||||||
|
|
||||||
if (read_config(arg_config, &configuration, !arg_have_config) == -1)
|
if (read_config(arg_config, &configuration, !arg_have_config) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -183,9 +169,12 @@ int check_configuration(int dump)
|
|||||||
int ret = read_config(arg_config, &configuration, 0);
|
int ret = read_config(arg_config, &configuration, 0);
|
||||||
|
|
||||||
if (dump)
|
if (dump)
|
||||||
|
{
|
||||||
|
if (ret != -1)
|
||||||
{
|
{
|
||||||
dump_config(&configuration, dump > 1);
|
dump_config(&configuration, dump > 1);
|
||||||
puts("");
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
@@ -193,6 +182,7 @@ int check_configuration(int dump)
|
|||||||
fprintf(stderr, "ERROR\n");
|
fprintf(stderr, "ERROR\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "OK\n");
|
fprintf(stdout, "OK\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,6 +264,13 @@ struct adc_message* adc_msg_parse(const char* line, size_t length)
|
|||||||
if (command == NULL)
|
if (command == NULL)
|
||||||
return NULL; /* OOM */
|
return NULL; /* OOM */
|
||||||
|
|
||||||
|
if (!is_printable_utf8(line, length))
|
||||||
|
{
|
||||||
|
hub_log(log_debug, "Dropped message with non-printable UTF-8 characters.");
|
||||||
|
hub_free(command);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (line[length-1] != '\n')
|
if (line[length-1] != '\n')
|
||||||
{
|
{
|
||||||
need_terminate = 1;
|
need_terminate = 1;
|
||||||
|
|||||||
35
src/misc.c
35
src/misc.c
@@ -31,6 +31,16 @@ int is_white_space(char c)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int is_printable(unsigned char c)
|
||||||
|
{
|
||||||
|
if (c >= 32)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (c == '\t' || c == '\r' || c == '\n')
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char* strip_white_space(char* string)
|
char* strip_white_space(char* string)
|
||||||
{
|
{
|
||||||
@@ -48,17 +58,15 @@ char* strip_white_space(char* string)
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int is_valid_utf8_str(const char* string, size_t length)
|
||||||
int is_valid_utf8(const char* string)
|
|
||||||
{
|
{
|
||||||
int expect = 0;
|
int expect = 0;
|
||||||
char div = 0;
|
char div = 0;
|
||||||
int pos = 0;
|
size_t pos = 0;
|
||||||
int length = strlen(string);
|
|
||||||
|
|
||||||
if (length == 0) return 1;
|
if (length == 0) return 1;
|
||||||
|
|
||||||
for (pos = 0; pos < strlen(string); pos++)
|
for (pos = 0; pos < length; pos++)
|
||||||
{
|
{
|
||||||
if (expect)
|
if (expect)
|
||||||
{
|
{
|
||||||
@@ -74,13 +82,28 @@ int is_valid_utf8(const char* string)
|
|||||||
if (string[pos] & div) expect++;
|
if (string[pos] & div) expect++;
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
if ((string[pos] & div) || (pos+expect >= strlen(string))) return 0;
|
if ((string[pos] & div) || (pos+expect >= length)) return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_valid_utf8(const char* string)
|
||||||
|
{
|
||||||
|
return is_valid_utf8_str(string, strlen(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_printable_utf8(const char* string, size_t length)
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
for (pos = 0; pos < length; pos++)
|
||||||
|
{
|
||||||
|
if (!is_printable(string[pos]))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return is_valid_utf8_str(string, length);
|
||||||
|
}
|
||||||
|
|
||||||
int is_valid_base32_char(char c)
|
int is_valid_base32_char(char c)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ extern int is_num(char c);
|
|||||||
extern int is_space(char c);
|
extern int is_space(char c);
|
||||||
extern int is_white_space(char c);
|
extern int is_white_space(char c);
|
||||||
extern int is_valid_utf8(const char* string);
|
extern int is_valid_utf8(const char* string);
|
||||||
|
extern int is_printable_utf8(const char* string, size_t length);
|
||||||
extern int is_valid_base32_char(char c);
|
extern int is_valid_base32_char(char c);
|
||||||
extern void base32_encode(const unsigned char* buffer, size_t len, char* result);
|
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 void base32_decode(const char* src, unsigned char* dst, size_t len);
|
||||||
|
|||||||
239
src/netevent.c
239
src/netevent.c
@@ -20,32 +20,14 @@
|
|||||||
#include "uhub.h"
|
#include "uhub.h"
|
||||||
|
|
||||||
|
|
||||||
void net_on_read(int fd, short ev, void *arg)
|
static int on_read(struct user* user)
|
||||||
{
|
{
|
||||||
static char buf[MAX_RECV_BUF];
|
static char buf[MAX_RECV_BUF];
|
||||||
struct user* user = (struct user*) arg;
|
size_t offset;
|
||||||
char* pos;
|
size_t buflen;
|
||||||
char* start;
|
|
||||||
ssize_t offset;
|
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
ssize_t buflen;
|
|
||||||
int more = 1;
|
int more = 1;
|
||||||
int flag_close = 0;
|
char* pos;
|
||||||
|
|
||||||
hub_log(log_trace, "net_on_read() : fd=%d, ev=%d, arg=%p", fd, (int) ev, arg);
|
|
||||||
|
|
||||||
if (ev == EV_TIMEOUT)
|
|
||||||
{
|
|
||||||
more = 0;
|
|
||||||
if (user_is_connecting(user))
|
|
||||||
{
|
|
||||||
flag_close = quit_timeout;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hub_send_ping(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (more)
|
while (more)
|
||||||
{
|
{
|
||||||
@@ -55,60 +37,75 @@ void net_on_read(int fd, short ev, void *arg)
|
|||||||
memcpy(buf, user->recv_buf, user->recv_buf_offset);
|
memcpy(buf, user->recv_buf, user->recv_buf_offset);
|
||||||
offset = user->recv_buf_offset;
|
offset = user->recv_buf_offset;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = net_recv(fd, &buf[offset], MAX_RECV_BUF - offset, 0);
|
size = net_recv(user->sd, &buf[offset], MAX_RECV_BUF - offset, 0);
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
{
|
{
|
||||||
if (net_error() != EWOULDBLOCK)
|
if (net_error() != EWOULDBLOCK)
|
||||||
flag_close = quit_socket_error;
|
return quit_socket_error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (size == 0)
|
else if (size == 0)
|
||||||
{
|
{
|
||||||
flag_close = quit_disconnected;
|
return quit_disconnected;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buflen = offset + size;
|
buflen = offset + size;
|
||||||
start = buf;
|
ssize_t handled = 0;
|
||||||
while ((pos = strchr(start, '\n')))
|
|
||||||
|
while ((pos = memchr(&buf[handled], '\n', (buflen - handled))))
|
||||||
{
|
{
|
||||||
pos[0] = '\0';
|
pos[0] = '\0';
|
||||||
if (*start && strlen(start) < user->hub->config->max_recv_buffer)
|
size_t msglen = &pos[0] - &buf[handled];
|
||||||
{
|
|
||||||
if (hub_handle_message(user, start, &pos[0]-&start[0]) == -1)
|
|
||||||
{
|
|
||||||
flag_close = quit_protocol_error;
|
|
||||||
more = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
start = &pos[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!more) break;
|
if (user_flag_get(user, flag_maxbuf))
|
||||||
|
|
||||||
if (&buf[offset + size] > &start[0])
|
|
||||||
{
|
{
|
||||||
if (!user->recv_buf)
|
user_flag_unset(user, flag_maxbuf);
|
||||||
{
|
|
||||||
user->recv_buf = hub_malloc(user->hub->config->max_recv_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!user->recv_buf)
|
|
||||||
{
|
|
||||||
flag_close = quit_memory_error;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memcpy(user->recv_buf, start, &buf[offset + size] - &start[0]);
|
if (msglen < user->hub->config->max_recv_buffer)
|
||||||
user->recv_buf_offset = &buf[offset + size] - &start[0];
|
{
|
||||||
|
if (hub_handle_message(user, &buf[handled], msglen) == -1)
|
||||||
|
{
|
||||||
|
return quit_protocol_error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handled += msglen;
|
||||||
|
handled++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handled == 0 && user_flag_get(user, flag_maxbuf))
|
||||||
|
handled = buflen;
|
||||||
|
|
||||||
|
if (!more)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (handled < buflen)
|
||||||
|
{
|
||||||
|
if ((buflen - handled) > user->hub->config->max_recv_buffer)
|
||||||
|
{
|
||||||
|
user_flag_set(user, flag_maxbuf);
|
||||||
|
hub_free(user->recv_buf);
|
||||||
|
user->recv_buf = 0;
|
||||||
|
user->recv_buf_offset = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!user->recv_buf)
|
||||||
|
user->recv_buf = hub_malloc(user->hub->config->max_recv_buffer);
|
||||||
|
|
||||||
|
if (user->recv_buf)
|
||||||
|
{
|
||||||
|
memcpy(user->recv_buf, &buf[handled], buflen - handled);
|
||||||
|
user->recv_buf_offset = buflen - handled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return quit_memory_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -122,39 +119,14 @@ void net_on_read(int fd, short ev, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
if (flag_close)
|
|
||||||
{
|
|
||||||
user_disconnect(user, flag_close);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user_is_logged_in(user))
|
|
||||||
{
|
|
||||||
if (user->ev_read)
|
|
||||||
{
|
|
||||||
struct timeval timeout = { TIMEOUT_IDLE, 0 };
|
|
||||||
event_add(user->ev_read, &timeout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (user_is_connecting(user))
|
|
||||||
{
|
|
||||||
if (user->ev_read)
|
|
||||||
{
|
|
||||||
struct timeval timeout = { TIMEOUT_HANDSHAKE, 0 };
|
|
||||||
event_add(user->ev_read, &timeout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int on_write(struct user* user)
|
||||||
void net_on_write(int fd, short ev, void *arg)
|
|
||||||
{
|
{
|
||||||
struct user* user = (struct user*) arg;
|
|
||||||
struct adc_message* msg;
|
struct adc_message* msg;
|
||||||
int ret;
|
int ret;
|
||||||
int length;
|
int length;
|
||||||
int close_flag = 0;
|
|
||||||
|
|
||||||
msg = list_get_first(user->send_queue);
|
msg = list_get_first(user->send_queue);
|
||||||
while (msg)
|
while (msg)
|
||||||
@@ -164,29 +136,16 @@ void net_on_write(int fd, short ev, void *arg)
|
|||||||
|
|
||||||
if (ret == 0 || (ret == -1 && net_error() == EWOULDBLOCK))
|
if (ret == 0 || (ret == -1 && net_error() == EWOULDBLOCK))
|
||||||
{
|
{
|
||||||
close_flag = 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if (ret > 0)
|
else if (ret > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
user->tm_last_write = time(NULL);
|
user->tm_last_write = time(NULL);
|
||||||
|
|
||||||
if (ret == length)
|
if (ret == length)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_SENDQ
|
|
||||||
hub_log(log_error, "SENDQ: sent=%d bytes/%d (all), send_queue_size=%d, offset=%d", ret, (int) msg->length, user->send_queue_size, user->send_queue_offset);
|
|
||||||
#endif
|
|
||||||
user->send_queue_size -= ret;
|
user->send_queue_size -= ret;
|
||||||
user->send_queue_offset = 0;
|
user->send_queue_offset = 0;
|
||||||
|
|
||||||
#ifdef DEBUG_SENDQ
|
|
||||||
if ((user->send_queue_size < 0) || (user->send_queue_offset < 0))
|
|
||||||
{
|
|
||||||
hub_log(log_error, "INVALID: send_queue_size=%d, send_queue_offset=%d", user->send_queue_size, user->send_queue_offset);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
list_remove(user->send_queue, msg);
|
list_remove(user->send_queue, msg);
|
||||||
|
|
||||||
if (user_flag_get(user, flag_user_list) && (msg == user->info || user->send_queue_size == 0))
|
if (user_flag_get(user, flag_user_list) && (msg == user->info || user->send_queue_size == 0))
|
||||||
@@ -202,53 +161,85 @@ void net_on_write(int fd, short ev, void *arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_SENDQ
|
|
||||||
hub_log(log_error, "SENDQ: sent=%d bytes/%d (part), send_queue_size=%d, offset=%d", ret, (int) msg->length, user->send_queue_size, user->send_queue_offset);
|
|
||||||
#endif
|
|
||||||
user->send_queue_size -= ret;
|
user->send_queue_size -= ret;
|
||||||
user->send_queue_offset += ret;
|
user->send_queue_offset += ret;
|
||||||
|
|
||||||
#ifdef DEBUG_SENDQ
|
|
||||||
if ((user->send_queue_size < 0) || (user->send_queue_offset < 0) || (user->send_queue_offset > msg->length))
|
|
||||||
{
|
|
||||||
hub_log(log_error, "INVALID: send_queue_size=%d, send_queue_offset=%d", user->send_queue_size, user->send_queue_offset);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
close_flag = quit_socket_error;
|
return quit_socket_error;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
msg = list_get_first(user->send_queue);
|
msg = list_get_first(user->send_queue);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (close_flag)
|
void on_net_event(int fd, short ev, void *arg)
|
||||||
|
{
|
||||||
|
struct user* user = (struct user*) arg;
|
||||||
|
int want_close = 0;
|
||||||
|
int want_write = 0;
|
||||||
|
|
||||||
|
hub_log(log_debug, "on_net_event() : fd=%d, ev=%d, user=%s", fd, (int) ev, user);
|
||||||
|
|
||||||
|
if (ev == EV_TIMEOUT)
|
||||||
{
|
{
|
||||||
user_disconnect(user, close_flag);
|
|
||||||
|
hub_log(log_debug, "EV_TIMEOUT");
|
||||||
|
|
||||||
|
if (user_is_connecting(user))
|
||||||
|
{
|
||||||
|
want_close = quit_timeout;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (user->send_queue_size > 0 && user->ev_write)
|
hub_send_ping(user);
|
||||||
event_add(user->ev_write, NULL);
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ev & EV_WRITE)
|
||||||
|
{
|
||||||
|
want_close = on_write(user);
|
||||||
|
want_write = (user->send_queue_size != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!want_close && ev & EV_READ)
|
||||||
|
{
|
||||||
|
want_close = on_read(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (want_close)
|
||||||
|
{
|
||||||
|
user_disconnect(user, want_close);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_is_logged_in(user))
|
||||||
|
{
|
||||||
|
user_trigger_update(user, want_write, TIMEOUT_IDLE);
|
||||||
|
}
|
||||||
|
else if (user_is_connecting(user))
|
||||||
|
{
|
||||||
|
user_trigger_update(user, want_write, TIMEOUT_HANDSHAKE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void net_on_accept(int server_fd, short ev, void *arg)
|
void net_on_accept(int server_fd, short ev, void *arg)
|
||||||
{
|
{
|
||||||
struct hub_info* hub = (struct hub_info*) arg;
|
struct hub_info* hub = (struct hub_info*) arg;
|
||||||
struct user* user = 0;
|
struct user* user = 0;
|
||||||
int accept_more = 1;
|
struct ip_addr_encap ipaddr;
|
||||||
const char* addr;
|
const char* addr;
|
||||||
struct timeval timeout = { TIMEOUT_CONNECTED, 0 };
|
|
||||||
|
|
||||||
while (accept_more)
|
for (;;)
|
||||||
{
|
{
|
||||||
int fd = net_accept(server_fd);
|
int fd = net_accept(server_fd, &ipaddr);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
if (net_error() == EWOULDBLOCK)
|
if (net_error() == EWOULDBLOCK)
|
||||||
@@ -262,7 +253,7 @@ void net_on_accept(int server_fd, short ev, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = net_get_peer_address(fd);
|
addr = ip_convert_to_string(&ipaddr);
|
||||||
|
|
||||||
/* FIXME: Should have a plugin log this */
|
/* FIXME: Should have a plugin log this */
|
||||||
hub_log(log_trace, "Got connection from %s", addr);
|
hub_log(log_trace, "Got connection from %s", addr);
|
||||||
@@ -284,17 +275,11 @@ void net_on_accept(int server_fd, short ev, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store IP address in user object */
|
/* Store IP address in user object */
|
||||||
ip_convert_to_binary(addr, &user->ipaddr);
|
memcpy(&user->ipaddr, &ipaddr, sizeof(ipaddr));
|
||||||
|
|
||||||
net_set_nonblocking(fd, 1);
|
net_set_nonblocking(fd, 1);
|
||||||
net_set_nosigpipe(fd, 1);
|
net_set_nosigpipe(fd, 1);
|
||||||
|
user_trigger_init(user);
|
||||||
event_set(user->ev_read, fd, EV_READ | EV_PERSIST, net_on_read, user);
|
|
||||||
event_set(user->ev_write, fd, EV_WRITE, net_on_write, user);
|
|
||||||
event_base_set(hub->evbase, user->ev_read);
|
|
||||||
event_base_set(hub->evbase, user->ev_write);
|
|
||||||
event_add(user->ev_read, &timeout);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,33 +20,19 @@
|
|||||||
#ifndef HAVE_UHUB_NET_EVENT_H
|
#ifndef HAVE_UHUB_NET_EVENT_H
|
||||||
#define HAVE_UHUB_NET_EVENT_H
|
#define HAVE_UHUB_NET_EVENT_H
|
||||||
|
|
||||||
/**
|
struct user;
|
||||||
* Network callback for reading data from a socket.
|
|
||||||
*/
|
|
||||||
extern void net_on_read(int fd, short ev, void *arg);
|
|
||||||
|
|
||||||
/**
|
extern void on_net_event(int fd, short ev, void *arg);
|
||||||
* Network callback for writing data to a socket.
|
|
||||||
*/
|
|
||||||
extern void net_on_write(int fd, short ev, void *arg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Network callback for timers.
|
|
||||||
*/
|
|
||||||
extern void net_on_read_timeout(int fd, short ev, void* arg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Network callback to accept incoming connections.
|
* Network callback to accept incoming connections.
|
||||||
*/
|
*/
|
||||||
extern void net_on_accept(int fd, short ev, void *arg);
|
extern void net_on_accept(int fd, short ev, void *arg);
|
||||||
|
|
||||||
#ifdef ADC_UDP_OPERATION
|
|
||||||
/**
|
/**
|
||||||
* Network callback to receive incoming UDP datagram.
|
*
|
||||||
*/
|
*/
|
||||||
extern void net_on_packet(int fd, short ev, void *arg);
|
extern void net_update_trigger(struct user* user, int write, struct timeval timeout);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* HAVE_UHUB_NET_EVENT_H */
|
#endif /* HAVE_UHUB_NET_EVENT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -236,13 +236,19 @@ int net_close(int fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int net_accept(int fd)
|
int net_accept(int fd, struct ip_addr_encap* ipaddr)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
|
struct sockaddr_in* addr4;
|
||||||
|
struct sockaddr_in6* addr6;
|
||||||
socklen_t addr_size;
|
socklen_t addr_size;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
addr_size = sizeof(struct sockaddr_storage);
|
addr_size = sizeof(struct sockaddr_storage);
|
||||||
|
|
||||||
memset(&addr, 0, addr_size);
|
memset(&addr, 0, addr_size);
|
||||||
|
addr4 = (struct sockaddr_in*) &addr;
|
||||||
|
addr6 = (struct sockaddr_in6*) &addr;
|
||||||
|
|
||||||
ret = accept(fd, (struct sockaddr*) &addr, &addr_size);
|
ret = accept(fd, (struct sockaddr*) &addr, &addr_size);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
@@ -270,6 +276,20 @@ int net_accept(int fd)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
net_stats_add_accept();
|
net_stats_add_accept();
|
||||||
|
|
||||||
|
if (ipaddr)
|
||||||
|
{
|
||||||
|
memset(ipaddr, 0, sizeof(struct ip_addr_encap));
|
||||||
|
ipaddr->af = addr4->sin_family;
|
||||||
|
if (ipaddr->af == AF_INET6)
|
||||||
|
{
|
||||||
|
memcpy(&ipaddr->internal_ip_data.in6, &addr6->sin6_addr, sizeof(struct in6_addr));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(&ipaddr->internal_ip_data.in, &addr4->sin_addr, sizeof(struct in_addr));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -465,11 +485,9 @@ const char* net_get_peer_address(int fd)
|
|||||||
name4 = (struct sockaddr_in*) &storage;
|
name4 = (struct sockaddr_in*) &storage;
|
||||||
name = (struct sockaddr*) &storage;
|
name = (struct sockaddr*) &storage;
|
||||||
|
|
||||||
|
|
||||||
int af = net_is_ipv6_supported() ? AF_INET6 : AF_INET;
|
|
||||||
|
|
||||||
if (getpeername(fd, (struct sockaddr*) name, &namelen) != -1)
|
if (getpeername(fd, (struct sockaddr*) name, &namelen) != -1)
|
||||||
{
|
{
|
||||||
|
int af = name4->sin_family;
|
||||||
if (af == AF_INET6)
|
if (af == AF_INET6)
|
||||||
{
|
{
|
||||||
net_address_to_string(af, (void*) &name6->sin6_addr, address, INET6_ADDRSTRLEN);
|
net_address_to_string(af, (void*) &name6->sin6_addr, address, INET6_ADDRSTRLEN);
|
||||||
|
|||||||
@@ -83,8 +83,11 @@ extern int net_close(int fd);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for the accept() function call.
|
* A wrapper for the accept() function call.
|
||||||
|
* @param fd socket descriptor
|
||||||
|
* @param ipaddr (in/out) if non-NULL the ip address of the
|
||||||
|
* accepted peer is filled in.
|
||||||
*/
|
*/
|
||||||
extern int net_accept(int fd);
|
extern int net_accept(int fd, struct ip_addr_encap* ipaddr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for the connect() call.
|
* A wrapper for the connect() call.
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ int route_to_user(struct user* user, struct adc_message* msg)
|
|||||||
{
|
{
|
||||||
queue_command(user, msg, ret);
|
queue_command(user, msg, ret);
|
||||||
|
|
||||||
if (user->send_queue_size && user->ev_write)
|
if (user->send_queue_size && user->ev_handle)
|
||||||
event_add(user->ev_write, NULL);
|
event_add(user->ev_handle, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -158,8 +158,8 @@ int route_to_user(struct user* user, struct adc_message* msg)
|
|||||||
{
|
{
|
||||||
/* queue command */
|
/* queue command */
|
||||||
queue_command(user, msg, 0);
|
queue_command(user, msg, 0);
|
||||||
if (user->ev_write)
|
if (user->ev_handle)
|
||||||
event_add(user->ev_write, NULL);
|
event_add(user->ev_handle, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
63
src/user.c
63
src/user.c
@@ -30,13 +30,11 @@ struct user* user_create(struct hub_info* hub, int sd)
|
|||||||
if (user == NULL)
|
if (user == NULL)
|
||||||
return NULL; /* OOM */
|
return NULL; /* OOM */
|
||||||
|
|
||||||
user->ev_write = hub_malloc_zero(sizeof(struct event));
|
user->ev_handle = hub_malloc_zero(sizeof(struct event));
|
||||||
user->ev_read = hub_malloc_zero(sizeof(struct event));
|
|
||||||
|
|
||||||
if (!user->ev_write || !user->ev_read)
|
if (!user->ev_handle)
|
||||||
{
|
{
|
||||||
hub_free(user->ev_read);
|
hub_free(user->ev_handle);
|
||||||
hub_free(user->ev_write);
|
|
||||||
hub_free(user);
|
hub_free(user);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -65,22 +63,8 @@ void user_destroy(struct user* user)
|
|||||||
{
|
{
|
||||||
hub_log(log_trace, "user_destroy(), user=%p", user);
|
hub_log(log_trace, "user_destroy(), user=%p", user);
|
||||||
|
|
||||||
if (user->ev_write)
|
user_trigger_shutdown(user);
|
||||||
{
|
|
||||||
event_del(user->ev_write);
|
|
||||||
hub_free(user->ev_write);
|
|
||||||
user->ev_write = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user->ev_read)
|
|
||||||
{
|
|
||||||
event_del(user->ev_read);
|
|
||||||
hub_free(user->ev_read);
|
|
||||||
user->ev_read = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
net_close(user->sd);
|
net_close(user->sd);
|
||||||
|
|
||||||
adc_msg_free(user->info);
|
adc_msg_free(user->info);
|
||||||
user_clear_feature_cast_support(user);
|
user_clear_feature_cast_support(user);
|
||||||
|
|
||||||
@@ -213,12 +197,7 @@ void user_disconnect(struct user* user, int reason)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dont read more data from this user */
|
/* dont read more data from this user */
|
||||||
if (user->ev_read)
|
user_flag_set(user, flag_ignore);
|
||||||
{
|
|
||||||
event_del(user->ev_read);
|
|
||||||
hub_free(user->ev_read);
|
|
||||||
user->ev_read = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
hub_log(log_trace, "user_disconnect(), user=%p, reason=%d, state=%d", user, reason, user->state);
|
hub_log(log_trace, "user_disconnect(), user=%p, reason=%d, state=%d", user, reason, user->state);
|
||||||
|
|
||||||
@@ -303,6 +282,36 @@ int user_is_disconnecting(struct user* user)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void user_trigger_init(struct user* user)
|
||||||
|
{
|
||||||
|
if (user->ev_handle)
|
||||||
|
{
|
||||||
|
struct timeval timeout = { TIMEOUT_CONNECTED, 0 };
|
||||||
|
event_set(user->ev_handle, user->sd, EV_READ | EV_PERSIST, on_net_event, user);
|
||||||
|
event_base_set(user->hub->evbase, user->ev_handle);
|
||||||
|
event_add(user->ev_handle, &timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void user_trigger_update(struct user* user, int w, int timeout_sec)
|
||||||
|
{
|
||||||
|
if (user->ev_handle)
|
||||||
|
{
|
||||||
|
struct timeval timeout = { timeout_sec, 0 };
|
||||||
|
int f = w ? EV_WRITE | EV_READ | EV_PERSIST : EV_READ | EV_PERSIST;
|
||||||
|
event_del(user->ev_handle);
|
||||||
|
event_set(user->ev_handle, user->sd, f, on_net_event, user);
|
||||||
|
event_base_set(user->hub->evbase, user->ev_handle);
|
||||||
|
event_add(user->ev_handle, &timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void user_trigger_shutdown(struct user* user)
|
||||||
|
{
|
||||||
|
if (user->ev_handle)
|
||||||
|
{
|
||||||
|
event_del(user->ev_handle);
|
||||||
|
hub_free(user->ev_handle);
|
||||||
|
user->ev_handle = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
19
src/user.h
19
src/user.h
@@ -47,11 +47,12 @@ enum user_flags
|
|||||||
feature_ping = 0x00000080, /** PING: Hub pinger information extension */
|
feature_ping = 0x00000080, /** PING: Hub pinger information extension */
|
||||||
feature_link = 0x00000100, /** LINK: Hub link (not supported) */
|
feature_link = 0x00000100, /** LINK: Hub link (not supported) */
|
||||||
flag_ignore = 0x01000000, /** Ignore further reads */
|
flag_ignore = 0x01000000, /** Ignore further reads */
|
||||||
flag_choke = 0x02000000, /** Choked: Cannot send, waiting for write event */
|
flag_maxbuf = 0x02000000, /** Hit max buf read, ignore msg */
|
||||||
flag_want_read = 0x04000000, /** Need to read (SSL) */
|
flag_choke = 0x04000000, /** Choked: Cannot send, waiting for write event */
|
||||||
flag_want_write = 0x08000000, /** Need to write (SSL) */
|
flag_want_read = 0x08000000, /** Need to read (SSL) */
|
||||||
flag_user_list = 0x10000000, /** Send queue bypass (when receiving the send queue) */
|
flag_want_write = 0x10000000, /** Need to write (SSL) */
|
||||||
flag_nat = 0x20000000, /** nat override enabled */
|
flag_user_list = 0x20000000, /** Send queue bypass (when receiving the send queue) */
|
||||||
|
flag_nat = 0x40000000, /** nat override enabled */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ enum user_quit_reason
|
|||||||
quit_protocol_error = 8, /** Fatal protocol error */
|
quit_protocol_error = 8, /** Fatal protocol error */
|
||||||
quit_logon_error = 9, /** Unable to login (wrong password, CID/PID, etc) */
|
quit_logon_error = 9, /** Unable to login (wrong password, CID/PID, etc) */
|
||||||
quit_hub_disabled = 10, /** Hub is disabled. No new connections allowed */
|
quit_hub_disabled = 10, /** Hub is disabled. No new connections allowed */
|
||||||
|
quit_ghost_timeout = 11, /** The user is a ghost, and trying to login from another connection */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -97,8 +99,7 @@ struct user_counts
|
|||||||
struct user
|
struct user
|
||||||
{
|
{
|
||||||
int sd; /** socket descriptor */
|
int sd; /** socket descriptor */
|
||||||
struct event* ev_read; /** libevent struct for read events */
|
struct event* ev_handle;
|
||||||
struct event* ev_write; /** libevent struct for write events */
|
|
||||||
enum user_state state; /** see enum user_state */
|
enum user_state state; /** see enum user_state */
|
||||||
enum user_credentials credentials; /** see enum user_credentials */
|
enum user_credentials credentials; /** see enum user_credentials */
|
||||||
struct user_info id; /** Contains nick name and CID */
|
struct user_info id; /** Contains nick name and CID */
|
||||||
@@ -254,7 +255,9 @@ extern int user_set_feature_cast_support(struct user* u, char feature[4]);
|
|||||||
*/
|
*/
|
||||||
extern void user_clear_feature_cast_support(struct user* u);
|
extern void user_clear_feature_cast_support(struct user* u);
|
||||||
|
|
||||||
|
extern void user_trigger_init(struct user* user);
|
||||||
|
extern void user_trigger_update(struct user* user, int w, int timeout_sec);
|
||||||
|
extern void user_trigger_shutdown(struct user* user);
|
||||||
|
|
||||||
#endif /* HAVE_UHUB_USER_H */
|
#endif /* HAVE_UHUB_USER_H */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user