Commit Graph

579 Commits

Author SHA1 Message Date
Jan Vidar Krey
458c7fa741 Remove list assertion when removing element that is not in the list.
Breaks autotest.
2012-05-01 20:40:27 +02:00
Jan Vidar Krey
74ca5a0a33 Cleaned up command handling code, by splitting into multiple files. 2012-05-01 20:15:49 +02:00
Tilka
e4cf01ff1f OMG OPTIMIZED 2012-04-21 16:56:22 +02:00
Tilka
b72f5a407a fix double free 2012-04-21 16:51:41 +02:00
Tilka
776f7d0bff use "0" instead of "false"
otherwise compilation breaks when using a C90 compiler
2012-04-21 13:35:06 +02:00
Tilka
27ceb7ad33 fix use of uninitialized struct ip_range 2012-04-21 09:46:50 +02:00
Tilka
c5036a3ff8 fix random crashes upon !reload
A struct plugin_hub_internals was falsely casted to struct
plugin_callback_data. This caused the contained commands list pointer to point to
a struct hub_info and commands->size took the value of a pointer to a struct
net_connection. Since size is increased/decreased every time an item is
added to/removed from the list, this resulted in some funny crashes.

This fix is a little dirty as it exports some internals.
2012-04-21 09:22:06 +02:00
Tilka
832277f653 fix command syntax 2012-04-21 06:08:36 +02:00
Tilka
c525e59fa5 use arg parser in !broadcast 2012-04-21 01:56:26 +02:00
Jan Vidar Krey
781f22edab Fixed tiny memory leak on reload/shutdown. 2012-04-19 20:05:37 +02:00
Jan Vidar Krey
55030935a7 Merge https://github.com/Tilka/uhub 2012-04-19 23:17:39 +02:00
Tilka
4f0c8e0356 fix multiple optional arguments
Assuming the argument definition "?xy", it was previously not possible
to specify only x. Also, the syntax will now be shown as "[x [y]]"
instead of "[x] [y]".
2012-04-19 03:06:52 +02:00
Tilka
e925db2b98 small cleanup 2012-04-19 02:56:27 +02:00
Tilka
e408ae3eba automatically clean up plugin commands 2012-04-19 02:53:43 +02:00
Jan Vidar Krey
1dba731cc3 Fix bug #158 - Added plugin for setting topic (hub description).
Load plugin mod_topic, and it will provide 3 new user commands:

!topic - set new topic
!cleartopic - reset the topic (use default hub description)
!showtopic - show the current topic
2012-04-19 00:33:38 +02:00
Jan Vidar Krey
df7bbc094f Command arguments handling + cleanups
Fix bug #185 - Args of !commands lost/damaged.
All string arguments were incorrectly freed after being added to the argument list for a command.
Instead this fix makes sure it is properly copied into a new string, and by doing so this requires
a new API for dealing with hub command arguments in a type safe manner, and also allows for each
argument to be cleaned up properly when the command is no longer needed.

This also fixes issues with parse errors for certain types, and optional arguments (previously it was impossible
to tell the difference for an integer with value 0 or if no integer was given).

All arguments can now be accessed through the new functions
hub_command_arg_reset() and hub_command_arg_next().

These functions are also exposed to plug-ins.

The argument type notations for 'n' has changed to mean nick (string),
and 'u' is used for a user (struct hub_user - must be online).
2012-04-18 23:03:05 +02:00
Jan Vidar Krey
5068fe8351 Cygwin/Mingw32 compile fixes. 2012-01-25 00:20:59 +01:00
Jan Vidar Krey
8607b40278 Fix bug #180 - Crash after signal SIGHUP. 2012-01-19 02:58:20 +01:00
Jan Vidar Krey
a9b5c6db38 Fixed minor issues found with static code analyzis (Clang). 2012-01-13 01:31:34 +01:00
Jan Vidar Krey
ff639d87c3 Disable SQL debugging output. 2012-01-10 02:21:22 +01:00
Jan Vidar Krey
5edf2b60d4 Fixed bug #179 - !broadcast command does not work properly. 2012-01-10 02:21:22 +01:00
Jan Vidar Krey
eee2636582 Added a chat only hub plugin that disables searching and connection setup.
This also deprecates the built-in chat_only configuration option.
If you need this functionality, then load the mod_chat_only plugin (if it is loaded then only operators
are able to search, connect, etc).
2012-01-09 20:58:19 +01:00
Jan Vidar Krey
ca3782c570 Merge branch 'mod_chat_history_work'
Conflicts:
	doc/plugins.conf
2012-01-03 23:22:41 +01:00
Jan Vidar Krey
875f55a401 Added a chat history plugin.
The mod_chat_history plugin provides chat history for all public chat messages.

Can be configured in the following ways:

- history_max: max number of messages stored in history
- history_default: the default number of messages to be returned when invoking !history
- history_connect: if > 0, then this number of messages is automatically sent when connecting to the hub

Removed the built-in !history command in favour of the mod_chat_history plug-in.

Make sure we unescape all chat messages before forwarding any of them to plugins.

Update example plugins.conf in documentation directory.
2012-01-03 23:22:41 +01:00
Jan Vidar Krey
a9ed03cf38 Cleaned up the mod_welcome parse failure code. 2012-01-02 12:54:35 +01:00
Jan Vidar Krey
7b392acbf5 Format the help list appropriately (as in older versions). 2011-12-28 10:45:02 +01:00
Jan Vidar Krey
66c77d5170 Don't broadcast the \!example command when issuing it (mod_example.c bug). 2011-12-28 10:44:03 +01:00
Jan Vidar Krey
1700a27619 Fix bug #173 - Fix the command parsing errors. 2011-12-22 01:49:21 +01:00
Jan Vidar Krey
fe15c4cb58 Fix VS2010 build issues. 2011-12-22 01:39:40 +01:00
Jan Vidar Krey
ecedd44fee Added %c substitution to mod_welcome to print the current user credentials. 2011-12-22 00:14:34 +00:00
Jan Vidar Krey
24e2c2090e Fix welcome plugin handle, and build issues. 2011-12-21 23:50:23 +00:00
Jan Vidar Krey
2a190859bd Remove the configuration options 'file_motd' and 'file_rules'. Use mod_welcome instead. 2011-12-21 14:44:37 +01:00
Jan Vidar Krey
88dd1341d2 Started working on mod_welcome which will replace the built-in file_motd and file_rules configuration options. 2011-12-21 14:31:29 +01:00
Jan Vidar Krey
b24d4b85cd Split out the command buffer code to a generic buffer. 2011-12-21 13:53:53 +01:00
Jan Vidar Krey
f34f0328a3 Removed the PLUGIN_SUPPORT code, since plugin support is now mandatory. 2011-12-21 10:48:37 +01:00
Jan Vidar Krey
f31fc65e1d VS2010 fixes. 2011-12-21 01:42:21 +01:00
Jan Vidar Krey
7325b15786 Fix bug #174 - Wrong check for fdatasync() availability. 2011-12-21 00:55:22 +01:00
Jan Vidar Krey
ec3afc3a44 Added a simple tool to create and manipulate the uhub sqlite authentication database. 2011-12-20 16:20:54 +01:00
Jan Vidar Krey
ba26f4c5e2 Update copyright notices and added licenses to files that were missing it. 2011-12-19 10:54:47 +01:00
Jan Vidar Krey
68dc3cafc7 Removed unused files. 2011-12-19 10:51:45 +01:00
Jan Vidar Krey
583900cec5 Fix compile warning about unused result for write() function. 2011-12-19 00:40:02 +01:00
Jan Vidar Krey
93caa9b3c1 Fix compile warning about uninitiaized variable. 2011-12-19 00:36:53 +01:00
Jan Vidar Krey
f2cb84180a Refactored command parsing.
Allows for automatically tested command parsing by splitting parsing
and invokation of the commands.
2011-12-19 00:34:45 +01:00
Jan Vidar Krey
fc5e09aa9e fixup! Fix bug #171 - Race condition could allow two users with same CID or nick to enter the hub. 2011-12-12 12:03:28 +01:00
Jan Vidar Krey
b4779bfb12 Fix bug #171 - Race condition could allow two users with same CID or nick to enter the hub. 2011-12-11 13:38:36 +01:00
Jan Vidar Krey
6d609e18a2 Windows/VS2010 fixes. 2011-12-11 12:53:09 +01:00
Jan Vidar Krey
ebd3ccf98e Disable the kqueue backend because it crashes under certain circumstances (see bug #169). 2011-12-09 17:01:02 +01:00
Jan Vidar Krey
aec89fc125 Fix memory leaks when parsing user commands. 2011-12-09 16:54:48 +01:00
Jan Vidar Krey
9377fb537a Fix memory leak when unloading plugins. 2011-12-09 16:39:19 +01:00
Jan Vidar Krey
afda1d7b9d Added a LOG_PLUGIN macro for plugin output debug messages.
Converted all TRACE messages related to plugins to LOG_PLUGIN.
2011-12-09 16:38:11 +01:00
Jan Vidar Krey
2352e5a0dd Fix memory leak for built-in commands. 2011-12-09 16:35:42 +01:00
Jan Vidar Krey
1dc79c641c Cleanup: do not use strcat(). 2011-12-09 15:58:58 +01:00
Jan Vidar Krey
41824ce2bf Fix compile issues on debian ports for GNU Hurd and Linux for s390. 2011-12-09 14:31:02 +01:00
Jan Vidar Krey
65c2652a22 Fix build errors on the Debian kfreebsd port. 2011-12-09 14:24:21 +01:00
Jan Vidar Krey
fb89307b0a fixup! Fix compiler warnings using gcc 4.6. 2011-12-09 14:21:16 +01:00
Jan Vidar Krey
7825c413d4 fixup! Added support for dynamic commands. 2011-12-09 13:04:05 +01:00
Jan Vidar Krey
318163c066 Added support for dynamic commands.
Dynamic commands are user commands that can be added dynamically to
the hub by a plugin.

The example plugin (mod_example.c) adds a !example command that when
invoked send a message to the user who invoked it.
2011-12-09 10:29:50 +01:00
Jan Vidar Krey
e972b03f38 Fix SSL disconnect memory leak. 2011-12-02 13:03:17 +01:00
Jan Vidar Krey
9f16298688 Fix minor valgrind issues
- Fix valgrind invalid write of 1 byte.
- Fix a few plugin related memory leaks.
2011-12-01 15:14:01 +01:00
Jan Vidar Krey
c17b43e77f Fix bug #144 - Count SSL traffic in !stats. But this does not include the SSL overhead. 2011-11-30 14:54:54 +01:00
Jan Vidar Krey
675e6af3ba Don't print warnings about known extensions that don't affect the hub at all (DHT0). 2011-11-30 14:14:36 +01:00
Jan Vidar Krey
2396d8555c Fix bug #167 - Build errors on OpenBSD.
- Don't link with -ldl, as it is not needed in most cases
- Don't compile plugins if USE_PLUGINS=NO
- Fix warning about missing newline at end of getopt.h
- Removed the O_NOATIME open() flag from the logging plugin.
- Removed the O_LARGEFILE open() flag. _FILE_OFFSET_BITS is 64.
- Use fsync() if fdatasync() is not available for log file writing.
- Replaced some sprintf() with snprintf() due to compiler warnings (though, they were length limited otherwise).
- Replaced two occurences of strcpy() with memcpy().
2011-11-30 13:43:39 +01:00
Jan Vidar Krey
9981acca08 Supply sid with user information in adcclient test code. 2011-11-30 12:32:59 +01:00
Jan Vidar Krey
99e644597d Cleaned up the ADC client test code.
Now works with ADCS (not very well tested, though)
2011-11-29 16:39:09 +01:00
Jan Vidar Krey
3a39a36fbb Fix for bug #166 - TLS crash. 2011-11-29 10:19:43 +01:00
Jan Vidar Krey
1102a86463 Adcrush fixes. 2011-11-28 16:36:45 +01:00
Jan Vidar Krey
bad4512a37 Fix compiler warnings using gcc 4.6. 2011-11-28 16:30:35 +01:00
Jan Vidar Krey
3b4a199673 Fix null pointer crash while encountering configuration file errors during parsing. 2011-10-17 09:50:14 +02:00
Jan Vidar Krey
39572c3684 Made plugin loading work properly on Windows. 2011-09-08 01:00:32 +02:00
Jan Vidar Krey
33b94d8eb4 Removed unused functions - prevents compile warnings. 2011-09-07 10:02:43 +02:00
Jan Vidar Krey
324bfcd2c8 Added plugin loader routines for windows. 2011-09-07 00:31:38 +02:00
Jan Vidar Krey
800f6a70f9 Added description to plugin_hub_info (an empty struct causes warning on VS2010). 2011-09-05 23:40:57 +02:00
Jan Vidar Krey
70f13158d3 Merge branch 'master' of github.com:janvidar/uhub 2011-09-05 23:34:05 +02:00
Jan Vidar Krey
9327615448 Compile warning fix. 2011-09-05 23:16:15 +02:00
Jan Vidar Krey
ebe54bcf27 Added plugin events for server wide events (mostly for logging). 2011-08-16 15:11:15 +02:00
Jan Vidar Krey
998f5a57e2 Fix bug #152 - disable self-registering 2011-08-16 15:09:02 +02:00
Jan Vidar Krey
472c489ae1 Fix bug #154 - plugin system is disabled silently if one plugin fails to initialize. 2011-08-16 14:46:11 +02:00
Jan Vidar Krey
bba7c0d05b Require setting the file name via file=/path/to/file for log file. 2011-08-16 14:33:15 +02:00
Jan Vidar Krey
169b8a4a75 Added option to redirect from adc:// to adcs:// if tls is required. 2011-08-16 12:11:04 +02:00
Jan Vidar Krey
f13bcd8c28 Minor compile fixes. 2011-08-16 12:08:21 +02:00
Jan Vidar Krey
a79fcd796e Shutdown SSL on close. 2011-08-16 12:07:17 +02:00
Jan Vidar Krey
474e2be308 Fix stupid mistake. 2011-08-16 12:06:44 +02:00
Jan Vidar Krey
47cf3326fd Don't do SSL_clear unless the SSL object is initialized. 2011-08-16 12:06:34 +02:00
Jan Vidar Krey
3353049ae3 Several SSL/TLS related memory leak fixes. 2011-08-16 12:06:17 +02:00
Jan Vidar Krey
3ccce614d0 Fix SSL/TLS related memory leak. 2011-08-16 12:04:14 +02:00
Jan Vidar Krey
e30505b54e Fix 100% CPU issue with SSL connections. 2011-08-16 12:04:03 +02:00
Jan Vidar Krey
3bc764adf5 Winsock fixes. 2011-08-08 00:12:50 +02:00
Jan Vidar Krey
6becadc984 Compile fix for gcc. 2011-02-05 17:18:08 +01:00
Jan Vidar Krey
d01813ef48 Added project files for Visual Studio 2010. 2011-02-05 17:13:26 +01:00
Jan Vidar Krey
e5bb7057de Windows fixes. 2011-02-05 17:11:23 +01:00
Jan Vidar Krey
bf4ad5624a Visual Studio compile fixes. 2011-01-12 16:58:18 +01:00
Jan Vidar Krey
03b4252ab5 Link fix in case not everything is linked as one binary. 2011-01-06 12:25:28 +01:00
Jan Vidar Krey
4c238dd946 Fix compile warning. 2011-01-03 00:12:40 +01:00
Jan Vidar Krey
9b57279628 Many Visual C++ compile warnings and errors fixed. 2011-01-03 00:03:07 +01:00
Jan Vidar Krey
adb6641a17 PATCH: Redirect did not work properly (Thanks MiMic)
The SID was not included in the redirect and it was thus an
incorrect ADC message which were discarded by most clients.
2010-12-29 14:40:23 +01:00
Jan Vidar Krey
67eabb5a98 Fix #157: calculation of limits for min/max share on 32 bit architectures. 2010-12-20 23:18:41 +01:00
Jan Vidar Krey
4ede1b2d8a Fix for bug #156 2010-12-20 11:52:15 +01:00
Jan Vidar Krey
b993e97bb4 Fix bug in config parser where 'foo=bar' did not work, but 'foo = bar' did work due to extra whitespace between tokens. 2010-11-18 22:43:48 +01:00
Jan Vidar Krey
4f8e3ba10b Cleaned up command parsing, added register, password, useradd, userdel, userinfo, usermod and userpass.
Mostly not implemented.
2010-11-12 18:03:39 +01:00
Jan Vidar Krey
16fc3ea68e Clean up argument parsing for plugins. 2010-11-12 18:03:39 +01:00
Jan Vidar Krey
a934dfaa70 Cleaned up boolean apply code. 2010-11-12 18:03:39 +01:00
Jan Vidar Krey
21c22288a2 Simplified plugin initialization by using a macro. 2010-11-12 18:03:39 +01:00
Jan Vidar Krey
ff8b8f5175 Fix bug #139: Unable to use TLS - due to not handling quotes around configuration strings.
Conflicts:

	src/util/misc.c
2010-08-16 22:53:16 +02:00
Jan Vidar Krey
1af7e26c52 Moved flood control stuff to the util package. 2010-08-11 22:46:06 +02:00
Jan Vidar Krey
35b055f9b7 Allow for connections accepted/refused to be logged by plugins. 2010-08-11 22:46:06 +02:00
Jan Vidar Krey
4c960cb977 Added logging of chat messages in the plugin API. 2010-08-11 22:46:06 +02:00
Jan Vidar Krey
c2b7ecd49c Made sure the logging plugin logs on a format that looks almost the same as we used to have in the past. 2010-08-04 17:03:37 +02:00
Jan Vidar Krey
0c6a58d35a Make sure chat messages are routed through plugins. 2010-08-03 23:19:39 +02:00
Jan Vidar Krey
4a977da514 Remember to terminate the SQL escaped string. 2010-08-03 23:15:37 +02:00
Jan Vidar Krey
e03b4ff0c1 Use correct sqlite escapes of strings. 2010-07-29 11:29:40 +02:00
Jan Vidar Krey
4bf882d385 Fixed credentials handling, and added debug output for SQL. 2010-07-29 11:22:57 +02:00
Jan Vidar Krey
dbf790bb93 Added autotests for credentials handling. 2010-07-29 11:22:04 +02:00
Jan Vidar Krey
5d135bb5b7 Use the credentials converter to determine user level. 2010-07-29 10:39:34 +02:00
Jan Vidar Krey
55ffe46a38 Added an SQLite authentication backend. 2010-07-29 08:49:24 +02:00
Jan Vidar Krey
93be2c584e Reworked plugin APIs slightly, added full support for authentication from plugins. 2010-07-29 08:43:22 +02:00
Jan Vidar Krey
c75090cdf2 Added a generic string to boolean parser. 2010-07-29 08:42:40 +02:00
Jan Vidar Krey
97feb3635e Allow plugins to provide an error message. Useful for reporting problems
when registering the plugins.
2010-07-29 08:41:26 +02:00
Jan Vidar Krey
350791cdf8 Added plugin invokers for authentication code. 2010-07-23 01:23:13 +02:00
Jan Vidar Krey
c6cf03614f Implement more plugin invokers, and call them. 2010-07-23 00:38:11 +02:00
Jan Vidar Krey
bdcf35b63d Cleanup code and allow for plugins to provide an error message. 2010-07-19 01:36:23 +02:00
Jan Vidar Krey
d41d649353 Encapsulate token API. 2010-07-18 19:43:11 +02:00
Jan Vidar Krey
56e5557146 Cleaned up the credentials handling, and made it ready for plugins. 2010-07-12 19:05:50 +02:00
Jan Vidar Krey
e4977606a7 Made sure logs can be rotated by sending a SIGHUP to the hub. 2010-07-12 17:00:10 +02:00
Jan Vidar Krey
f386e57de8 Updated copyright of touched files. 2010-07-10 03:41:49 +02:00
Jan Vidar Krey
ccb318547d Started using new file reader tokenizer. 2010-07-10 03:36:47 +02:00
Jan Vidar Krey
394c8a5f95 Whitespace fixes. 2010-07-09 14:01:22 +02:00
Jan Vidar Krey
4b22ccb73c Added a proper config file tokenizer that supports escaping sequences
and comments.

This allows for:

'"foo bar"' can be represented as 'foo\ bar'.

And allows for comments using the hash symbol (#), but not inside
escapes or quotes. "#this is not a comment", \#this\ is\ not\ a comment.

All configuration file parsers should be rewritten using this functionality.
2010-07-09 14:01:03 +02:00
Jan Vidar Krey
849a791f79 Fixed plugin handling when using the utils code from within a plugin. 2010-07-08 14:26:07 +02:00
Jan Vidar Krey
490f7dd835 Merge branch 'plugin_work' 2010-06-30 19:24:03 +02:00
Jan Vidar Krey
aa26052479 Misc plugin work
* Fix crash when unloading plugins.
* Fixed plugin loader and plugin unload handler.
* Added a new example plugin: mod_logging which logs users logging in and out of the hub to stdout.
2010-06-29 15:40:19 +02:00
Jan Vidar Krey
7b96e2c912 Merge branch 'plugin_work' of git://github.com/janvidar/uhub 2010-06-22 14:35:15 +02:00
Jan Vidar Krey
ccaa4860b4 Started working on the plugin configuration and loader code.
The example plugin works, but does not do anything.
2010-06-13 19:34:20 +02:00
Jan Vidar Krey
7218011449 Added missing plugin file. 2010-06-07 15:42:38 +02:00
Jan Vidar Krey
0810982b57 Fix bug #136 - !broadcast does not report status back to to sender. 2010-06-07 15:41:07 +02:00
Jan Vidar Krey
baeba01835 Added file_plugins directive to configuration file. 2010-06-06 16:32:43 +02:00
Jan Vidar Krey
07d4e4470c More work on the plugin API. 2010-06-06 16:19:59 +02:00
Jan Vidar Krey
ed53034ad5 Added plugin loader code, merely a wrapper around dlopen() and friends. 2010-05-30 23:33:06 +02:00
Jan Vidar Krey
fc8965f1c5 Started working on an authentication plugin API. 2010-05-30 13:03:03 +02:00
Jan Vidar Krey
b3ed3a5526 Fix a silly invalid read operation 2010-05-28 15:23:44 +02:00
Jan Vidar Krey
1480b7e9c0 Fix bug #133 - Kqueue backend crash (BSD/OSX) 2010-05-28 15:22:33 +02:00
Jan Vidar Krey
50fde1c5c8 Updated the broadcast command to not send the message back to the user that sent it, but
instead summarize the number of users that received it.
2010-05-26 09:38:14 +02:00
Jan Vidar Krey
77faac0494 Fixed some minor issues found during code review. 2010-05-25 22:47:30 +02:00
Jan Vidar Krey
473ff0e159 Fix static buffer overrun - Thanks BlackSonar. 2010-05-25 22:23:40 +02:00
Jan Vidar Krey
62333c5f39 Update the command to send a PM originating from the operator/admin that sent it. 2010-05-25 22:21:56 +02:00
Jan Vidar Krey
44860c8477 Fix bug #131 - Missing escape handling for # in config files.
Added support for escaping stuff in the configuration file parser.
2010-05-25 19:43:32 +02:00
Jan Vidar Krey
c70119870a Adding support for redirecting clients to other hubs when they fail to login
for various reasons.

Config variable is "redirect_addr".
2010-04-22 21:07:46 +02:00
Jan Vidar Krey
b29f34af4a FreeBSD kqueue backend fixes.
This fixes bug #126 - Core dump on FreeBSD with obsolete_clients=0
2010-04-22 16:11:50 +02:00
Jan Vidar Krey
076492f1b9 Fix some small memory leaks. 2010-04-21 18:34:55 +02:00
Jan Vidar Krey
b6fb2b41bd Fix a potential crash 2010-04-21 18:34:39 +02:00
Jan Vidar Krey
c82f8ba167 Fix compile error. 2010-04-16 06:31:47 +02:00