mirror of
https://github.com/samhocevar/rinetd.git
synced 2026-08-21 22:03:28 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f91e34c3af | ||
|
|
5e8be95d8a | ||
|
|
7887c17096 |
12
CHANGES.md
12
CHANGES.md
@@ -1,20 +1,24 @@
|
||||
## Version 0.71
|
||||
## Version 0.72 (2021/02/16)
|
||||
|
||||
* fixed a configuration parsing bug making 0.71 almost unusable
|
||||
|
||||
## Version 0.71 (2021/02/14)
|
||||
|
||||
* IPv6 support
|
||||
* fix a display overflow in data usage statistics
|
||||
* fixed a display overflow in data usage statistics
|
||||
* made the configuration parser more tolerant with service names that contain
|
||||
dashes (e.g. snmp-trap) or hostnames with underscores (e.g. \_http.example.com).
|
||||
* create the log file if it does not exist
|
||||
* new Visual Studio project file
|
||||
|
||||
## Version 0.70
|
||||
## Version 0.70 (2017/09/09)
|
||||
|
||||
* UDP support
|
||||
* source address binding support
|
||||
* use a real grammar for the configuration file and get rid of the hand-made
|
||||
parser
|
||||
|
||||
## Version 0.63
|
||||
## Version 0.63 (2017/07/19)
|
||||
|
||||
* added a `-f` flag to run in the foreground
|
||||
* quit cleanly when `SIGINT` is received
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.52)
|
||||
AC_INIT(rinetd, 0.71, sam@hocevar.net)
|
||||
AC_INIT(rinetd, 0.72, sam@hocevar.net)
|
||||
AC_CONFIG_AUX_DIR(.auto)
|
||||
AC_CONFIG_SRCDIR([src/rinetd.c])
|
||||
AC_CONFIG_HEADER([src/config.h])
|
||||
|
||||
2
rinetd.8
2
rinetd.8
@@ -1,4 +1,4 @@
|
||||
.TH rinetd 8 "2021-02-14" "rinetd 0.71"
|
||||
.TH rinetd 8 "2021-02-12" "rinetd 0.72"
|
||||
|
||||
.SH NAME
|
||||
rinetd \- internet redirection server
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PreprocessorDefinitions>_CONSOLE;PACKAGE_VERSION="0.71";_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CONSOLE;PACKAGE_VERSION="0.72";_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
||||
@@ -15,9 +15,10 @@ parse.c: parse.peg
|
||||
if which leg >/dev/null 2>&1; then leg -o $@ $^; else touch $@; fi
|
||||
|
||||
# _POSIX_C_SOURCE is for SA_RESTART and others
|
||||
# _DARWIN_C_SOURCE is for NI_MAXHOST on OS X
|
||||
# _XOPEN_SOURCE is for struct sigaction
|
||||
# _GNU_SOURCE is for h_errno and gethostbyname-related macros
|
||||
___rinetd_CFLAGS = -std=c99 \
|
||||
-D_XOPEN_SOURCE -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L \
|
||||
___rinetd_CFLAGS = -std=c99 -D_POSIX_C_SOURCE=200809L \
|
||||
-D_XOPEN_SOURCE -D_GNU_SOURCE -D_DARWIN_C_SOURCE \
|
||||
-Wall -Wextra -Wwrite-strings
|
||||
|
||||
|
||||
50
src/parse.c
50
src/parse.c
@@ -356,7 +356,7 @@ YY_ACTION(void) yy_1_sol(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_sol\n"));
|
||||
{
|
||||
#line 152
|
||||
#line 156
|
||||
++yy->currentLine; ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -370,7 +370,7 @@ YY_ACTION(void) yy_1_invalid_syntax(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_invalid_syntax\n"));
|
||||
{
|
||||
#line 127
|
||||
#line 131
|
||||
|
||||
fprintf(stderr, "rinetd: invalid syntax at line %d: %s\n",
|
||||
yy->currentLine, yytext);
|
||||
@@ -388,7 +388,7 @@ YY_ACTION(void) yy_1_logcommon(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_logcommon\n"));
|
||||
{
|
||||
#line 122
|
||||
#line 126
|
||||
|
||||
logFormatCommon = 1;
|
||||
;
|
||||
@@ -404,7 +404,7 @@ YY_ACTION(void) yy_1_pidlogfile(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_pidlogfile\n"));
|
||||
{
|
||||
#line 114
|
||||
#line 118
|
||||
|
||||
pidLogFileName = strdup(yytext);
|
||||
if (!pidLogFileName) {
|
||||
@@ -423,7 +423,7 @@ YY_ACTION(void) yy_1_logfile(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_logfile\n"));
|
||||
{
|
||||
#line 106
|
||||
#line 110
|
||||
|
||||
logFileName = strdup(yytext);
|
||||
if (!logFileName) {
|
||||
@@ -442,7 +442,7 @@ YY_ACTION(void) yy_1_auth_key(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_auth_key\n"));
|
||||
{
|
||||
#line 103
|
||||
#line 107
|
||||
yy->isAuthAllow = (yytext[0] == 'a'); ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -456,7 +456,7 @@ YY_ACTION(void) yy_1_auth_rule(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_auth_rule\n"));
|
||||
{
|
||||
#line 81
|
||||
#line 85
|
||||
|
||||
allRules = (Rule *)
|
||||
realloc(allRules, sizeof(Rule) * (allRulesCount + 1));
|
||||
@@ -490,7 +490,7 @@ YY_ACTION(void) yy_3_proto(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_3_proto\n"));
|
||||
{
|
||||
#line 78
|
||||
#line 82
|
||||
yy->tmpProto = IPPROTO_TCP; ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -504,7 +504,7 @@ YY_ACTION(void) yy_2_proto(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_2_proto\n"));
|
||||
{
|
||||
#line 77
|
||||
#line 81
|
||||
yy->tmpProto = IPPROTO_UDP; ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -518,7 +518,7 @@ YY_ACTION(void) yy_1_proto(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_proto\n"));
|
||||
{
|
||||
#line 76
|
||||
#line 80
|
||||
yy->tmpProto = IPPROTO_TCP; ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -532,9 +532,8 @@ YY_ACTION(void) yy_1_port(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_port\n"));
|
||||
{
|
||||
#line 74
|
||||
free(yy->tmpPort);
|
||||
yy->tmpPort = strdup(yytext); ;
|
||||
#line 79
|
||||
yy->tmpPort = strdup(yytext); ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
@@ -547,9 +546,8 @@ YY_ACTION(void) yy_1_option_source(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_option_source\n"));
|
||||
{
|
||||
#line 69
|
||||
free(yy->sourceAddress);
|
||||
yy->sourceAddress = strdup(yytext); ;
|
||||
#line 75
|
||||
yy->sourceAddress = strdup(yytext); ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
@@ -562,7 +560,7 @@ YY_ACTION(void) yy_1_option_timeout(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_option_timeout\n"));
|
||||
{
|
||||
#line 68
|
||||
#line 74
|
||||
yy->serverTimeout = atoi(yytext); ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -576,7 +574,7 @@ YY_ACTION(void) yy_1_connect_port(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_connect_port\n"));
|
||||
{
|
||||
#line 63
|
||||
#line 69
|
||||
yy->connectPort = yy->tmpPort; yy->connectProto = yy->tmpProto; ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -590,7 +588,7 @@ YY_ACTION(void) yy_1_bind_port(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_bind_port\n"));
|
||||
{
|
||||
#line 62
|
||||
#line 68
|
||||
yy->bindPort = yy->tmpPort; yy->bindProto = yy->tmpProto; ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -604,7 +602,7 @@ YY_ACTION(void) yy_1_connect_address(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_connect_address\n"));
|
||||
{
|
||||
#line 61
|
||||
#line 67
|
||||
yy->connectAddress = strdup(yytext); ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -618,7 +616,7 @@ YY_ACTION(void) yy_1_bind_address(yycontext *yy, char *yytext, int yyleng)
|
||||
#define yythunkpos yy->__thunkpos
|
||||
yyprintf((stderr, "do yy_1_bind_address\n"));
|
||||
{
|
||||
#line 60
|
||||
#line 66
|
||||
yy->bindAddress = strdup(yytext); ;
|
||||
}
|
||||
#undef yythunkpos
|
||||
@@ -638,7 +636,13 @@ YY_ACTION(void) yy_1_server_rule(yycontext *yy, char *yytext, int yyleng)
|
||||
yy->connectAddress, yy->connectPort, yy->connectProto,
|
||||
yy->serverTimeout > 0 ? yy->serverTimeout : RINETD_DEFAULT_UDP_TIMEOUT,
|
||||
yy->sourceAddress);
|
||||
free(yy->bindAddress);
|
||||
free(yy->connectAddress);
|
||||
free(yy->sourceAddress);
|
||||
yy->bindAddress = yy->connectAddress = yy->sourceAddress = NULL;
|
||||
free(yy->bindPort);
|
||||
free(yy->connectPort);
|
||||
yy->bindPort = yy->connectPort = NULL;
|
||||
yy->serverTimeout = 0;
|
||||
;
|
||||
}
|
||||
@@ -1396,7 +1400,7 @@ YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx)
|
||||
}
|
||||
|
||||
#endif
|
||||
#line 156 "parse.peg"
|
||||
#line 160 "parse.peg"
|
||||
|
||||
|
||||
void parseConfiguration(char const *file)
|
||||
@@ -1414,8 +1418,6 @@ void parseConfiguration(char const *file)
|
||||
"on file %s, line %d.\n", file, -1);
|
||||
exit(1);
|
||||
}
|
||||
free(ctx.sourceAddress);
|
||||
free(ctx.tmpPort);
|
||||
yyrelease(&ctx);
|
||||
|
||||
fclose(in);
|
||||
|
||||
@@ -53,7 +53,13 @@ server-rule = bind-address - bind-port - connect-address - connect-port (-? se
|
||||
yy->connectAddress, yy->connectPort, yy->connectProto,
|
||||
yy->serverTimeout > 0 ? yy->serverTimeout : RINETD_DEFAULT_UDP_TIMEOUT,
|
||||
yy->sourceAddress);
|
||||
free(yy->bindAddress);
|
||||
free(yy->connectAddress);
|
||||
free(yy->sourceAddress);
|
||||
yy->bindAddress = yy->connectAddress = yy->sourceAddress = NULL;
|
||||
free(yy->bindPort);
|
||||
free(yy->connectPort);
|
||||
yy->bindPort = yy->connectPort = NULL;
|
||||
yy->serverTimeout = 0;
|
||||
}
|
||||
|
||||
@@ -66,13 +72,11 @@ server-options = "[" -? option-list -? "]"
|
||||
option-list = option (-? ',' -? option-list)?
|
||||
option = (option-timeout | option-source)
|
||||
option-timeout = "timeout" -? "=" -? < number > { yy->serverTimeout = atoi(yytext); }
|
||||
option-source = "src" -? "=" -? < address > { free(yy->sourceAddress);
|
||||
yy->sourceAddress = strdup(yytext); }
|
||||
option-source = "src" -? "=" -? < address > { yy->sourceAddress = strdup(yytext); }
|
||||
|
||||
full-port = port proto
|
||||
|
||||
port = < (number | service) > { free(yy->tmpPort);
|
||||
yy->tmpPort = strdup(yytext); }
|
||||
port = < (number | service) > { yy->tmpPort = strdup(yytext); }
|
||||
proto = '/tcp' { yy->tmpProto = IPPROTO_TCP; }
|
||||
| '/udp' { yy->tmpProto = IPPROTO_UDP; }
|
||||
| '' { yy->tmpProto = IPPROTO_TCP; }
|
||||
@@ -170,8 +174,6 @@ void parseConfiguration(char const *file)
|
||||
"on file %s, line %d.\n", file, -1);
|
||||
exit(1);
|
||||
}
|
||||
free(ctx.sourceAddress);
|
||||
free(ctx.tmpPort);
|
||||
yyrelease(&ctx);
|
||||
|
||||
fclose(in);
|
||||
|
||||
@@ -261,8 +261,8 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol,
|
||||
int serverTimeout, char *sourceAddress)
|
||||
{
|
||||
ServerInfo si = {
|
||||
.fromHost = bindAddress,
|
||||
.toHost = connectAddress,
|
||||
.fromHost = strdup(bindAddress),
|
||||
.toHost = strdup(connectAddress),
|
||||
.serverTimeout = serverTimeout,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user