Commit Graph

636 Commits

Author SHA1 Message Date
Jan Vidar Krey
b85381c0f5 Added configuration options for TLS cipher suites and TLS versions. 2014-07-29 13:31:42 +02:00
Hector Martin
0426cb523a Fix: Rework SSL poll event handling to avoid infinite loops
The downstream connection callback must only be invoked when the event
that SSL requests for the connection to make progress has actually
occured. Otherwise, the downstream callback might do nothing but
re-queue an unrelated event (e.g. in user_net_io_want_write), and the
event loop comes around instantly while making no progress. Track the
SSL-requested events separately and deliver the required downstream
event when they fire.

Sample strace:

epoll_wait(0, {{EPOLLIN, {u32=96, u64=96}}}, 91, 10000) = 1
: net_ssl_callback in state tls_st_need_write calls cb NET_EVENT_WRITE
: User writes data, OpenSSL tries to write data
write(96, <snip>..., 170) = -1 EAGAIN (Resource temporarily unavailable)
: handle_openssl_error requests NET_EVENT_WRITE
epoll_ctl(0, EPOLL_CTL_MOD, 96, {EPOLLOUT, {u32=96, u64=96}}) = 0
: User callback then requests NET_EVENT_READ|NET_EVENT_WRITE
epoll_ctl(0, EPOLL_CTL_MOD, 96, {EPOLLIN|EPOLLOUT, {u32=96, u64=96}}) =
: Data available for *reading*
epoll_wait(0, {{EPOLLIN, {u32=96, u64=96}}}, 91, 10000) = 1
: net_ssl_callback in state tls_st_need_write calls cb NET_EVENT_WRITE
: again...
2014-07-29 12:09:07 +02:00
Jan Vidar Krey
9f78a2e85f Merge branch 'master' of github.com:janvidar/uhub 2014-05-30 15:06:23 +02:00
Jan Vidar Krey
f472fc9424 Fix Clang compile warnings. 2014-05-14 21:00:42 +02:00
Jan Vidar Krey
7706e1cb8a Fix copyright year. 2014-05-14 11:39:18 +02:00
Jan Vidar Krey
24b98358d3 Remove usage of strcat, since OpenBSD does not like that. 2014-05-14 11:00:18 +02:00
Jan Vidar Krey
5e06b46deb Fix compile warning due to missing newline at EOF. 2014-05-14 11:00:04 +02:00
Jan Vidar Krey
e2b0757f4a Improved flood control counting to strictly not allow more than
the given amount of messages in the configured interval.

The previous behavior allowed n+2 messages in the interval, due to
two off by one comparison rules.

In addition, if flooding is detected then each new message after the flooding
is detected will reset the interval timer, which means the client
cannot send another message until the timeout interval expires.
2014-05-08 13:30:09 +02:00
Tillmann Karras
c295461f4e mod_topic: check argument for NULL
Better safe than sorry.
2013-09-10 08:30:27 +02:00
Tillmann Karras
8b442018a7 Fix struct mixup 2013-09-06 21:17:43 +02:00
Tillmann Karras
fa782e3d2c Fix memleak 2013-09-06 21:17:31 +02:00
Tilka
591d0ba5bb Support certificate chains 2013-09-06 01:44:25 +02:00
Tilka
a81757c483 Merge remote-tracking branch 'upstream/master' 2013-09-06 01:43:10 +02:00
Jan Vidar Krey
cf9be754aa Rewrote the configuration file parser generator.
Converted from Perl to Python for a better
and cleaner object oriented design.
2013-04-22 21:58:06 +02:00
Jan Vidar Krey
73b4d51393 fixup! fixup! Updated copyright year. 2013-03-24 20:17:51 +01:00
Jan Vidar Krey
50b6221874 fixup! Updated copyright year. 2013-03-24 20:17:51 +01:00
Jan Vidar Krey
bb5865d368 Fix double free() 2013-03-24 09:47:32 +01:00
Jan Vidar Krey
550740f715 Fix bug #198 - Timers could cause infinite loops
This could essentially happen due to time drift,
high load, or the process being put in sleep for a while.

The reason is that recurring timers could be added to the same time slot
as the timeslot being handled.
2013-03-24 09:47:32 +01:00
mimicmod
5672ba14e3 Added mod_chat_history_sqlite and mod_chat_is_privileged.
Use file=/path/to/db to specify the database file where chat history should be stored. Other config variables are the same as those for mod_chat_history.

Code merged adapted and merged from Mimicmod's repository:
https://github.com/mimicmod/uhub.git
2013-03-23 22:47:32 +01:00
Jan Vidar Krey
cd5c4ee622 Optimize lookups by CID and nick.
This used to be a linear search O(n), but is now done
as a red-black tree O(log n) instead.

These operations can be further opimized with a hash-table
which would acheive near constant time lookups.
2013-03-23 22:11:05 +01:00
Jan Vidar Krey
52211a6bac Updated copyright year. 2013-03-22 20:00:40 +01:00
Jan Vidar Krey
f25015927a Clean up white space. 2013-03-22 20:00:40 +01:00
Jan Vidar Krey
5835a06676 Removed redundant debug printf. 2013-03-22 20:00:40 +01:00
Jan Vidar Krey
6c55ae1146 Simple compile fix. 2013-03-22 20:00:40 +01:00
Jan Vidar Krey
2d6f69d299 Cleaned up usage of linked lists and added missing functionality.
- Added a list_remove_first() which is generally better than list_remove()
  provided you want to remove the first element.
- Added a list_append_list() to append and move all nodes from one list to
  another.
2013-03-22 20:00:40 +01:00
Jan Vidar Krey
b81bb2cbd9 Cleaned up all list iterations, added macro named LIST_FOREACH.
Previously you would have to do something like this:

for (type foo = (type) list_get_first(list); foo; foo = (type) list_get_next(list)
{
    /* code */
}

Now, you can instead write this as:

LIST_FOREACH(type, foo, list,
{
    /* code */
})

Basically, boilerplate stuff including the casting is gone.
2013-03-22 00:58:14 +01:00
Jan Vidar Krey
1fbde2b0fd Re-factored the ADC client code to use the new connection establishment API. 2013-02-05 22:43:59 +01:00
Jan Vidar Krey
92b65a0e14 Created a connection establishment API.
This API provides transparent asynchronous DNS lookups
with both IPv4 and IPv6 support, and in addition will try
to connect to all addresses until one of them work.

This implements the "happy eyeballs" algorithm provided that the client supports IPv6
and that the DNS records provides both IPv6 and IPv4 addresses.
2013-02-05 22:40:20 +01:00
Jan Vidar Krey
4d438e1e90 Don't poll the connection monitor if there are no connections added.
This caused the backends to return an error code, which
in turn ended the mainloop. However, several other things
also might occur in the main loop, such as DNS lookups which
come prior to creating any connections that in turn would be monitored.
2013-02-05 22:38:13 +01:00
Jan Vidar Krey
4f3c71234b Merge branch 'master' of https://github.com/3M3RY/uhub 2012-11-22 22:26:46 +01:00
Boris Pek
b452488431 Fix build in Debian GNU/Hurd. 2012-11-20 22:41:38 +02:00
Emery
143b68588a Systemd notify support 2012-11-17 09:57:14 -06:00
Emery
ce68c446d1 Optional systemd journal logging 2012-11-11 15:21:00 -06:00
Tillmann Karras
37c80fd403 rename !cleartopic to !resettopic
The command resets the topic to the default as configured in uhub.conf.
"clear" wrongly implies that the topic will be emptied.

Also added a plugin description in plugins.conf.
2012-11-08 15:14:58 +01:00
Tillmann Karras
dcc7aa4018 some regex adjustments
IP addresses are now checked for correct charset rather than allowing
everything.
2012-11-08 12:36:37 +01:00
Tilka
9dce6693f6 fix error messages and comments 2012-11-08 12:27:08 +01:00
Jan Vidar Krey
a43953bc0d Added simple plugin that blocks downloads for non-registered users (guests). 2012-11-01 22:07:55 +01:00
Jan Vidar Krey
594801df46 Fix windows compile issues. 2012-11-01 21:52:33 +01:00
Jan Vidar Krey
3dcbb63a31 Implemented a simlpe red-black tree which should give better performance
for certain lookups.

The rb_tree will act as a general purpose key/value storage, and
also give a performance boost in the cases where the other
simple alternative would be to use a linked_list.

On average this should give on average O(log n) lookups, while the linked_list
would be O(n) at worst.
2012-11-01 21:46:44 +01:00
Jan Vidar Krey
2d2ccc0039 Merge branch 'async_dns_api' 2012-11-01 10:42:19 +01:00
Jan Vidar Krey
0a2f9c4b79 Merge branch 'autotest' 2012-11-01 10:40:51 +01:00
Jan Vidar Krey
ae62c35cb9 Disable SSL compression. 2012-11-01 10:39:31 +01:00
Jan Vidar Krey
d4763e54db Fixed memory leaks. 2012-10-25 04:13:45 +02:00
Jan Vidar Krey
38b19f633d Fix memory leaks and report "host is not found" correctly. 2012-10-25 04:13:05 +02:00
Jan Vidar Krey
d106ecdc65 Bugfixes for pthreads. 2012-10-25 04:10:42 +02:00
Jan Vidar Krey
99a2307d1d Simple compile fix. 2012-10-25 00:44:21 +02:00
Jan Vidar Krey
470c936e63 Converted the DNS resolver to work with the new threading API abstraction. 2012-10-25 00:40:16 +02:00
Jan Vidar Krey
168fc5bfcc Abstracted the threading code so that it works with Winthreads and pthreads. 2012-10-25 00:39:44 +02:00
Jan Vidar Krey
b34b90f95a Start using the async DNS API. 2012-10-24 23:22:10 +02:00
Jan Vidar Krey
793790d089 Initial implementation of an async DNS client API with getaddrinfo + pthreads. 2012-10-24 23:19:14 +02:00
Jan Vidar Krey
19559f4974 Make sure we count OpenSSL traffic for the byte IO statistics. 2012-10-18 11:40:18 +02:00
Jan Vidar Krey
4385266bb7 Free all memory in case the hub does not start because of port already in use. 2012-10-17 20:54:46 +02:00
Jan Vidar Krey
c50eb90bee Removed the last bits of OpenSSL code called directly 2012-10-17 20:53:05 +02:00
Jan Vidar Krey
1e0927f510 Update copyright year. 2012-10-17 20:00:52 +02:00
Jan Vidar Krey
b9d43c784c Merge branch 'master' of github.com:janvidar/uhub
Conflicts:
	CMakeLists.txt
2012-10-17 19:59:02 +02:00
Jan Vidar Krey
2f830d3132 Cleaned up error handling. 2012-10-17 15:39:48 +02:00
Jan Vidar Krey
5884983a2f Return -1 as error for recv/send only to signal socket has closed, use a number < -1 for socket errors. 2012-10-17 15:02:32 +02:00
Jan Vidar Krey
c43acd97bd Fixed accept/connect state event propagation.
Also removed some unused states and flags.
2012-10-17 09:25:15 +02:00
Jan Vidar Krey
b1f2c93738 Reworked the error handling of non-blocking reads and writes.
This should prevent busy loops where the socket is makred readable
but we are really only looking for it to become writable.
2012-10-17 09:16:02 +02:00
Jan Vidar Krey
50912bdf75 More work on splitting out OpenSSL specific bits. 2012-10-15 20:39:03 +02:00
Boris Pek
ddfbb919a7 Fix build in Debian GNU/kFreeBSD. 2012-10-14 02:13:10 +03:00
Jan Vidar Krey
f3922bb3e0 Work on splitting out OpenSSL cleanly. 2012-10-12 14:24:03 +02:00
Jan Vidar Krey
f20c42d05f Wrapped everything OpenSSL related in a SSL_USE_OPENSSL check macro. 2012-10-02 23:59:11 +02:00
Jan Vidar Krey
3ea38c59af Better reporting using the !stats command. 2012-10-02 23:59:11 +02:00
Jan Vidar Krey
50292cb8c9 Update the network statistics every 10 seconds instead of 60 seconds. 2012-10-02 23:59:11 +02:00
Jan Vidar Krey
e4fc91dde1 Made the network statistics work again. 2012-10-02 23:59:11 +02:00
Jan Vidar Krey
8086d89e23 Better formatting of byte sizes. 2012-10-02 23:59:11 +02:00
Jan Vidar Krey
cc2ead8136 Use util's format_size. 2012-10-09 10:20:58 +02:00
Jan Vidar Krey
10d8157477 Added a utility function to convert an arbitrary byte size into a human readable string.
E.g. 849484 becomes "829.57 KB".
2012-10-09 10:20:12 +02:00
Jan Vidar Krey
0a7cb86014 Fixed a crash in plugin mod_chat_only. 2012-10-09 10:02:08 +02:00
Jan Vidar Krey
2e8c99b7ec Refurbished the ADC hub stress-tester tool; adcrush 2012-10-02 23:59:11 +02:00
Jan Vidar Krey
cb6236691b Added more functionality to the ADC client test code. 2012-10-02 23:59:11 +02:00
Jan Vidar Krey
5136525abc Added API to construct ADC messages with source and destination. 2012-10-02 23:59:11 +02:00
Tillmann Karras
16ee65422d Fix cbuffer initialization
If no data was appended, cbuf_get() would return a pointer to
uninitialized memory. Now it returns a pointer to a string of zero
length.
2012-10-03 22:40:33 +02:00
Jan Vidar Krey
f0b11dadf1 Refurbished adcrush (hub stress tester). 2012-10-03 13:51:07 +02:00
Jan Vidar Krey
61073bd304 Fix rare protocol parse error due to incorrect recv queue handling. 2012-10-03 13:49:50 +02:00
Jan Vidar Krey
20a847e1b4 Moved the ipcalc code to the network directory. 2012-10-03 12:59:05 +02:00
Jan Vidar Krey
a90807fccb Fix version auto generation. 2012-10-03 12:02:35 +02:00
Jan Vidar Krey
089966d918 Fix ADC client send queue. 2012-10-03 11:44:07 +02:00
Jan Vidar Krey
e95a892fb7 MSVC compile warnings fixed. 2012-10-02 22:47:43 +02:00
Jan Vidar Krey
62d14a9c52 Plugin compile fixes for windows systems. 2012-10-02 21:42:58 +02:00
Jan Vidar Krey
37e78eada1 Replaced the GNU makefiles with CMake. 2012-10-02 15:49:27 +02:00
Jan Vidar Krey
5b4467acd5 Minor stuff on the uhub-admin tool based on the changes in the ADC client code. 2012-09-28 15:52:39 +02:00
Jan Vidar Krey
ff2e2a3d4c Misc ADC client fixes. 2012-09-28 15:51:39 +02:00
Jan Vidar Krey
a599b29b9d Added more complete API for dealing with ADC messages.
- Added a construct method which would take a fourcc and a source.
- Added an unescape function that would write into pre-allocated memory.
2012-09-28 15:49:46 +02:00
Jan Vidar Krey
fc52f0e030 Renamed the hub_sendq and hub_recvq to ioq_send and ioq_recv. 2012-09-28 09:24:04 +02:00
Jan Vidar Krey
35bfefa717 Fix debug output typo. 2012-09-27 15:29:19 +02:00
Jan Vidar Krey
845aefc941 Decouple hub and user manager more cleanly. 2012-09-27 15:29:00 +02:00
Jan Vidar Krey
4fcf3ffc83 Add support for configuration options that depend on certain #ifdefs. 2012-09-27 15:28:46 +02:00
Blair Bonnett
3f777ce5e2 Fix msg_check_escapes() so it allows escaped backslashes.
If a valid escape (\n, \s, or \\) is found, increment the pointer
marking the start of the next search so we don't start looking at the
escaped character. The old behaviour was a problem for messages
containing slashes -- the escaped slash would be looked at in the next
pass and so the following character would be treated as an escape,
causing the message to be dropped for having "an invalid ADC escape".
2012-09-17 23:31:20 +12:00
Jan Vidar Krey
fb11589bb0 Drop all ADC messages containing illegal ADC escapes. 2012-08-07 11:55:29 +02:00
Jan Vidar Krey
cba0121574 ADCH++ had a security bug that allowed UCMD extension to be relayed.
uhub did not have this security bug since the hub did not advertise support for the
UCMD extension, but the message was still correctly relayed as specified in the
protocol specification.

However, this commit adds support for the UCMD extension, but only to the extent
that uhub will advertise it and uhub will also drop any such CMD message
generated by a client and will (currently) never issues a CMD message by itself.
2012-07-30 00:08:12 +02:00
Yorhel
b9005b1724 core/probe.c: Fix TLS probe when handshake version != SSL version
GnuTLS sends a handshake with SSL 3.0 (0x0300) in the outer packet, but
mentions TLS 1.2 (0x0303) in the Client Hello. There's no real need for
uhub to validate these fields, as OpenSSL should do that itself already.
Just use the version mentioned in Client Hello for logging output.
2012-06-02 14:46:47 +02:00
Jan Vidar Krey
571abddd98 Cleaned up code generator for config file parsing. 2012-05-23 23:37:42 +02:00
Jan Vidar Krey
3ae6da4a64 Print error message in case of shutting down due to errors loading plugins. 2012-05-14 23:35:53 +02:00
Jan Vidar Krey
f3754fb4e4 Fix Windows file read discrepancy. 2012-05-14 23:33:54 +02:00
Tilka
274f17bce0 use "I64u" instead of PRIu64 on Windows 2012-05-11 16:45:07 +02:00
Tilka
8365278cbf fix uhub_itoa() and uhub_ulltoa() 2012-05-10 23:24:42 +02:00
Tilka
eb49174ab3 marked plugin callbacks that are not called yet 2012-05-10 01:37:20 +02:00
Tilka
9e52ea7eff add on_change_nick() to struct plugin_funcs
It's not called anywhere yet.
Also reorder some typedefs, rename the ip check functions and add
struct {hub,plugin}_user parameter to on_check_ip_late(). Not sure where
to insert a call to that...
2012-05-09 23:33:03 +02:00