Sam Hocevar
e35403e112
Minor #ifdef cleanup.
2017-09-06 18:17:33 +02:00
Sam Hocevar
ff3974440e
Get rid of useless refuse() function.
2017-09-06 18:05:25 +02:00
Sam Hocevar
00dec123da
Use recvfrom() in UDP listening mode to get remote address.
...
Also move a few #ifdef from .c to .h to make the code slightly more readable.
2017-09-06 17:57:22 +02:00
Sam Hocevar
6909d2c3de
Move connection authorisation logic to a separate function.
2017-09-06 14:56:35 +02:00
Sam Hocevar
7b62e576cf
Reorganise some code for clarity and add license headers.
2017-09-05 17:29:10 +02:00
Sam Hocevar
a613195ad9
Do not call listen() on UDP listeners.
2017-09-05 17:28:04 +02:00
Sam Hocevar
33e8b8d7f9
Start playing around with UDP.
2017-09-05 17:27:16 +02:00
Sam Hocevar
718f4cddf7
Implement a new parser using a PEG grammar.
2017-09-04 20:14:11 +02:00
Sam Hocevar
982c14f46f
Properly handle FD_SET on Windows. Fixes #5 .
...
On Windows, select() ignores its first argument and instead relies on a
slightly different fd_set structure that can hold file descriptors with
arbitrary values. We use the Microsoft recommended way and just increase
FD_SETSIZE at compilation time.
2017-07-19 19:18:01 +02:00
Sam Hocevar
8feb3e0513
Fix a memory corruption in the configuration file parsing. Fixes : #11 .
2017-07-17 11:57:12 +02:00
Sam Hocevar
8b071acbe4
Fix a few issues in the Windows port.
2016-02-09 02:28:23 +01:00
Sam Hocevar
cb60037d58
Fix Windows cross-compilation.
...
Test with: ./configure --host=i686-w64-mingw32
2016-02-08 09:20:55 +01:00
Sam Hocevar
a259a67e2d
Fix a probably harmless uninitialised memory access.
2016-02-08 02:49:24 +01:00
Sam Hocevar
c92c0cf4bb
Stop passing server indices around.
...
Also fix a possible file descriptor leak when reloading configuration,
and ensure we no longer reference freed objects after reloading.
2016-02-08 02:36:23 +01:00
Sam Hocevar
53d670f9b1
Some cleaning up in includes and ifdefs.
2016-02-07 00:05:09 +01:00
Sam Hocevar
86cba0ad56
Remove patternBad() and inline its code in its only caller.
2016-02-06 23:35:43 +01:00
Sam Hocevar
65273124f3
Free all memory when quitting, and quit when SIGINT is received.
2016-02-06 18:40:02 +01:00
Sam Hocevar
830b7e5fd1
Allow to shrink the number of connections.
...
This will let us implement clean exit.
2016-02-06 18:31:50 +01:00
Sam Hocevar
f65f4d2506
Pedantic C fixes.
2016-02-06 18:23:50 +01:00
Sam Hocevar
f2d3ecd7f2
Reorganise log categories.
2016-02-06 18:14:14 +01:00
Sam Hocevar
d4c4c99ec7
Move a few declarations and definitions to rinetd.h.
2016-02-06 18:10:44 +01:00
Sam Hocevar
e365bf65f0
Increase buffer size to 16k instead of 1k.
2016-02-06 18:01:36 +01:00
Sam Hocevar
31f320a74d
Merge openLocalFd() into handleAccept().
...
Also move the connection search code out of this function.
2016-02-06 18:01:36 +01:00
Sam Hocevar
568b04acd6
Merge some similar functions.
2016-02-06 18:01:36 +01:00
Sam Hocevar
af28930cd7
Merge similar ConnectionInfo members into another struct.
2016-02-06 16:54:17 +01:00
Sam Hocevar
da1fbfbf4f
Make a few pointer types const.
2016-02-06 15:37:29 +01:00
Sam Hocevar
ad8874362c
Merge allow and deny rules in a single array.
...
We now just differentiate between them with an enum.
2016-02-06 15:34:53 +01:00
Sam Hocevar
e9f4d50051
Move some magic numbers and strings to constants.
2016-02-06 15:31:32 +01:00
Sam Hocevar
13d8d29093
Merge handleCloseFromLocal() and handleCloseFromRemote().
2016-02-06 14:58:31 +01:00
Sam Hocevar
bbf92c9e85
OS X compilation fixes in getAddress().
...
Also change the semantics for this function to return 0 on success.
2016-02-06 14:28:54 +01:00
Sam Hocevar
cefb09eddd
Use FD_SETSIZE instead of __FD_SETSIZE.
2016-02-06 14:23:02 +01:00
Sam Hocevar
cd1de600aa
Get rid of ConnectionInfo::coClosed.
...
What we actually care about is whether the socket file descriptors
are valid.
2016-02-06 14:20:21 +01:00
Sam Hocevar
990a368df0
Get rid of ConnectionInfo::loClosed.
2016-02-06 14:20:21 +01:00
Sam Hocevar
10935c8dc6
Get rid of ConnectionInfo::reClosed.
...
The variable ConnectionInfo::reFd already tells us whether the
connection is closed. This seems safer to me.
2016-02-06 14:20:20 +01:00
Sam Hocevar
4feb1ecd4f
Minor refactoring in getAddress().
2016-02-06 14:20:20 +01:00
Sam Hocevar
ed7fe3ce9d
Fix patternBad() behaviour.
...
This function was only ever checking the first character in the string.
2016-02-06 14:20:20 +01:00
Sam Hocevar
77548712d1
Fix a memory leak on configuration reload.
...
This old bug was apparently introduced in rinetd 0.52.
2016-02-06 14:20:20 +01:00
Sam Hocevar
6c385facd2
Various code improvements.
...
Remove useless if() statements, try to factor common code, use
NULL instead of 0 where it seems to make sense, fix indentation
in switch/case for readability.
2016-02-06 14:20:20 +01:00
Sam Hocevar
bf11a9a4b5
Do the configuration parsing in a single pass.
2016-02-06 14:20:20 +01:00
Sam Hocevar
b1d6ce5356
Fix a possible inconsistency in configuration reading.
...
The configuration is read in two passes (which we should stop doing one
day) and there was no check that we found the same number of forward rules
during each pass.
2016-02-03 18:54:33 +01:00
Sam Hocevar
bf40f07764
Declare a few variables closer to their actual use.
2016-02-03 18:37:19 +01:00
Sam Hocevar
b7c30a067e
Handle more than __FD_SETSIZE file descriptors. Fixes #1 .
2016-01-13 07:47:12 +01:00
Sam Hocevar
edeb1685d2
Improve connection reallocation code.
...
Merge allocation and reallocation as they’re pretty much the same
thing. Make the growing factor less aggressive. Remove a goto for
immediate good karma.
2016-01-13 06:36:14 +01:00
Sam Hocevar
64a9c56c36
Reduce allocation count for connection buffers.
2016-01-13 06:12:43 +01:00
Sam Hocevar
54cf9badb2
Group all signal handlers together.
2016-01-12 11:46:31 +01:00
Sam Hocevar
e69b28d9a0
Get rid of safeRealloc().
...
This function was only used in one place, had a memory leak, and is not
type-safe. It’s better to avoid it altogether.
2016-01-12 11:44:32 +01:00
Sam Hocevar
401a67b569
Fix error reporting for out-of-range port numbers.
...
This was found by simply adding -Wextra to the compilation flags.
2016-01-12 11:39:36 +01:00
Sam Hocevar
9ceb167e51
Try to declare more variable in a tighter scope.
...
This reduces the chances of a variable being reused by an unrelated
piece of code without proper initialisaion.
2016-01-12 11:36:42 +01:00
Sam Hocevar
15ed538dcc
Add indentation to preprocessor directives and remove macros.
2016-01-12 11:35:08 +01:00
Sam Hocevar
8890e03ae9
Use “srv” and “cnx” for servers and connections instead of “s” and “c”.
2016-01-12 02:54:28 +01:00