From 4f64342ed5c39ce3ad01d90d3ce29e2f413ebc0c Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 13 Feb 2021 21:37:11 +0100 Subject: [PATCH] Allow listening on IPv6 addresses. --- src/parse.c | 540 ++++++++++++++++++++++++++------------------------ src/parse.peg | 8 +- src/rinetd.c | 148 +++++++------- src/rinetd.h | 4 +- 4 files changed, 363 insertions(+), 337 deletions(-) diff --git a/src/parse.c b/src/parse.c index c1d5343..40964a4 100644 --- a/src/parse.c +++ b/src/parse.c @@ -3,7 +3,7 @@ #include #include #include -#define YYRULECOUNT 39 +#define YYRULECOUNT 40 #line 9 "parse.peg" #if HAVE_CONFIG_H @@ -22,10 +22,10 @@ int isAuthAllow; \ char *tmpPort; \ uint16_t tmpPortNum, tmpProto; \ - uint16_t bindPortNum, connectPortNum; \ + uint16_t connectPortNum; \ int bindProto, connectProto; \ int serverTimeout; \ - char *bindAddress, *connectAddress, *sourceAddress; + char *bindAddress, *bindPort, *connectAddress, *sourceAddress; #define YY_INPUT(yyctx, buf, result, max_size) \ { \ int yyc = fgetc(yyctx->fp); \ @@ -310,7 +310,8 @@ YY_LOCAL(void) yySet(yycontext *yy, char *text, int count) { yy->__val[count]= #define YYACCEPT yyAccept(yy, yythunkpos0) -YY_RULE(int) yy_eof(yycontext *yy); /* 39 */ +YY_RULE(int) yy_eof(yycontext *yy); /* 40 */ +YY_RULE(int) yy_id(yycontext *yy); /* 39 */ YY_RULE(int) yy_label(yycontext *yy); /* 38 */ YY_RULE(int) yy_hexdigit(yycontext *yy); /* 37 */ YY_RULE(int) yy_digit(yycontext *yy); /* 36 */ @@ -357,7 +358,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 161 +#line 162 ++yy->currentLine; ; } #undef yythunkpos @@ -613,7 +614,7 @@ YY_ACTION(void) yy_1_bind_port(yycontext *yy, char *yytext, int yyleng) yyprintf((stderr, "do yy_1_bind_port\n")); { #line 64 - yy->bindPortNum = yy->tmpPortNum; yy->bindProto = yy->tmpProto; ; + yy->bindPort = yy->tmpPort; yy->bindProto = yy->tmpProto; ; } #undef yythunkpos #undef yypos @@ -656,7 +657,7 @@ YY_ACTION(void) yy_1_server_rule(yycontext *yy, char *yytext, int yyleng) { #line 53 - addServer(yy->bindAddress, yy->bindPortNum, yy->bindProto, + addServer(yy->bindAddress, yy->bindPort, yy->bindProto, yy->connectAddress, yy->connectPortNum, yy->connectProto, yy->serverTimeout > 0 ? yy->serverTimeout : RINETD_DEFAULT_UDP_TIMEOUT, yy->sourceAddress); @@ -678,160 +679,183 @@ YY_RULE(int) yy_eof(yycontext *yy) yyprintf((stderr, " fail %s @ %s\n", "eof", yy->__buf+yy->__pos)); return 0; } +YY_RULE(int) yy_id(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "id")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l2; + yyprintf((stderr, " ok %s @ %s\n", "id", yy->__buf+yy->__pos)); + return 1; + l2:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "id", yy->__buf+yy->__pos)); + return 0; +} YY_RULE(int) yy_label(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "label")); - l3:; - { int yypos4= yy->__pos, yythunkpos4= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l4; goto l3; - l4:; yy->__pos= yypos4; yy->__thunkpos= yythunkpos4; - } if (!yy_name(yy)) goto l2; + { int yypos4= yy->__pos, yythunkpos4= yy->__thunkpos; if (!yy_id(yy)) goto l5; goto l4; + l5:; yy->__pos= yypos4; yy->__thunkpos= yythunkpos4; if (!yy_digit(yy)) goto l3; + } + l4:; + l6:; + { int yypos7= yy->__pos, yythunkpos7= yy->__thunkpos; + { int yypos8= yy->__pos, yythunkpos8= yy->__thunkpos; if (!yymatchChar(yy, '-')) goto l9; goto l8; + l9:; yy->__pos= yypos8; yy->__thunkpos= yythunkpos8; if (!yy_id(yy)) goto l10; goto l8; + l10:; yy->__pos= yypos8; yy->__thunkpos= yythunkpos8; if (!yy_digit(yy)) goto l7; + } + l8:; goto l6; + l7:; yy->__pos= yypos7; yy->__thunkpos= yythunkpos7; + } yyprintf((stderr, " ok %s @ %s\n", "label", yy->__buf+yy->__pos)); return 1; - l2:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l3:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "label", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_hexdigit(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "hexdigit")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l5; + yyprintf((stderr, "%s\n", "hexdigit")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l11; yyprintf((stderr, " ok %s @ %s\n", "hexdigit", yy->__buf+yy->__pos)); return 1; - l5:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l11:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "hexdigit", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_digit(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "digit")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l6; + yyprintf((stderr, "%s\n", "digit")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l12; yyprintf((stderr, " ok %s @ %s\n", "digit", yy->__buf+yy->__pos)); return 1; - l6:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l12:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "digit", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_hostname(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "hostname")); - l8:; - { int yypos9= yy->__pos, yythunkpos9= yy->__thunkpos; if (!yy_label(yy)) goto l9; if (!yymatchChar(yy, '.')) goto l9; goto l8; - l9:; yy->__pos= yypos9; yy->__thunkpos= yythunkpos9; - } if (!yy_name(yy)) goto l7; - { int yypos10= yy->__pos, yythunkpos10= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l10; goto l11; - l10:; yy->__pos= yypos10; yy->__thunkpos= yythunkpos10; + l14:; + { int yypos15= yy->__pos, yythunkpos15= yy->__thunkpos; if (!yy_label(yy)) goto l15; if (!yymatchChar(yy, '.')) goto l15; goto l14; + l15:; yy->__pos= yypos15; yy->__thunkpos= yythunkpos15; + } if (!yy_name(yy)) goto l13; + { int yypos16= yy->__pos, yythunkpos16= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l16; goto l17; + l16:; yy->__pos= yypos16; yy->__thunkpos= yythunkpos16; } - l11:; + l17:; yyprintf((stderr, " ok %s @ %s\n", "hostname", yy->__buf+yy->__pos)); return 1; - l7:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l13:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "hostname", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_ipv6(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "ipv6")); - { int yypos13= yy->__pos, yythunkpos13= yy->__thunkpos; - { int yypos17= yy->__pos, yythunkpos17= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l18; goto l17; - l18:; yy->__pos= yypos17; yy->__thunkpos= yythunkpos17; if (!yymatchChar(yy, ':')) goto l14; + { int yypos19= yy->__pos, yythunkpos19= yy->__thunkpos; + { int yypos23= yy->__pos, yythunkpos23= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l24; goto l23; + l24:; yy->__pos= yypos23; yy->__thunkpos= yythunkpos23; if (!yymatchChar(yy, ':')) goto l20; } - l17:; - l15:; - { int yypos16= yy->__pos, yythunkpos16= yy->__thunkpos; - { int yypos19= yy->__pos, yythunkpos19= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l20; goto l19; - l20:; yy->__pos= yypos19; yy->__thunkpos= yythunkpos19; if (!yymatchChar(yy, ':')) goto l16; + l23:; + l21:; + { int yypos22= yy->__pos, yythunkpos22= yy->__thunkpos; + { int yypos25= yy->__pos, yythunkpos25= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l26; goto l25; + l26:; yy->__pos= yypos25; yy->__thunkpos= yythunkpos25; if (!yymatchChar(yy, ':')) goto l22; } - l19:; goto l15; - l16:; yy->__pos= yypos16; yy->__thunkpos= yythunkpos16; - } goto l13; - l14:; yy->__pos= yypos13; yy->__thunkpos= yythunkpos13; if (!yymatchChar(yy, '[')) goto l12; if (!yy_ipv6(yy)) goto l12; if (!yymatchChar(yy, ']')) goto l12; + l25:; goto l21; + l22:; yy->__pos= yypos22; yy->__thunkpos= yythunkpos22; + } goto l19; + l20:; yy->__pos= yypos19; yy->__thunkpos= yythunkpos19; if (!yymatchChar(yy, '[')) goto l18; if (!yy_ipv6(yy)) goto l18; if (!yymatchChar(yy, ']')) goto l18; } - l13:; + l19:; yyprintf((stderr, " ok %s @ %s\n", "ipv6", yy->__buf+yy->__pos)); return 1; - l12:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l18:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "ipv6", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_ipv4(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "ipv4")); - { int yypos22= yy->__pos, yythunkpos22= yy->__thunkpos; if (!yy_number(yy)) goto l23; if (!yymatchChar(yy, '.')) goto l23; if (!yy_number(yy)) goto l23; if (!yymatchChar(yy, '.')) goto l23; if (!yy_number(yy)) goto l23; if (!yymatchChar(yy, '.')) goto l23; if (!yy_number(yy)) goto l23; goto l22; - l23:; yy->__pos= yypos22; yy->__thunkpos= yythunkpos22; if (!yymatchChar(yy, '0')) goto l21; + { int yypos28= yy->__pos, yythunkpos28= yy->__thunkpos; if (!yy_number(yy)) goto l29; if (!yymatchChar(yy, '.')) goto l29; if (!yy_number(yy)) goto l29; if (!yymatchChar(yy, '.')) goto l29; if (!yy_number(yy)) goto l29; if (!yymatchChar(yy, '.')) goto l29; if (!yy_number(yy)) goto l29; goto l28; + l29:; yy->__pos= yypos28; yy->__thunkpos= yythunkpos28; if (!yymatchChar(yy, '0')) goto l27; } - l22:; + l28:; yyprintf((stderr, " ok %s @ %s\n", "ipv4", yy->__buf+yy->__pos)); return 1; - l21:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l27:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "ipv4", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_name(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "name")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l24; - l25:; - { int yypos26= yy->__pos, yythunkpos26= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; goto l25; - l26:; yy->__pos= yypos26; yy->__thunkpos= yythunkpos26; + yyprintf((stderr, "%s\n", "name")); if (!yy_id(yy)) goto l30; + l31:; + { int yypos32= yy->__pos, yythunkpos32= yy->__thunkpos; + { int yypos33= yy->__pos, yythunkpos33= yy->__thunkpos; if (!yymatchChar(yy, '-')) goto l34; goto l33; + l34:; yy->__pos= yypos33; yy->__thunkpos= yythunkpos33; if (!yy_id(yy)) goto l35; goto l33; + l35:; yy->__pos= yypos33; yy->__thunkpos= yythunkpos33; if (!yy_digit(yy)) goto l32; + } + l33:; goto l31; + l32:; yy->__pos= yypos32; yy->__thunkpos= yythunkpos32; } yyprintf((stderr, " ok %s @ %s\n", "name", yy->__buf+yy->__pos)); return 1; - l24:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l30:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "name", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_filename(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "filename")); - { int yypos28= yy->__pos, yythunkpos28= yy->__thunkpos; if (!yymatchChar(yy, '"')) goto l29; if (!yymatchClass(yy, (unsigned char *)"\377\377\377\377\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l29; - l30:; - { int yypos31= yy->__pos, yythunkpos31= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\377\377\377\377\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l31; goto l30; - l31:; yy->__pos= yypos31; yy->__thunkpos= yythunkpos31; - } if (!yymatchChar(yy, '"')) goto l29; goto l28; - l29:; yy->__pos= yypos28; yy->__thunkpos= yythunkpos28; if (!yymatchClass(yy, (unsigned char *)"\377\331\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l27; - l32:; - { int yypos33= yy->__pos, yythunkpos33= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\377\331\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l33; goto l32; - l33:; yy->__pos= yypos33; yy->__thunkpos= yythunkpos33; + { int yypos37= yy->__pos, yythunkpos37= yy->__thunkpos; if (!yymatchChar(yy, '"')) goto l38; if (!yymatchClass(yy, (unsigned char *)"\377\377\377\377\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l38; + l39:; + { int yypos40= yy->__pos, yythunkpos40= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\377\377\377\377\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l40; goto l39; + l40:; yy->__pos= yypos40; yy->__thunkpos= yythunkpos40; + } if (!yymatchChar(yy, '"')) goto l38; goto l37; + l38:; yy->__pos= yypos37; yy->__thunkpos= yythunkpos37; if (!yymatchClass(yy, (unsigned char *)"\377\331\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l36; + l41:; + { int yypos42= yy->__pos, yythunkpos42= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\377\331\377\377\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l42; goto l41; + l42:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; } } - l28:; + l37:; yyprintf((stderr, " ok %s @ %s\n", "filename", yy->__buf+yy->__pos)); return 1; - l27:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l36:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "filename", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_pattern(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "pattern")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l34; - l35:; - { int yypos36= yy->__pos, yythunkpos36= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l36; goto l35; - l36:; yy->__pos= yypos36; yy->__thunkpos= yythunkpos36; - } - { int yypos37= yy->__pos, yythunkpos37= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l37; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; - l39:; - { int yypos40= yy->__pos, yythunkpos40= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l40; goto l39; - l40:; yy->__pos= yypos40; yy->__thunkpos= yythunkpos40; - } - { int yypos41= yy->__pos, yythunkpos41= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l41; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l41; - l43:; - { int yypos44= yy->__pos, yythunkpos44= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l44; goto l43; - l44:; yy->__pos= yypos44; yy->__thunkpos= yythunkpos44; - } - { int yypos45= yy->__pos, yythunkpos45= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l45; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l45; - l47:; - { int yypos48= yy->__pos, yythunkpos48= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l48; goto l47; - l48:; yy->__pos= yypos48; yy->__thunkpos= yythunkpos48; - } goto l46; + yyprintf((stderr, "%s\n", "pattern")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l43; + l44:; + { int yypos45= yy->__pos, yythunkpos45= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l45; goto l44; l45:; yy->__pos= yypos45; yy->__thunkpos= yythunkpos45; } - l46:; goto l42; - l41:; yy->__pos= yypos41; yy->__thunkpos= yythunkpos41; + { int yypos46= yy->__pos, yythunkpos46= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l46; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l46; + l48:; + { int yypos49= yy->__pos, yythunkpos49= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l49; goto l48; + l49:; yy->__pos= yypos49; yy->__thunkpos= yythunkpos49; } - l42:; goto l38; - l37:; yy->__pos= yypos37; yy->__thunkpos= yythunkpos37; + { int yypos50= yy->__pos, yythunkpos50= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l50; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l50; + l52:; + { int yypos53= yy->__pos, yythunkpos53= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l53; goto l52; + l53:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; } - l38:; + { int yypos54= yy->__pos, yythunkpos54= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l54; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l54; + l56:; + { int yypos57= yy->__pos, yythunkpos57= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\377\203\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l57; goto l56; + l57:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; + } goto l55; + l54:; yy->__pos= yypos54; yy->__thunkpos= yythunkpos54; + } + l55:; goto l51; + l50:; yy->__pos= yypos50; yy->__thunkpos= yythunkpos50; + } + l51:; goto l47; + l46:; yy->__pos= yypos46; yy->__thunkpos= yythunkpos46; + } + l47:; yyprintf((stderr, " ok %s @ %s\n", "pattern", yy->__buf+yy->__pos)); return 1; - l34:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l43:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "pattern", yy->__buf+yy->__pos)); return 0; } @@ -840,46 +864,46 @@ YY_RULE(int) yy_auth_key(yycontext *yy) yyprintf((stderr, "%s\n", "auth_key")); yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l49; +if (!(YY_BEGIN)) goto l58; #undef yytext #undef yyleng } - { int yypos50= yy->__pos, yythunkpos50= yy->__thunkpos; if (!yymatchString(yy, "allow")) goto l51; goto l50; - l51:; yy->__pos= yypos50; yy->__thunkpos= yythunkpos50; if (!yymatchString(yy, "deny")) goto l49; + { int yypos59= yy->__pos, yythunkpos59= yy->__thunkpos; if (!yymatchString(yy, "allow")) goto l60; goto l59; + l60:; yy->__pos= yypos59; yy->__thunkpos= yythunkpos59; if (!yymatchString(yy, "deny")) goto l58; } - l50:; yyText(yy, yy->__begin, yy->__end); { + l59:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l49; +if (!(YY_END)) goto l58; #undef yytext #undef yyleng } yyDo(yy, yy_1_auth_key, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "auth_key", yy->__buf+yy->__pos)); return 1; - l49:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l58:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "auth_key", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_service(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "service")); if (!yy_name(yy)) goto l52; + yyprintf((stderr, "%s\n", "service")); if (!yy_name(yy)) goto l61; yyprintf((stderr, " ok %s @ %s\n", "service", yy->__buf+yy->__pos)); return 1; - l52:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l61:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "service", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_proto(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "proto")); - { int yypos54= yy->__pos, yythunkpos54= yy->__thunkpos; if (!yymatchString(yy, "/tcp")) goto l55; yyDo(yy, yy_1_proto, yy->__begin, yy->__end); goto l54; - l55:; yy->__pos= yypos54; yy->__thunkpos= yythunkpos54; if (!yymatchString(yy, "/udp")) goto l56; yyDo(yy, yy_2_proto, yy->__begin, yy->__end); goto l54; - l56:; yy->__pos= yypos54; yy->__thunkpos= yythunkpos54; if (!yymatchString(yy, "")) goto l53; yyDo(yy, yy_3_proto, yy->__begin, yy->__end); + { int yypos63= yy->__pos, yythunkpos63= yy->__thunkpos; if (!yymatchString(yy, "/tcp")) goto l64; yyDo(yy, yy_1_proto, yy->__begin, yy->__end); goto l63; + l64:; yy->__pos= yypos63; yy->__thunkpos= yythunkpos63; if (!yymatchString(yy, "/udp")) goto l65; yyDo(yy, yy_2_proto, yy->__begin, yy->__end); goto l63; + l65:; yy->__pos= yypos63; yy->__thunkpos= yythunkpos63; if (!yymatchString(yy, "")) goto l62; yyDo(yy, yy_3_proto, yy->__begin, yy->__end); } - l54:; + l63:; yyprintf((stderr, " ok %s @ %s\n", "proto", yy->__buf+yy->__pos)); return 1; - l53:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l62:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "proto", yy->__buf+yy->__pos)); return 0; } @@ -888,177 +912,177 @@ YY_RULE(int) yy_port(yycontext *yy) yyprintf((stderr, "%s\n", "port")); yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l57; +if (!(YY_BEGIN)) goto l66; #undef yytext #undef yyleng } - { int yypos58= yy->__pos, yythunkpos58= yy->__thunkpos; if (!yy_number(yy)) goto l59; goto l58; - l59:; yy->__pos= yypos58; yy->__thunkpos= yythunkpos58; if (!yy_service(yy)) goto l57; + { int yypos67= yy->__pos, yythunkpos67= yy->__thunkpos; if (!yy_number(yy)) goto l68; goto l67; + l68:; yy->__pos= yypos67; yy->__thunkpos= yythunkpos67; if (!yy_service(yy)) goto l66; } - l58:; yyText(yy, yy->__begin, yy->__end); { + l67:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l57; +if (!(YY_END)) goto l66; #undef yytext #undef yyleng } yyDo(yy, yy_1_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "port", yy->__buf+yy->__pos)); return 1; - l57:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l66:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "port", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_number(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "number")); if (!yy_digit(yy)) goto l60; - l61:; - { int yypos62= yy->__pos, yythunkpos62= yy->__thunkpos; if (!yy_digit(yy)) goto l62; goto l61; - l62:; yy->__pos= yypos62; yy->__thunkpos= yythunkpos62; + yyprintf((stderr, "%s\n", "number")); if (!yy_digit(yy)) goto l69; + l70:; + { int yypos71= yy->__pos, yythunkpos71= yy->__thunkpos; if (!yy_digit(yy)) goto l71; goto l70; + l71:; yy->__pos= yypos71; yy->__thunkpos= yythunkpos71; } yyprintf((stderr, " ok %s @ %s\n", "number", yy->__buf+yy->__pos)); return 1; - l60:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l69:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "number", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_option_source(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "option_source")); if (!yymatchString(yy, "src")) goto l63; - { int yypos64= yy->__pos, yythunkpos64= yy->__thunkpos; if (!yy__(yy)) goto l64; goto l65; - l64:; yy->__pos= yypos64; yy->__thunkpos= yythunkpos64; + yyprintf((stderr, "%s\n", "option_source")); if (!yymatchString(yy, "src")) goto l72; + { int yypos73= yy->__pos, yythunkpos73= yy->__thunkpos; if (!yy__(yy)) goto l73; goto l74; + l73:; yy->__pos= yypos73; yy->__thunkpos= yythunkpos73; } - l65:; if (!yymatchChar(yy, '=')) goto l63; - { int yypos66= yy->__pos, yythunkpos66= yy->__thunkpos; if (!yy__(yy)) goto l66; goto l67; - l66:; yy->__pos= yypos66; yy->__thunkpos= yythunkpos66; + l74:; if (!yymatchChar(yy, '=')) goto l72; + { int yypos75= yy->__pos, yythunkpos75= yy->__thunkpos; if (!yy__(yy)) goto l75; goto l76; + l75:; yy->__pos= yypos75; yy->__thunkpos= yythunkpos75; } - l67:; yyText(yy, yy->__begin, yy->__end); { + l76:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l63; +if (!(YY_BEGIN)) goto l72; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l63; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l72; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l63; +if (!(YY_END)) goto l72; #undef yytext #undef yyleng } yyDo(yy, yy_1_option_source, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "option_source", yy->__buf+yy->__pos)); return 1; - l63:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l72:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "option_source", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_option_timeout(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "option_timeout")); if (!yymatchString(yy, "timeout")) goto l68; - { int yypos69= yy->__pos, yythunkpos69= yy->__thunkpos; if (!yy__(yy)) goto l69; goto l70; - l69:; yy->__pos= yypos69; yy->__thunkpos= yythunkpos69; + yyprintf((stderr, "%s\n", "option_timeout")); if (!yymatchString(yy, "timeout")) goto l77; + { int yypos78= yy->__pos, yythunkpos78= yy->__thunkpos; if (!yy__(yy)) goto l78; goto l79; + l78:; yy->__pos= yypos78; yy->__thunkpos= yythunkpos78; } - l70:; if (!yymatchChar(yy, '=')) goto l68; - { int yypos71= yy->__pos, yythunkpos71= yy->__thunkpos; if (!yy__(yy)) goto l71; goto l72; - l71:; yy->__pos= yypos71; yy->__thunkpos= yythunkpos71; + l79:; if (!yymatchChar(yy, '=')) goto l77; + { int yypos80= yy->__pos, yythunkpos80= yy->__thunkpos; if (!yy__(yy)) goto l80; goto l81; + l80:; yy->__pos= yypos80; yy->__thunkpos= yythunkpos80; } - l72:; yyText(yy, yy->__begin, yy->__end); { + l81:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l68; +if (!(YY_BEGIN)) goto l77; #undef yytext #undef yyleng - } if (!yy_number(yy)) goto l68; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_number(yy)) goto l77; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l68; +if (!(YY_END)) goto l77; #undef yytext #undef yyleng } yyDo(yy, yy_1_option_timeout, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "option_timeout", yy->__buf+yy->__pos)); return 1; - l68:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l77:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "option_timeout", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_option(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "option")); - { int yypos74= yy->__pos, yythunkpos74= yy->__thunkpos; if (!yy_option_timeout(yy)) goto l75; goto l74; - l75:; yy->__pos= yypos74; yy->__thunkpos= yythunkpos74; if (!yy_option_source(yy)) goto l73; + { int yypos83= yy->__pos, yythunkpos83= yy->__thunkpos; if (!yy_option_timeout(yy)) goto l84; goto l83; + l84:; yy->__pos= yypos83; yy->__thunkpos= yythunkpos83; if (!yy_option_source(yy)) goto l82; } - l74:; + l83:; yyprintf((stderr, " ok %s @ %s\n", "option", yy->__buf+yy->__pos)); return 1; - l73:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l82:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "option", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_option_list(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "option_list")); if (!yy_option(yy)) goto l76; - { int yypos77= yy->__pos, yythunkpos77= yy->__thunkpos; - { int yypos79= yy->__pos, yythunkpos79= yy->__thunkpos; if (!yy__(yy)) goto l79; goto l80; - l79:; yy->__pos= yypos79; yy->__thunkpos= yythunkpos79; + yyprintf((stderr, "%s\n", "option_list")); if (!yy_option(yy)) goto l85; + { int yypos86= yy->__pos, yythunkpos86= yy->__thunkpos; + { int yypos88= yy->__pos, yythunkpos88= yy->__thunkpos; if (!yy__(yy)) goto l88; goto l89; + l88:; yy->__pos= yypos88; yy->__thunkpos= yythunkpos88; } - l80:; if (!yymatchChar(yy, ',')) goto l77; - { int yypos81= yy->__pos, yythunkpos81= yy->__thunkpos; if (!yy__(yy)) goto l81; goto l82; - l81:; yy->__pos= yypos81; yy->__thunkpos= yythunkpos81; + l89:; if (!yymatchChar(yy, ',')) goto l86; + { int yypos90= yy->__pos, yythunkpos90= yy->__thunkpos; if (!yy__(yy)) goto l90; goto l91; + l90:; yy->__pos= yypos90; yy->__thunkpos= yythunkpos90; } - l82:; if (!yy_option_list(yy)) goto l77; goto l78; - l77:; yy->__pos= yypos77; yy->__thunkpos= yythunkpos77; + l91:; if (!yy_option_list(yy)) goto l86; goto l87; + l86:; yy->__pos= yypos86; yy->__thunkpos= yythunkpos86; } - l78:; + l87:; yyprintf((stderr, " ok %s @ %s\n", "option_list", yy->__buf+yy->__pos)); return 1; - l76:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l85:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "option_list", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_full_port(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "full_port")); if (!yy_port(yy)) goto l83; if (!yy_proto(yy)) goto l83; yyDo(yy, yy_1_full_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "full_port")); if (!yy_port(yy)) goto l92; if (!yy_proto(yy)) goto l92; yyDo(yy, yy_1_full_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "full_port", yy->__buf+yy->__pos)); return 1; - l83:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l92:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "full_port", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_address(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "address")); - { int yypos85= yy->__pos, yythunkpos85= yy->__thunkpos; if (!yy_ipv4(yy)) goto l86; goto l85; - l86:; yy->__pos= yypos85; yy->__thunkpos= yythunkpos85; if (!yy_ipv6(yy)) goto l87; goto l85; - l87:; yy->__pos= yypos85; yy->__thunkpos= yythunkpos85; if (!yy_hostname(yy)) goto l84; + { int yypos94= yy->__pos, yythunkpos94= yy->__thunkpos; if (!yy_ipv4(yy)) goto l95; goto l94; + l95:; yy->__pos= yypos94; yy->__thunkpos= yythunkpos94; if (!yy_ipv6(yy)) goto l96; goto l94; + l96:; yy->__pos= yypos94; yy->__thunkpos= yythunkpos94; if (!yy_hostname(yy)) goto l93; } - l85:; + l94:; yyprintf((stderr, " ok %s @ %s\n", "address", yy->__buf+yy->__pos)); return 1; - l84:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l93:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "address", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_server_options(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "server_options")); if (!yymatchChar(yy, '[')) goto l88; - { int yypos89= yy->__pos, yythunkpos89= yy->__thunkpos; if (!yy__(yy)) goto l89; goto l90; - l89:; yy->__pos= yypos89; yy->__thunkpos= yythunkpos89; + yyprintf((stderr, "%s\n", "server_options")); if (!yymatchChar(yy, '[')) goto l97; + { int yypos98= yy->__pos, yythunkpos98= yy->__thunkpos; if (!yy__(yy)) goto l98; goto l99; + l98:; yy->__pos= yypos98; yy->__thunkpos= yythunkpos98; } - l90:; if (!yy_option_list(yy)) goto l88; - { int yypos91= yy->__pos, yythunkpos91= yy->__thunkpos; if (!yy__(yy)) goto l91; goto l92; - l91:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; + l99:; if (!yy_option_list(yy)) goto l97; + { int yypos100= yy->__pos, yythunkpos100= yy->__thunkpos; if (!yy__(yy)) goto l100; goto l101; + l100:; yy->__pos= yypos100; yy->__thunkpos= yythunkpos100; } - l92:; if (!yymatchChar(yy, ']')) goto l88; + l101:; if (!yymatchChar(yy, ']')) goto l97; yyprintf((stderr, " ok %s @ %s\n", "server_options", yy->__buf+yy->__pos)); return 1; - l88:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l97:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "server_options", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_connect_port(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "connect_port")); if (!yy_full_port(yy)) goto l93; yyDo(yy, yy_1_connect_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "connect_port")); if (!yy_full_port(yy)) goto l102; yyDo(yy, yy_1_connect_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "connect_port", yy->__buf+yy->__pos)); return 1; - l93:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l102:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "connect_port", yy->__buf+yy->__pos)); return 0; } @@ -1067,28 +1091,28 @@ YY_RULE(int) yy_connect_address(yycontext *yy) yyprintf((stderr, "%s\n", "connect_address")); yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l94; +if (!(YY_BEGIN)) goto l103; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l94; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l103; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l94; +if (!(YY_END)) goto l103; #undef yytext #undef yyleng } yyDo(yy, yy_1_connect_address, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "connect_address", yy->__buf+yy->__pos)); return 1; - l94:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l103:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "connect_address", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_bind_port(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "bind_port")); if (!yy_full_port(yy)) goto l95; yyDo(yy, yy_1_bind_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "bind_port")); if (!yy_full_port(yy)) goto l104; yyDo(yy, yy_1_bind_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "bind_port", yy->__buf+yy->__pos)); return 1; - l95:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l104:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "bind_port", yy->__buf+yy->__pos)); return 0; } @@ -1097,153 +1121,153 @@ YY_RULE(int) yy_bind_address(yycontext *yy) yyprintf((stderr, "%s\n", "bind_address")); yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l96; +if (!(YY_BEGIN)) goto l105; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l96; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l105; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l96; +if (!(YY_END)) goto l105; #undef yytext #undef yyleng } yyDo(yy, yy_1_bind_address, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "bind_address", yy->__buf+yy->__pos)); return 1; - l96:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l105:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "bind_address", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_logcommon(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "logcommon")); if (!yymatchString(yy, "logcommon")) goto l97; yyDo(yy, yy_1_logcommon, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "logcommon")); if (!yymatchString(yy, "logcommon")) goto l106; yyDo(yy, yy_1_logcommon, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "logcommon", yy->__buf+yy->__pos)); return 1; - l97:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l106:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "logcommon", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_pidlogfile(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "pidlogfile")); if (!yymatchString(yy, "pidlogfile")) goto l98; if (!yy__(yy)) goto l98; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "pidlogfile")); if (!yymatchString(yy, "pidlogfile")) goto l107; if (!yy__(yy)) goto l107; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l98; +if (!(YY_BEGIN)) goto l107; #undef yytext #undef yyleng - } if (!yy_filename(yy)) goto l98; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_filename(yy)) goto l107; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l98; +if (!(YY_END)) goto l107; #undef yytext #undef yyleng } yyDo(yy, yy_1_pidlogfile, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "pidlogfile", yy->__buf+yy->__pos)); return 1; - l98:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l107:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "pidlogfile", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_logfile(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "logfile")); if (!yymatchString(yy, "logfile")) goto l99; if (!yy__(yy)) goto l99; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "logfile")); if (!yymatchString(yy, "logfile")) goto l108; if (!yy__(yy)) goto l108; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l99; +if (!(YY_BEGIN)) goto l108; #undef yytext #undef yyleng - } if (!yy_filename(yy)) goto l99; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_filename(yy)) goto l108; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l99; +if (!(YY_END)) goto l108; #undef yytext #undef yyleng } yyDo(yy, yy_1_logfile, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "logfile", yy->__buf+yy->__pos)); return 1; - l99:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l108:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "logfile", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_auth_rule(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "auth_rule")); if (!yy_auth_key(yy)) goto l100; if (!yy__(yy)) goto l100; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "auth_rule")); if (!yy_auth_key(yy)) goto l109; if (!yy__(yy)) goto l109; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l100; +if (!(YY_BEGIN)) goto l109; #undef yytext #undef yyleng - } if (!yy_pattern(yy)) goto l100; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_pattern(yy)) goto l109; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l100; +if (!(YY_END)) goto l109; #undef yytext #undef yyleng } yyDo(yy, yy_1_auth_rule, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "auth_rule", yy->__buf+yy->__pos)); return 1; - l100:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l109:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "auth_rule", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_server_rule(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "server_rule")); if (!yy_bind_address(yy)) goto l101; if (!yy__(yy)) goto l101; if (!yy_bind_port(yy)) goto l101; if (!yy__(yy)) goto l101; if (!yy_connect_address(yy)) goto l101; if (!yy__(yy)) goto l101; if (!yy_connect_port(yy)) goto l101; - { int yypos102= yy->__pos, yythunkpos102= yy->__thunkpos; - { int yypos104= yy->__pos, yythunkpos104= yy->__thunkpos; if (!yy__(yy)) goto l104; goto l105; - l104:; yy->__pos= yypos104; yy->__thunkpos= yythunkpos104; + yyprintf((stderr, "%s\n", "server_rule")); if (!yy_bind_address(yy)) goto l110; if (!yy__(yy)) goto l110; if (!yy_bind_port(yy)) goto l110; if (!yy__(yy)) goto l110; if (!yy_connect_address(yy)) goto l110; if (!yy__(yy)) goto l110; if (!yy_connect_port(yy)) goto l110; + { int yypos111= yy->__pos, yythunkpos111= yy->__thunkpos; + { int yypos113= yy->__pos, yythunkpos113= yy->__thunkpos; if (!yy__(yy)) goto l113; goto l114; + l113:; yy->__pos= yypos113; yy->__thunkpos= yythunkpos113; } - l105:; if (!yy_server_options(yy)) goto l102; goto l103; - l102:; yy->__pos= yypos102; yy->__thunkpos= yythunkpos102; + l114:; if (!yy_server_options(yy)) goto l111; goto l112; + l111:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111; } - l103:; yyDo(yy, yy_1_server_rule, yy->__begin, yy->__end); + l112:; yyDo(yy, yy_1_server_rule, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "server_rule", yy->__buf+yy->__pos)); return 1; - l101:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l110:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "server_rule", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_comment(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(yy, '#')) goto l106; - l107:; - { int yypos108= yy->__pos, yythunkpos108= yy->__thunkpos; - { int yypos109= yy->__pos, yythunkpos109= yy->__thunkpos; if (!yy_eol(yy)) goto l109; goto l108; - l109:; yy->__pos= yypos109; yy->__thunkpos= yythunkpos109; - } if (!yymatchDot(yy)) goto l108; goto l107; - l108:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108; + yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(yy, '#')) goto l115; + l116:; + { int yypos117= yy->__pos, yythunkpos117= yy->__thunkpos; + { int yypos118= yy->__pos, yythunkpos118= yy->__thunkpos; if (!yy_eol(yy)) goto l118; goto l117; + l118:; yy->__pos= yypos118; yy->__thunkpos= yythunkpos118; + } if (!yymatchDot(yy)) goto l117; goto l116; + l117:; yy->__pos= yypos117; yy->__thunkpos= yythunkpos117; } yyprintf((stderr, " ok %s @ %s\n", "comment", yy->__buf+yy->__pos)); return 1; - l106:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l115:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "comment", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_command(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "command")); - { int yypos111= yy->__pos, yythunkpos111= yy->__thunkpos; if (!yy_server_rule(yy)) goto l112; goto l111; - l112:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111; if (!yy_auth_rule(yy)) goto l113; goto l111; - l113:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111; if (!yy_logfile(yy)) goto l114; goto l111; - l114:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111; if (!yy_pidlogfile(yy)) goto l115; goto l111; - l115:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111; if (!yy_logcommon(yy)) goto l110; + { int yypos120= yy->__pos, yythunkpos120= yy->__thunkpos; if (!yy_server_rule(yy)) goto l121; goto l120; + l121:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_auth_rule(yy)) goto l122; goto l120; + l122:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_logfile(yy)) goto l123; goto l120; + l123:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_pidlogfile(yy)) goto l124; goto l120; + l124:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_logcommon(yy)) goto l119; } - l111:; + l120:; yyprintf((stderr, " ok %s @ %s\n", "command", yy->__buf+yy->__pos)); return 1; - l110:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l119:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "command", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy__(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; - yyprintf((stderr, "%s\n", "_")); if (!yymatchClass(yy, (unsigned char *)"\000\002\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l116; - l117:; - { int yypos118= yy->__pos, yythunkpos118= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\002\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l118; goto l117; - l118:; yy->__pos= yypos118; yy->__thunkpos= yythunkpos118; + yyprintf((stderr, "%s\n", "_")); if (!yymatchClass(yy, (unsigned char *)"\000\002\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l125; + l126:; + { int yypos127= yy->__pos, yythunkpos127= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\002\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l127; goto l126; + l127:; yy->__pos= yypos127; yy->__thunkpos= yythunkpos127; } yyprintf((stderr, " ok %s @ %s\n", "_", yy->__buf+yy->__pos)); return 1; - l116:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l125:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "_", yy->__buf+yy->__pos)); return 0; } @@ -1252,71 +1276,71 @@ YY_RULE(int) yy_invalid_syntax(yycontext *yy) yyprintf((stderr, "%s\n", "invalid_syntax")); yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l119; +if (!(YY_BEGIN)) goto l128; #undef yytext #undef yyleng } - { int yypos122= yy->__pos, yythunkpos122= yy->__thunkpos; if (!yy_eol(yy)) goto l122; goto l119; - l122:; yy->__pos= yypos122; yy->__thunkpos= yythunkpos122; - } if (!yymatchDot(yy)) goto l119; - l120:; - { int yypos121= yy->__pos, yythunkpos121= yy->__thunkpos; - { int yypos123= yy->__pos, yythunkpos123= yy->__thunkpos; if (!yy_eol(yy)) goto l123; goto l121; - l123:; yy->__pos= yypos123; yy->__thunkpos= yythunkpos123; - } if (!yymatchDot(yy)) goto l121; goto l120; - l121:; yy->__pos= yypos121; yy->__thunkpos= yythunkpos121; + { int yypos131= yy->__pos, yythunkpos131= yy->__thunkpos; if (!yy_eol(yy)) goto l131; goto l128; + l131:; yy->__pos= yypos131; yy->__thunkpos= yythunkpos131; + } if (!yymatchDot(yy)) goto l128; + l129:; + { int yypos130= yy->__pos, yythunkpos130= yy->__thunkpos; + { int yypos132= yy->__pos, yythunkpos132= yy->__thunkpos; if (!yy_eol(yy)) goto l132; goto l130; + l132:; yy->__pos= yypos132; yy->__thunkpos= yythunkpos132; + } if (!yymatchDot(yy)) goto l130; goto l129; + l130:; yy->__pos= yypos130; yy->__thunkpos= yythunkpos130; } yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l119; +if (!(YY_END)) goto l128; #undef yytext #undef yyleng - } if (!yy_eol(yy)) goto l119; yyDo(yy, yy_1_invalid_syntax, yy->__begin, yy->__end); + } if (!yy_eol(yy)) goto l128; yyDo(yy, yy_1_invalid_syntax, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "invalid_syntax", yy->__buf+yy->__pos)); return 1; - l119:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l128:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "invalid_syntax", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_eol(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "eol")); - { int yypos125= yy->__pos, yythunkpos125= yy->__thunkpos; - { int yypos127= yy->__pos, yythunkpos127= yy->__thunkpos; if (!yymatchChar(yy, '\r')) goto l127; goto l128; - l127:; yy->__pos= yypos127; yy->__thunkpos= yythunkpos127; + { int yypos134= yy->__pos, yythunkpos134= yy->__thunkpos; + { int yypos136= yy->__pos, yythunkpos136= yy->__thunkpos; if (!yymatchChar(yy, '\r')) goto l136; goto l137; + l136:; yy->__pos= yypos136; yy->__thunkpos= yythunkpos136; } - l128:; if (!yymatchChar(yy, '\n')) goto l126; goto l125; - l126:; yy->__pos= yypos125; yy->__thunkpos= yythunkpos125; if (!yy_eof(yy)) goto l124; + l137:; if (!yymatchChar(yy, '\n')) goto l135; goto l134; + l135:; yy->__pos= yypos134; yy->__thunkpos= yythunkpos134; if (!yy_eof(yy)) goto l133; } - l125:; + l134:; yyprintf((stderr, " ok %s @ %s\n", "eol", yy->__buf+yy->__pos)); return 1; - l124:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l133:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "eol", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_line(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "line")); - { int yypos130= yy->__pos, yythunkpos130= yy->__thunkpos; if (!yy__(yy)) goto l130; goto l131; - l130:; yy->__pos= yypos130; yy->__thunkpos= yythunkpos130; + { int yypos139= yy->__pos, yythunkpos139= yy->__thunkpos; if (!yy__(yy)) goto l139; goto l140; + l139:; yy->__pos= yypos139; yy->__thunkpos= yythunkpos139; } - l131:; - { int yypos132= yy->__pos, yythunkpos132= yy->__thunkpos; if (!yy_command(yy)) goto l132; - { int yypos134= yy->__pos, yythunkpos134= yy->__thunkpos; if (!yy__(yy)) goto l134; goto l135; - l134:; yy->__pos= yypos134; yy->__thunkpos= yythunkpos134; + l140:; + { int yypos141= yy->__pos, yythunkpos141= yy->__thunkpos; if (!yy_command(yy)) goto l141; + { int yypos143= yy->__pos, yythunkpos143= yy->__thunkpos; if (!yy__(yy)) goto l143; goto l144; + l143:; yy->__pos= yypos143; yy->__thunkpos= yythunkpos143; } - l135:; goto l133; - l132:; yy->__pos= yypos132; yy->__thunkpos= yythunkpos132; + l144:; goto l142; + l141:; yy->__pos= yypos141; yy->__thunkpos= yythunkpos141; } - l133:; - { int yypos136= yy->__pos, yythunkpos136= yy->__thunkpos; if (!yy_comment(yy)) goto l136; goto l137; - l136:; yy->__pos= yypos136; yy->__thunkpos= yythunkpos136; + l142:; + { int yypos145= yy->__pos, yythunkpos145= yy->__thunkpos; if (!yy_comment(yy)) goto l145; goto l146; + l145:; yy->__pos= yypos145; yy->__thunkpos= yythunkpos145; } - l137:; + l146:; yyprintf((stderr, " ok %s @ %s\n", "line", yy->__buf+yy->__pos)); return 1; - l129:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l138:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "line", yy->__buf+yy->__pos)); return 0; } @@ -1325,20 +1349,20 @@ YY_RULE(int) yy_sol(yycontext *yy) yyprintf((stderr, "%s\n", "sol")); yyDo(yy, yy_1_sol, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "sol", yy->__buf+yy->__pos)); return 1; - l138:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l147:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "sol", yy->__buf+yy->__pos)); return 0; } YY_RULE(int) yy_file(yycontext *yy) { yyprintf((stderr, "%s\n", "file")); - l140:; - { int yypos141= yy->__pos, yythunkpos141= yy->__thunkpos; if (!yy_sol(yy)) goto l141; - { int yypos142= yy->__pos, yythunkpos142= yy->__thunkpos; if (!yy_line(yy)) goto l143; if (!yy_eol(yy)) goto l143; goto l142; - l143:; yy->__pos= yypos142; yy->__thunkpos= yythunkpos142; if (!yy_invalid_syntax(yy)) goto l141; + l149:; + { int yypos150= yy->__pos, yythunkpos150= yy->__thunkpos; if (!yy_sol(yy)) goto l150; + { int yypos151= yy->__pos, yythunkpos151= yy->__thunkpos; if (!yy_line(yy)) goto l152; if (!yy_eol(yy)) goto l152; goto l151; + l152:; yy->__pos= yypos151; yy->__thunkpos= yythunkpos151; if (!yy_invalid_syntax(yy)) goto l150; } - l142:; goto l140; - l141:; yy->__pos= yypos141; yy->__thunkpos= yythunkpos141; + l151:; goto l149; + l150:; yy->__pos= yypos150; yy->__thunkpos= yythunkpos150; } yyprintf((stderr, " ok %s @ %s\n", "file", yy->__buf+yy->__pos)); return 1; @@ -1391,7 +1415,7 @@ YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx) } #endif -#line 165 "parse.peg" +#line 166 "parse.peg" void parseConfiguration(char const *file) diff --git a/src/parse.peg b/src/parse.peg index 81366ad..092ed01 100644 --- a/src/parse.peg +++ b/src/parse.peg @@ -23,10 +23,10 @@ int isAuthAllow; \ char *tmpPort; \ uint16_t tmpPortNum, tmpProto; \ - uint16_t bindPortNum, connectPortNum; \ + uint16_t connectPortNum; \ int bindProto, connectProto; \ int serverTimeout; \ - char *bindAddress, *connectAddress, *sourceAddress; + char *bindAddress, *bindPort, *connectAddress, *sourceAddress; #define YY_INPUT(yyctx, buf, result, max_size) \ { \ int yyc = fgetc(yyctx->fp); \ @@ -51,7 +51,7 @@ comment = "#" (!eol .)* server-rule = bind-address - bind-port - connect-address - connect-port (-? server-options)? { - addServer(yy->bindAddress, yy->bindPortNum, yy->bindProto, + addServer(yy->bindAddress, yy->bindPort, yy->bindProto, yy->connectAddress, yy->connectPortNum, yy->connectProto, yy->serverTimeout > 0 ? yy->serverTimeout : RINETD_DEFAULT_UDP_TIMEOUT, yy->sourceAddress); @@ -61,7 +61,7 @@ server-rule = bind-address - bind-port - connect-address - connect-port (-? se bind-address = < address > { yy->bindAddress = strdup(yytext); } connect-address = < address > { yy->connectAddress = strdup(yytext); } -bind-port = full-port { yy->bindPortNum = yy->tmpPortNum; yy->bindProto = yy->tmpProto; } +bind-port = full-port { yy->bindPort = yy->tmpPort; yy->bindProto = yy->tmpProto; } connect-port = full-port { yy->connectPortNum = yy->tmpPortNum; yy->connectProto = yy->tmpProto; } server-options = "[" -? option-list -? "]" diff --git a/src/rinetd.c b/src/rinetd.c index e8a39d1..f6b3263 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -1,6 +1,6 @@ /* Copyright © 1997—1999 Thomas Boutell and Boutell.Com, Inc. - © 2003—2019 Sam Hocevar + © 2003—2021 Sam Hocevar This software is released for free use under the terms of the GNU Public License, version 2 or higher. NO WARRANTY @@ -248,101 +248,103 @@ static void readConfiguration(char const *file) { } } -void addServer(char *bindAddress, uint16_t bindPort, protocolType bindProto, +void addServer(char *bindAddress, char *bindPort, protocolType bindProto, char *connectAddress, uint16_t connectPort, protocolType connectProto, int serverTimeout, char *sourceAddress) { - /* Turn all of this stuff into reasonable addresses */ - struct in_addr iaddr; - if (getAddress(bindAddress, &iaddr) < 0) { - fprintf(stderr, "rinetd: host %s could not be resolved.\n", - bindAddress); - exit(1); - } - struct in_addr isourceaddr; - isourceaddr.s_addr = INADDR_ANY; - if (sourceAddress && getAddress(sourceAddress, &isourceaddr) < 0) { + ServerInfo si = { + .fromHost = bindAddress, + .fromProto = bindProto, + .toHost = connectAddress, + .toPort = connectPort, + .toProto = connectProto, + .serverTimeout = serverTimeout, + }; + + si.sourceAddr.s_addr = INADDR_ANY; + if (sourceAddress && getAddress(sourceAddress, &si.sourceAddr) < 0) { fprintf(stderr, "rinetd: host %s could not be resolved.\n", sourceAddress); exit(1); } + /* Make a server socket */ - SOCKET fd = socket(PF_INET, - bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM, - bindProto == protoTcp ? IPPROTO_TCP : IPPROTO_UDP); - if (fd == INVALID_SOCKET) { - syslog(LOG_ERR, "couldn't create " - "server socket! (%m)\n"); - exit(1); - } - struct sockaddr_in saddr; - saddr.sin_family = AF_INET; - memcpy(&saddr.sin_addr, &iaddr, sizeof(iaddr)); - saddr.sin_port = htons(bindPort); - int tmp = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - (const char *) &tmp, sizeof(tmp)); - if (bind(fd, (struct sockaddr *) - &saddr, sizeof(saddr)) == SOCKET_ERROR) { - /* Warn -- don't exit. */ - syslog(LOG_ERR, "couldn't bind to " - "address %s port %d (%m)\n", - bindAddress, (int)bindPort); - closesocket(fd); + struct addrinfo hints = + { + .ai_family = AF_UNSPEC, + .ai_socktype = bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM, + .ai_flags = AI_PASSIVE, + }; + struct addrinfo *servinfo; + int ret = getaddrinfo(bindAddress, bindPort, &hints, &servinfo); + if (ret != 0) { + fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerror(ret)); exit(1); } - if (bindProto == protoTcp) { - if (listen(fd, RINETD_LISTEN_BACKLOG) == SOCKET_ERROR) { - /* Warn -- don't exit. */ - syslog(LOG_ERR, "couldn't listen to " - "address %s port %d (%m)\n", - bindAddress, (int)bindPort); - closesocket(fd); + for (struct addrinfo *it = servinfo; it; it = it->ai_next) { + si.fd = socket(it->ai_family, + bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM, + bindProto == protoTcp ? IPPROTO_TCP : IPPROTO_UDP); + if (si.fd == INVALID_SOCKET) { + syslog(LOG_ERR, "couldn't create server socket! (%m)\n"); + freeaddrinfo(servinfo); + exit(1); } - /* Make socket nonblocking in TCP mode only, otherwise - we may miss some data. */ - setSocketDefaults(fd); - } + int tmp = 1; + setsockopt(si.fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &tmp, sizeof(tmp)); - if (getAddress(connectAddress, &iaddr) < 0) { + if (bind(si.fd, it->ai_addr, it->ai_addrlen) == SOCKET_ERROR) { + syslog(LOG_ERR, "couldn't bind to address %s port %s (%m)\n", + bindAddress, bindPort); + closesocket(si.fd); + freeaddrinfo(servinfo); + exit(1); + } + + if (bindProto == protoTcp) { + if (listen(si.fd, RINETD_LISTEN_BACKLOG) == SOCKET_ERROR) { + /* Warn -- don't exit. */ + syslog(LOG_ERR, "couldn't listen to address %s port %s (%m)\n", + bindAddress, bindPort); + /* XXX: check whether this is correct */ + closesocket(si.fd); + } + + /* Make socket nonblocking in TCP mode only, otherwise + we may miss some data. */ + setSocketDefaults(si.fd); + } + + si.fromPort = it->ai_addr->sa_family == AF_INET + ? ntohs(((struct sockaddr_in*)it->ai_addr)->sin_port) + : ntohs(((struct sockaddr_in6*)it->ai_addr)->sin6_port); + break; + } + freeaddrinfo(servinfo); + + if (getAddress(connectAddress, &si.localAddr) < 0) { /* Warn -- don't exit. */ syslog(LOG_ERR, "host %s could not be resolved.\n", bindAddress); - closesocket(fd); + closesocket(si.fd); exit(1); } + si.localPort = htons(connectPort); + +#ifndef _WIN32 + if (si.fd > maxfd) { + maxfd = si.fd; + } +#endif + /* Allocate server info */ - seInfo = (ServerInfo *) - realloc(seInfo, sizeof(ServerInfo) * (seTotal + 1)); + seInfo = (ServerInfo *)realloc(seInfo, sizeof(ServerInfo) * (seTotal + 1)); if (!seInfo) { exit(1); } - ServerInfo *srv = &seInfo[seTotal]; - memset(srv, 0, sizeof(*srv)); - srv->fd = fd; - srv->localAddr = iaddr; - srv->localPort = htons(connectPort); - srv->fromHost = bindAddress; - if (!srv->fromHost) { - exit(1); - } - srv->fromPort = bindPort; - srv->fromProto = bindProto; - srv->sourceAddr = isourceaddr; - srv->toHost = connectAddress; - if (!srv->toHost) { - exit(1); - } - srv->toPort = connectPort; - srv->toProto = connectProto; - srv->serverTimeout = serverTimeout; -#ifndef _WIN32 - if (fd > maxfd) { - maxfd = fd; - } -#endif + seInfo[seTotal] = si; ++seTotal; } diff --git a/src/rinetd.h b/src/rinetd.h index d7de52c..4f2275e 100644 --- a/src/rinetd.h +++ b/src/rinetd.h @@ -1,6 +1,6 @@ /* Copyright © 1997—1999 Thomas Boutell and Boutell.Com, Inc. - © 2003—2019 Sam Hocevar + © 2003—2021 Sam Hocevar This software is released for free use under the terms of the GNU Public License, version 2 or higher. NO WARRANTY @@ -46,7 +46,7 @@ extern FILE *logFile; /* Functions */ -void addServer(char *bindAddress, uint16_t bindPort, protocolType bindProto, +void addServer(char *bindAddress, char *bindPort, protocolType bindProto, char *connectAddress, uint16_t connectPort, protocolType connectProto, int serverTimeout, char *sourceAddress);