From dd17267afed4acf881df2f688edce0aadafbab1c Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 8 Sep 2017 19:42:18 +0200 Subject: [PATCH 01/16] Start working on IPv6 support. --- parse.c | 517 +++++++++++++++++++++++++++++------------------------- parse.peg | 4 +- rinetd.c | 15 +- 3 files changed, 289 insertions(+), 247 deletions(-) diff --git a/parse.c b/parse.c index 1562a9c..a4f2201 100644 --- a/parse.c +++ b/parse.c @@ -3,7 +3,7 @@ #include #include #include -#define YYRULECOUNT 36 +#define YYRULECOUNT 38 #line 9 "parse.peg" #if HAVE_CONFIG_H @@ -309,9 +309,11 @@ 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); /* 36 */ -YY_RULE(int) yy_digit(yycontext *yy); /* 35 */ -YY_RULE(int) yy_hostname(yycontext *yy); /* 34 */ +YY_RULE(int) yy_eof(yycontext *yy); /* 38 */ +YY_RULE(int) yy_hexdigit(yycontext *yy); /* 37 */ +YY_RULE(int) yy_digit(yycontext *yy); /* 36 */ +YY_RULE(int) yy_hostname(yycontext *yy); /* 35 */ +YY_RULE(int) yy_ipv6(yycontext *yy); /* 34 */ YY_RULE(int) yy_ipv4(yycontext *yy); /* 33 */ YY_RULE(int) yy_name(yycontext *yy); /* 32 */ YY_RULE(int) yy_filename(yycontext *yy); /* 31 */ @@ -353,7 +355,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 156 +#line 158 ++yy->currentLine; ; } #undef yythunkpos @@ -673,121 +675,155 @@ YY_RULE(int) yy_eof(yycontext *yy) yyprintf((stderr, " fail %s @ %s\n", "eof", yy->__buf+yy->__pos)); return 0; } -YY_RULE(int) yy_digit(yycontext *yy) +YY_RULE(int) yy_hexdigit(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 l2; - yyprintf((stderr, " ok %s @ %s\n", "digit", yy->__buf+yy->__pos)); + 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 l2; + yyprintf((stderr, " ok %s @ %s\n", "hexdigit", yy->__buf+yy->__pos)); return 1; l2:; 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 l3; + yyprintf((stderr, " ok %s @ %s\n", "digit", yy->__buf+yy->__pos)); + return 1; + l3:; 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")); - l4:; - { int yypos5= yy->__pos, yythunkpos5= 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 l5; - l6:; - { int yypos7= yy->__pos, yythunkpos7= 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 l7; goto l6; - l7:; yy->__pos= yypos7; yy->__thunkpos= yythunkpos7; - } if (!yymatchChar(yy, '.')) goto l5; goto l4; - l5:; yy->__pos= yypos5; yy->__thunkpos= yythunkpos5; - } if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l3; - l8:; - { int yypos9= yy->__pos, yythunkpos9= 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 l9; goto l8; - l9:; yy->__pos= yypos9; yy->__thunkpos= yythunkpos9; - } - { int yypos10= yy->__pos, yythunkpos10= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l10; goto l11; + l5:; + { int yypos6= yy->__pos, yythunkpos6= 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 l6; + l7:; + { int yypos8= yy->__pos, yythunkpos8= 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 l8; goto l7; + l8:; yy->__pos= yypos8; yy->__thunkpos= yythunkpos8; + } if (!yymatchChar(yy, '.')) goto l6; goto l5; + l6:; yy->__pos= yypos6; yy->__thunkpos= yythunkpos6; + } if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l4; + l9:; + { int yypos10= yy->__pos, yythunkpos10= 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 l10; goto l9; l10:; yy->__pos= yypos10; yy->__thunkpos= yythunkpos10; } - l11:; + { int yypos11= yy->__pos, yythunkpos11= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l11; goto l12; + l11:; yy->__pos= yypos11; yy->__thunkpos= yythunkpos11; + } + l12:; yyprintf((stderr, " ok %s @ %s\n", "hostname", yy->__buf+yy->__pos)); return 1; - l3:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l4:; 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 yypos14= yy->__pos, yythunkpos14= yy->__thunkpos; + { int yypos18= yy->__pos, yythunkpos18= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l19; goto l18; + l19:; yy->__pos= yypos18; yy->__thunkpos= yythunkpos18; if (!yymatchChar(yy, ':')) goto l15; + } + l18:; + l16:; + { int yypos17= yy->__pos, yythunkpos17= yy->__thunkpos; + { int yypos20= yy->__pos, yythunkpos20= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l21; goto l20; + l21:; yy->__pos= yypos20; yy->__thunkpos= yythunkpos20; if (!yymatchChar(yy, ':')) goto l17; + } + l20:; goto l16; + l17:; yy->__pos= yypos17; yy->__thunkpos= yythunkpos17; + } goto l14; + l15:; yy->__pos= yypos14; yy->__thunkpos= yythunkpos14; if (!yymatchChar(yy, '[')) goto l13; if (!yy_ipv6(yy)) goto l13; if (!yymatchChar(yy, ']')) goto l13; + } + l14:; + yyprintf((stderr, " ok %s @ %s\n", "ipv6", yy->__buf+yy->__pos)); + return 1; + l13:; 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 yypos13= yy->__pos, yythunkpos13= yy->__thunkpos; if (!yy_number(yy)) goto l14; if (!yymatchChar(yy, '.')) goto l14; if (!yy_number(yy)) goto l14; if (!yymatchChar(yy, '.')) goto l14; if (!yy_number(yy)) goto l14; if (!yymatchChar(yy, '.')) goto l14; if (!yy_number(yy)) goto l14; goto l13; - l14:; yy->__pos= yypos13; yy->__thunkpos= yythunkpos13; if (!yymatchChar(yy, '0')) goto l12; + { int yypos23= yy->__pos, yythunkpos23= yy->__thunkpos; if (!yy_number(yy)) goto l24; if (!yymatchChar(yy, '.')) goto l24; if (!yy_number(yy)) goto l24; if (!yymatchChar(yy, '.')) goto l24; if (!yy_number(yy)) goto l24; if (!yymatchChar(yy, '.')) goto l24; if (!yy_number(yy)) goto l24; goto l23; + l24:; yy->__pos= yypos23; yy->__thunkpos= yythunkpos23; if (!yymatchChar(yy, '0')) goto l22; } - l13:; + l23:; yyprintf((stderr, " ok %s @ %s\n", "ipv4", yy->__buf+yy->__pos)); return 1; - l12:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l22:; 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\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l15; - l16:; - { int yypos17= yy->__pos, yythunkpos17= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\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 l17; goto l16; - l17:; yy->__pos= yypos17; yy->__thunkpos= yythunkpos17; + yyprintf((stderr, "%s\n", "name")); if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; + l26:; + { int yypos27= yy->__pos, yythunkpos27= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\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 l27; goto l26; + l27:; yy->__pos= yypos27; yy->__thunkpos= yythunkpos27; } yyprintf((stderr, " ok %s @ %s\n", "name", yy->__buf+yy->__pos)); return 1; - l15:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l25:; 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 yypos19= yy->__pos, yythunkpos19= yy->__thunkpos; if (!yymatchChar(yy, '"')) goto l20; 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 l20; - l21:; - { int yypos22= yy->__pos, yythunkpos22= 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 l22; goto l21; - l22:; yy->__pos= yypos22; yy->__thunkpos= yythunkpos22; - } if (!yymatchChar(yy, '"')) goto l20; goto l19; - l20:; yy->__pos= yypos19; yy->__thunkpos= yythunkpos19; 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 l18; - l23:; - { int yypos24= yy->__pos, yythunkpos24= 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 l24; goto l23; - l24:; yy->__pos= yypos24; yy->__thunkpos= yythunkpos24; + { int yypos29= yy->__pos, yythunkpos29= yy->__thunkpos; if (!yymatchChar(yy, '"')) goto l30; 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 l30; + l31:; + { int yypos32= yy->__pos, yythunkpos32= 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 l32; goto l31; + l32:; yy->__pos= yypos32; yy->__thunkpos= yythunkpos32; + } if (!yymatchChar(yy, '"')) goto l30; goto l29; + l30:; yy->__pos= yypos29; yy->__thunkpos= yythunkpos29; 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 l28; + l33:; + { int yypos34= yy->__pos, yythunkpos34= 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 l34; goto l33; + l34:; yy->__pos= yypos34; yy->__thunkpos= yythunkpos34; } } - l19:; + l29:; yyprintf((stderr, " ok %s @ %s\n", "filename", yy->__buf+yy->__pos)); return 1; - l18:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l28:; 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 l25; - l26:; - { int yypos27= yy->__pos, yythunkpos27= 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 l27; goto l26; - l27:; yy->__pos= yypos27; yy->__thunkpos= yythunkpos27; + 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 l35; + l36:; + { int yypos37= yy->__pos, yythunkpos37= 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 l37; goto l36; + l37:; yy->__pos= yypos37; yy->__thunkpos= yythunkpos37; } - { int yypos28= yy->__pos, yythunkpos28= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l28; 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 l28; - l30:; - { int yypos31= yy->__pos, yythunkpos31= 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 l31; goto l30; - l31:; yy->__pos= yypos31; yy->__thunkpos= yythunkpos31; + { int yypos38= yy->__pos, yythunkpos38= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l38; 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 l38; + l40:; + { int yypos41= yy->__pos, yythunkpos41= 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 l41; goto l40; + l41:; yy->__pos= yypos41; yy->__thunkpos= yythunkpos41; } - { int yypos32= yy->__pos, yythunkpos32= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l32; 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 l32; - l34:; - { int yypos35= yy->__pos, yythunkpos35= 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 l35; goto l34; - l35:; yy->__pos= yypos35; yy->__thunkpos= yythunkpos35; + { int yypos42= yy->__pos, yythunkpos42= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l42; 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 l42; + 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; } - { int yypos36= yy->__pos, yythunkpos36= yy->__thunkpos; if (!yymatchChar(yy, '.')) goto l36; 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; - l38:; - { int yypos39= yy->__pos, yythunkpos39= 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 l39; goto l38; - l39:; yy->__pos= yypos39; yy->__thunkpos= yythunkpos39; - } goto l37; - l36:; yy->__pos= yypos36; yy->__thunkpos= yythunkpos36; + { 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; + } goto l47; + l46:; yy->__pos= yypos46; yy->__thunkpos= yythunkpos46; } - l37:; goto l33; - l32:; yy->__pos= yypos32; yy->__thunkpos= yythunkpos32; + l47:; goto l43; + l42:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; } - l33:; goto l29; - l28:; yy->__pos= yypos28; yy->__thunkpos= yythunkpos28; + l43:; goto l39; + l38:; yy->__pos= yypos38; yy->__thunkpos= yythunkpos38; } - l29:; + l39:; yyprintf((stderr, " ok %s @ %s\n", "pattern", yy->__buf+yy->__pos)); return 1; - l25:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l35:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "pattern", yy->__buf+yy->__pos)); return 0; } @@ -796,46 +832,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 l40; +if (!(YY_BEGIN)) goto l50; #undef yytext #undef yyleng } - { int yypos41= yy->__pos, yythunkpos41= yy->__thunkpos; if (!yymatchString(yy, "allow")) goto l42; goto l41; - l42:; yy->__pos= yypos41; yy->__thunkpos= yythunkpos41; if (!yymatchString(yy, "deny")) goto l40; + { int yypos51= yy->__pos, yythunkpos51= yy->__thunkpos; if (!yymatchString(yy, "allow")) goto l52; goto l51; + l52:; yy->__pos= yypos51; yy->__thunkpos= yythunkpos51; if (!yymatchString(yy, "deny")) goto l50; } - l41:; yyText(yy, yy->__begin, yy->__end); { + l51:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l40; +if (!(YY_END)) goto l50; #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; - l40:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l50:; 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 l43; + yyprintf((stderr, "%s\n", "service")); if (!yy_name(yy)) goto l53; yyprintf((stderr, " ok %s @ %s\n", "service", yy->__buf+yy->__pos)); return 1; - l43:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l53:; 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 yypos45= yy->__pos, yythunkpos45= yy->__thunkpos; if (!yymatchString(yy, "/tcp")) goto l46; yyDo(yy, yy_1_proto, yy->__begin, yy->__end); goto l45; - l46:; yy->__pos= yypos45; yy->__thunkpos= yythunkpos45; if (!yymatchString(yy, "/udp")) goto l47; yyDo(yy, yy_2_proto, yy->__begin, yy->__end); goto l45; - l47:; yy->__pos= yypos45; yy->__thunkpos= yythunkpos45; if (!yymatchString(yy, "")) goto l44; yyDo(yy, yy_3_proto, yy->__begin, yy->__end); + { int yypos55= yy->__pos, yythunkpos55= yy->__thunkpos; if (!yymatchString(yy, "/tcp")) goto l56; yyDo(yy, yy_1_proto, yy->__begin, yy->__end); goto l55; + l56:; yy->__pos= yypos55; yy->__thunkpos= yythunkpos55; if (!yymatchString(yy, "/udp")) goto l57; yyDo(yy, yy_2_proto, yy->__begin, yy->__end); goto l55; + l57:; yy->__pos= yypos55; yy->__thunkpos= yythunkpos55; if (!yymatchString(yy, "")) goto l54; yyDo(yy, yy_3_proto, yy->__begin, yy->__end); } - l45:; + l55:; yyprintf((stderr, " ok %s @ %s\n", "proto", yy->__buf+yy->__pos)); return 1; - l44:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l54:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "proto", yy->__buf+yy->__pos)); return 0; } @@ -844,176 +880,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 l48; +if (!(YY_BEGIN)) goto l58; #undef yytext #undef yyleng } - { int yypos49= yy->__pos, yythunkpos49= yy->__thunkpos; if (!yy_number(yy)) goto l50; goto l49; - l50:; yy->__pos= yypos49; yy->__thunkpos= yythunkpos49; if (!yy_service(yy)) goto l48; + { int yypos59= yy->__pos, yythunkpos59= yy->__thunkpos; if (!yy_number(yy)) goto l60; goto l59; + l60:; yy->__pos= yypos59; yy->__thunkpos= yythunkpos59; if (!yy_service(yy)) goto l58; } - l49:; 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 l48; +if (!(YY_END)) goto l58; #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; - l48:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l58:; 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 l51; - l52:; - { int yypos53= yy->__pos, yythunkpos53= yy->__thunkpos; if (!yy_digit(yy)) goto l53; goto l52; - l53:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; + yyprintf((stderr, "%s\n", "number")); if (!yy_digit(yy)) goto l61; + l62:; + { int yypos63= yy->__pos, yythunkpos63= yy->__thunkpos; if (!yy_digit(yy)) goto l63; goto l62; + l63:; yy->__pos= yypos63; yy->__thunkpos= yythunkpos63; } yyprintf((stderr, " ok %s @ %s\n", "number", yy->__buf+yy->__pos)); return 1; - l51:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l61:; 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 l54; - { int yypos55= yy->__pos, yythunkpos55= yy->__thunkpos; if (!yy__(yy)) goto l55; goto l56; - l55:; yy->__pos= yypos55; yy->__thunkpos= yythunkpos55; + yyprintf((stderr, "%s\n", "option_source")); if (!yymatchString(yy, "src")) goto l64; + { int yypos65= yy->__pos, yythunkpos65= yy->__thunkpos; if (!yy__(yy)) goto l65; goto l66; + l65:; yy->__pos= yypos65; yy->__thunkpos= yythunkpos65; } - l56:; if (!yymatchChar(yy, '=')) goto l54; - { int yypos57= yy->__pos, yythunkpos57= yy->__thunkpos; if (!yy__(yy)) goto l57; goto l58; - l57:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; + l66:; if (!yymatchChar(yy, '=')) goto l64; + { int yypos67= yy->__pos, yythunkpos67= yy->__thunkpos; if (!yy__(yy)) goto l67; goto l68; + l67:; yy->__pos= yypos67; yy->__thunkpos= yythunkpos67; } - l58:; yyText(yy, yy->__begin, yy->__end); { + l68:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l54; +if (!(YY_BEGIN)) goto l64; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l54; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l64; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l54; +if (!(YY_END)) goto l64; #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; - l54:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l64:; 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 l59; - { int yypos60= yy->__pos, yythunkpos60= yy->__thunkpos; if (!yy__(yy)) goto l60; goto l61; - l60:; yy->__pos= yypos60; yy->__thunkpos= yythunkpos60; + yyprintf((stderr, "%s\n", "option_timeout")); if (!yymatchString(yy, "timeout")) goto l69; + { int yypos70= yy->__pos, yythunkpos70= yy->__thunkpos; if (!yy__(yy)) goto l70; goto l71; + l70:; yy->__pos= yypos70; yy->__thunkpos= yythunkpos70; } - l61:; if (!yymatchChar(yy, '=')) goto l59; - { int yypos62= yy->__pos, yythunkpos62= yy->__thunkpos; if (!yy__(yy)) goto l62; goto l63; - l62:; yy->__pos= yypos62; yy->__thunkpos= yythunkpos62; + l71:; if (!yymatchChar(yy, '=')) goto l69; + { int yypos72= yy->__pos, yythunkpos72= yy->__thunkpos; if (!yy__(yy)) goto l72; goto l73; + l72:; yy->__pos= yypos72; yy->__thunkpos= yythunkpos72; } - l63:; yyText(yy, yy->__begin, yy->__end); { + l73:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l59; +if (!(YY_BEGIN)) goto l69; #undef yytext #undef yyleng - } if (!yy_number(yy)) goto l59; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_number(yy)) goto l69; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l59; +if (!(YY_END)) goto l69; #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; - l59:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l69:; 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 yypos65= yy->__pos, yythunkpos65= yy->__thunkpos; if (!yy_option_timeout(yy)) goto l66; goto l65; - l66:; yy->__pos= yypos65; yy->__thunkpos= yythunkpos65; if (!yy_option_source(yy)) goto l64; + { int yypos75= yy->__pos, yythunkpos75= yy->__thunkpos; if (!yy_option_timeout(yy)) goto l76; goto l75; + l76:; yy->__pos= yypos75; yy->__thunkpos= yythunkpos75; if (!yy_option_source(yy)) goto l74; } - l65:; + l75:; yyprintf((stderr, " ok %s @ %s\n", "option", yy->__buf+yy->__pos)); return 1; - l64:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l74:; 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 l67; - { int yypos68= yy->__pos, yythunkpos68= yy->__thunkpos; - { int yypos70= yy->__pos, yythunkpos70= yy->__thunkpos; if (!yy__(yy)) goto l70; goto l71; - l70:; yy->__pos= yypos70; yy->__thunkpos= yythunkpos70; + yyprintf((stderr, "%s\n", "option_list")); if (!yy_option(yy)) goto l77; + { int yypos78= yy->__pos, yythunkpos78= yy->__thunkpos; + { int yypos80= yy->__pos, yythunkpos80= yy->__thunkpos; if (!yy__(yy)) goto l80; goto l81; + l80:; yy->__pos= yypos80; yy->__thunkpos= yythunkpos80; } - l71:; if (!yymatchChar(yy, ',')) goto l68; - { int yypos72= yy->__pos, yythunkpos72= yy->__thunkpos; if (!yy__(yy)) goto l72; goto l73; - l72:; yy->__pos= yypos72; yy->__thunkpos= yythunkpos72; + l81:; if (!yymatchChar(yy, ',')) goto l78; + { int yypos82= yy->__pos, yythunkpos82= yy->__thunkpos; if (!yy__(yy)) goto l82; goto l83; + l82:; yy->__pos= yypos82; yy->__thunkpos= yythunkpos82; } - l73:; if (!yy_option_list(yy)) goto l68; goto l69; - l68:; yy->__pos= yypos68; yy->__thunkpos= yythunkpos68; + l83:; if (!yy_option_list(yy)) goto l78; goto l79; + l78:; yy->__pos= yypos78; yy->__thunkpos= yythunkpos78; } - l69:; + l79:; yyprintf((stderr, " ok %s @ %s\n", "option_list", yy->__buf+yy->__pos)); return 1; - l67:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l77:; 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 l74; if (!yy_proto(yy)) goto l74; yyDo(yy, yy_1_full_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "full_port")); if (!yy_port(yy)) goto l84; if (!yy_proto(yy)) goto l84; yyDo(yy, yy_1_full_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "full_port", yy->__buf+yy->__pos)); return 1; - l74:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l84:; 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 yypos76= yy->__pos, yythunkpos76= yy->__thunkpos; if (!yy_ipv4(yy)) goto l77; goto l76; - l77:; yy->__pos= yypos76; yy->__thunkpos= yythunkpos76; if (!yy_hostname(yy)) goto l75; + { int yypos86= yy->__pos, yythunkpos86= yy->__thunkpos; if (!yy_ipv4(yy)) goto l87; goto l86; + l87:; yy->__pos= yypos86; yy->__thunkpos= yythunkpos86; if (!yy_ipv6(yy)) goto l88; goto l86; + l88:; yy->__pos= yypos86; yy->__thunkpos= yythunkpos86; if (!yy_hostname(yy)) goto l85; } - l76:; + l86:; yyprintf((stderr, " ok %s @ %s\n", "address", yy->__buf+yy->__pos)); return 1; - l75:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l85:; 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 l78; - { 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", "server_options")); if (!yymatchChar(yy, '[')) goto l89; + { int yypos90= yy->__pos, yythunkpos90= yy->__thunkpos; if (!yy__(yy)) goto l90; goto l91; + l90:; yy->__pos= yypos90; yy->__thunkpos= yythunkpos90; } - l80:; if (!yy_option_list(yy)) goto l78; - { int yypos81= yy->__pos, yythunkpos81= yy->__thunkpos; if (!yy__(yy)) goto l81; goto l82; - l81:; yy->__pos= yypos81; yy->__thunkpos= yythunkpos81; + l91:; if (!yy_option_list(yy)) goto l89; + { int yypos92= yy->__pos, yythunkpos92= yy->__thunkpos; if (!yy__(yy)) goto l92; goto l93; + l92:; yy->__pos= yypos92; yy->__thunkpos= yythunkpos92; } - l82:; if (!yymatchChar(yy, ']')) goto l78; + l93:; if (!yymatchChar(yy, ']')) goto l89; yyprintf((stderr, " ok %s @ %s\n", "server_options", yy->__buf+yy->__pos)); return 1; - l78:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l89:; 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 l83; yyDo(yy, yy_1_connect_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "connect_port")); if (!yy_full_port(yy)) goto l94; yyDo(yy, yy_1_connect_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "connect_port", yy->__buf+yy->__pos)); return 1; - l83:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l94:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "connect_port", yy->__buf+yy->__pos)); return 0; } @@ -1022,28 +1059,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 l84; +if (!(YY_BEGIN)) goto l95; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l84; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l95; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l84; +if (!(YY_END)) goto l95; #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; - l84:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l95:; 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 l85; yyDo(yy, yy_1_bind_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "bind_port")); if (!yy_full_port(yy)) goto l96; yyDo(yy, yy_1_bind_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "bind_port", yy->__buf+yy->__pos)); return 1; - l85:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l96:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "bind_port", yy->__buf+yy->__pos)); return 0; } @@ -1052,153 +1089,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 l86; +if (!(YY_BEGIN)) goto l97; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l86; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l97; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l86; +if (!(YY_END)) goto l97; #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; - l86:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l97:; 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 l87; yyDo(yy, yy_1_logcommon, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "logcommon")); if (!yymatchString(yy, "logcommon")) goto l98; yyDo(yy, yy_1_logcommon, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "logcommon", yy->__buf+yy->__pos)); return 1; - l87:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l98:; 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 l88; if (!yy__(yy)) goto l88; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "pidlogfile")); if (!yymatchString(yy, "pidlogfile")) goto l99; if (!yy__(yy)) goto l99; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l88; +if (!(YY_BEGIN)) goto l99; #undef yytext #undef yyleng - } if (!yy_filename(yy)) goto l88; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_filename(yy)) goto l99; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l88; +if (!(YY_END)) goto l99; #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; - l88:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l99:; 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 l89; if (!yy__(yy)) goto l89; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "logfile")); if (!yymatchString(yy, "logfile")) goto l100; if (!yy__(yy)) goto l100; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l89; +if (!(YY_BEGIN)) goto l100; #undef yytext #undef yyleng - } if (!yy_filename(yy)) goto l89; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_filename(yy)) goto l100; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l89; +if (!(YY_END)) goto l100; #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; - l89:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l100:; 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 l90; if (!yy__(yy)) goto l90; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "auth_rule")); if (!yy_auth_key(yy)) goto l101; if (!yy__(yy)) goto l101; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l90; +if (!(YY_BEGIN)) goto l101; #undef yytext #undef yyleng - } if (!yy_pattern(yy)) goto l90; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_pattern(yy)) goto l101; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l90; +if (!(YY_END)) goto l101; #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; - l90:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l101:; 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 l91; if (!yy__(yy)) goto l91; if (!yy_bind_port(yy)) goto l91; if (!yy__(yy)) goto l91; if (!yy_connect_address(yy)) goto l91; if (!yy__(yy)) goto l91; if (!yy_connect_port(yy)) goto l91; - { int yypos92= yy->__pos, yythunkpos92= yy->__thunkpos; - { int yypos94= yy->__pos, yythunkpos94= yy->__thunkpos; if (!yy__(yy)) goto l94; goto l95; - l94:; yy->__pos= yypos94; yy->__thunkpos= yythunkpos94; + yyprintf((stderr, "%s\n", "server_rule")); if (!yy_bind_address(yy)) goto l102; if (!yy__(yy)) goto l102; if (!yy_bind_port(yy)) goto l102; if (!yy__(yy)) goto l102; if (!yy_connect_address(yy)) goto l102; if (!yy__(yy)) goto l102; if (!yy_connect_port(yy)) goto l102; + { int yypos103= yy->__pos, yythunkpos103= yy->__thunkpos; + { int yypos105= yy->__pos, yythunkpos105= yy->__thunkpos; if (!yy__(yy)) goto l105; goto l106; + l105:; yy->__pos= yypos105; yy->__thunkpos= yythunkpos105; } - l95:; if (!yy_server_options(yy)) goto l92; goto l93; - l92:; yy->__pos= yypos92; yy->__thunkpos= yythunkpos92; + l106:; if (!yy_server_options(yy)) goto l103; goto l104; + l103:; yy->__pos= yypos103; yy->__thunkpos= yythunkpos103; } - l93:; yyDo(yy, yy_1_server_rule, yy->__begin, yy->__end); + l104:; yyDo(yy, yy_1_server_rule, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "server_rule", yy->__buf+yy->__pos)); return 1; - l91:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l102:; 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 l96; - l97:; - { int yypos98= yy->__pos, yythunkpos98= yy->__thunkpos; - { int yypos99= yy->__pos, yythunkpos99= yy->__thunkpos; if (!yy_eol(yy)) goto l99; goto l98; - l99:; yy->__pos= yypos99; yy->__thunkpos= yythunkpos99; - } if (!yymatchDot(yy)) goto l98; goto l97; - l98:; yy->__pos= yypos98; yy->__thunkpos= yythunkpos98; + yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(yy, '#')) goto l107; + l108:; + { int yypos109= yy->__pos, yythunkpos109= yy->__thunkpos; + { int yypos110= yy->__pos, yythunkpos110= yy->__thunkpos; if (!yy_eol(yy)) goto l110; goto l109; + l110:; yy->__pos= yypos110; yy->__thunkpos= yythunkpos110; + } if (!yymatchDot(yy)) goto l109; goto l108; + l109:; yy->__pos= yypos109; yy->__thunkpos= yythunkpos109; } yyprintf((stderr, " ok %s @ %s\n", "comment", yy->__buf+yy->__pos)); return 1; - l96:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l107:; 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 yypos101= yy->__pos, yythunkpos101= yy->__thunkpos; if (!yy_server_rule(yy)) goto l102; goto l101; - l102:; yy->__pos= yypos101; yy->__thunkpos= yythunkpos101; if (!yy_auth_rule(yy)) goto l103; goto l101; - l103:; yy->__pos= yypos101; yy->__thunkpos= yythunkpos101; if (!yy_logfile(yy)) goto l104; goto l101; - l104:; yy->__pos= yypos101; yy->__thunkpos= yythunkpos101; if (!yy_pidlogfile(yy)) goto l105; goto l101; - l105:; yy->__pos= yypos101; yy->__thunkpos= yythunkpos101; if (!yy_logcommon(yy)) goto l100; + { int yypos112= yy->__pos, yythunkpos112= yy->__thunkpos; if (!yy_server_rule(yy)) goto l113; goto l112; + l113:; yy->__pos= yypos112; yy->__thunkpos= yythunkpos112; if (!yy_auth_rule(yy)) goto l114; goto l112; + l114:; yy->__pos= yypos112; yy->__thunkpos= yythunkpos112; if (!yy_logfile(yy)) goto l115; goto l112; + l115:; yy->__pos= yypos112; yy->__thunkpos= yythunkpos112; if (!yy_pidlogfile(yy)) goto l116; goto l112; + l116:; yy->__pos= yypos112; yy->__thunkpos= yythunkpos112; if (!yy_logcommon(yy)) goto l111; } - l101:; + l112:; yyprintf((stderr, " ok %s @ %s\n", "command", yy->__buf+yy->__pos)); return 1; - l100:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l111:; 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 l106; - l107:; - { int yypos108= yy->__pos, yythunkpos108= 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 l108; goto l107; - l108:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108; + 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 l117; + l118:; + { int yypos119= yy->__pos, yythunkpos119= 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 l119; goto l118; + l119:; yy->__pos= yypos119; yy->__thunkpos= yythunkpos119; } yyprintf((stderr, " ok %s @ %s\n", "_", yy->__buf+yy->__pos)); return 1; - l106:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l117:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "_", yy->__buf+yy->__pos)); return 0; } @@ -1207,71 +1244,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 l109; +if (!(YY_BEGIN)) goto l120; #undef yytext #undef yyleng } - { int yypos112= yy->__pos, yythunkpos112= yy->__thunkpos; if (!yy_eol(yy)) goto l112; goto l109; - l112:; yy->__pos= yypos112; yy->__thunkpos= yythunkpos112; - } if (!yymatchDot(yy)) goto l109; - l110:; - { int yypos111= yy->__pos, yythunkpos111= yy->__thunkpos; - { int yypos113= yy->__pos, yythunkpos113= yy->__thunkpos; if (!yy_eol(yy)) goto l113; goto l111; - l113:; yy->__pos= yypos113; yy->__thunkpos= yythunkpos113; - } if (!yymatchDot(yy)) goto l111; goto l110; - l111:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111; + { int yypos123= yy->__pos, yythunkpos123= yy->__thunkpos; if (!yy_eol(yy)) goto l123; goto l120; + l123:; yy->__pos= yypos123; yy->__thunkpos= yythunkpos123; + } if (!yymatchDot(yy)) goto l120; + l121:; + { int yypos122= yy->__pos, yythunkpos122= yy->__thunkpos; + { int yypos124= yy->__pos, yythunkpos124= yy->__thunkpos; if (!yy_eol(yy)) goto l124; goto l122; + l124:; yy->__pos= yypos124; yy->__thunkpos= yythunkpos124; + } if (!yymatchDot(yy)) goto l122; goto l121; + l122:; yy->__pos= yypos122; yy->__thunkpos= yythunkpos122; } yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l109; +if (!(YY_END)) goto l120; #undef yytext #undef yyleng - } if (!yy_eol(yy)) goto l109; yyDo(yy, yy_1_invalid_syntax, yy->__begin, yy->__end); + } if (!yy_eol(yy)) goto l120; yyDo(yy, yy_1_invalid_syntax, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "invalid_syntax", yy->__buf+yy->__pos)); return 1; - l109:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l120:; 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 yypos115= yy->__pos, yythunkpos115= yy->__thunkpos; - { int yypos117= yy->__pos, yythunkpos117= yy->__thunkpos; if (!yymatchChar(yy, '\r')) goto l117; goto l118; - l117:; yy->__pos= yypos117; yy->__thunkpos= yythunkpos117; + { int yypos126= yy->__pos, yythunkpos126= yy->__thunkpos; + { int yypos128= yy->__pos, yythunkpos128= yy->__thunkpos; if (!yymatchChar(yy, '\r')) goto l128; goto l129; + l128:; yy->__pos= yypos128; yy->__thunkpos= yythunkpos128; } - l118:; if (!yymatchChar(yy, '\n')) goto l116; goto l115; - l116:; yy->__pos= yypos115; yy->__thunkpos= yythunkpos115; if (!yy_eof(yy)) goto l114; + l129:; if (!yymatchChar(yy, '\n')) goto l127; goto l126; + l127:; yy->__pos= yypos126; yy->__thunkpos= yythunkpos126; if (!yy_eof(yy)) goto l125; } - l115:; + l126:; yyprintf((stderr, " ok %s @ %s\n", "eol", yy->__buf+yy->__pos)); return 1; - l114:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l125:; 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 yypos120= yy->__pos, yythunkpos120= yy->__thunkpos; if (!yy__(yy)) goto l120; goto l121; - l120:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; + { int yypos131= yy->__pos, yythunkpos131= yy->__thunkpos; if (!yy__(yy)) goto l131; goto l132; + l131:; yy->__pos= yypos131; yy->__thunkpos= yythunkpos131; } - l121:; - { int yypos122= yy->__pos, yythunkpos122= yy->__thunkpos; if (!yy_command(yy)) goto l122; - { int yypos124= yy->__pos, yythunkpos124= yy->__thunkpos; if (!yy__(yy)) goto l124; goto l125; - l124:; yy->__pos= yypos124; yy->__thunkpos= yythunkpos124; + l132:; + { int yypos133= yy->__pos, yythunkpos133= yy->__thunkpos; if (!yy_command(yy)) goto l133; + { int yypos135= yy->__pos, yythunkpos135= yy->__thunkpos; if (!yy__(yy)) goto l135; goto l136; + l135:; yy->__pos= yypos135; yy->__thunkpos= yythunkpos135; } - l125:; goto l123; - l122:; yy->__pos= yypos122; yy->__thunkpos= yythunkpos122; + l136:; goto l134; + l133:; yy->__pos= yypos133; yy->__thunkpos= yythunkpos133; } - l123:; - { int yypos126= yy->__pos, yythunkpos126= yy->__thunkpos; if (!yy_comment(yy)) goto l126; goto l127; - l126:; yy->__pos= yypos126; yy->__thunkpos= yythunkpos126; + l134:; + { int yypos137= yy->__pos, yythunkpos137= yy->__thunkpos; if (!yy_comment(yy)) goto l137; goto l138; + l137:; yy->__pos= yypos137; yy->__thunkpos= yythunkpos137; } - l127:; + l138:; yyprintf((stderr, " ok %s @ %s\n", "line", yy->__buf+yy->__pos)); return 1; - l119:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l130:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "line", yy->__buf+yy->__pos)); return 0; } @@ -1280,20 +1317,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; - l128:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l139:; 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")); - l130:; - { int yypos131= yy->__pos, yythunkpos131= yy->__thunkpos; if (!yy_sol(yy)) goto l131; - { int yypos132= yy->__pos, yythunkpos132= yy->__thunkpos; if (!yy_line(yy)) goto l133; if (!yy_eol(yy)) goto l133; goto l132; - l133:; yy->__pos= yypos132; yy->__thunkpos= yythunkpos132; if (!yy_invalid_syntax(yy)) goto l131; + l141:; + { int yypos142= yy->__pos, yythunkpos142= yy->__thunkpos; if (!yy_sol(yy)) goto l142; + { int yypos143= yy->__pos, yythunkpos143= yy->__thunkpos; if (!yy_line(yy)) goto l144; if (!yy_eol(yy)) goto l144; goto l143; + l144:; yy->__pos= yypos143; yy->__thunkpos= yythunkpos143; if (!yy_invalid_syntax(yy)) goto l142; } - l132:; goto l130; - l131:; yy->__pos= yypos131; yy->__thunkpos= yythunkpos131; + l143:; goto l141; + l142:; yy->__pos= yypos142; yy->__thunkpos= yythunkpos142; } yyprintf((stderr, " ok %s @ %s\n", "file", yy->__buf+yy->__pos)); return 1; @@ -1346,7 +1383,7 @@ YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx) } #endif -#line 160 "parse.peg" +#line 162 "parse.peg" void parseConfiguration(char const *file) diff --git a/parse.peg b/parse.peg index cae69b2..a418f10 100644 --- a/parse.peg +++ b/parse.peg @@ -139,11 +139,12 @@ invalid_syntax = < (!eol .)+ > eol } service = name -address = ipv4 | hostname # TODO: IPV6 +address = ipv4 | ipv6 | hostname # TODO: IPV6 pattern = [0-9*?]+ ('.' [0-9*?]+ ('.' [0-9*?]+ ('.' [0-9*?]+)?)?)? number = digit+ ipv4 = number '.' number '.' number '.' number | '0' +ipv6 = (hexdigit | ':')+ | '[' ipv6 ']' hostname = ([-0-9a-zA-Z_]+ '.')* [a-zA-Z][-0-9a-zA-Z_]* '.'? @@ -153,6 +154,7 @@ filename = '"' [^"]+ '"' - = [ \t]+ digit = [0-9] +hexdigit = [0-9a-fA-F] sol = { ++yy->currentLine; } eol = '\r'? '\n' | eof eof = '\0' diff --git a/rinetd.c b/rinetd.c index 3b0b66e..adb5f7e 100644 --- a/rinetd.c +++ b/rinetd.c @@ -858,14 +858,17 @@ static int checkConnectionAllowed(ConnectionInfo const *cnx) static int getAddress(char const *host, struct in_addr *iaddr) { /* If this is an IP address, use inet_addr() */ - int is_ipaddr = 1; + int is_ipv4 = 1, is_ipv6 = 0; for (char const *p = host; *p; ++p) { - if (!isdigit(*p) && *p != '.') { - is_ipaddr = 0; - break; - } + is_ipv6 |= (*p == ':' || *p == '[' || *p == ']'); + is_ipv4 &= (isdigit(*p) || *p == '.'); } - if (is_ipaddr) { + if (is_ipv6) { + fprintf(stderr, "IPv6 addresses are not supported yet: %s\n", host); + return -1; + } + + if (is_ipv4) { iaddr->s_addr = inet_addr(host); return 0; } From 44f973d9fd8b7b45e921e6e94c149b862656d4e2 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 13 Feb 2021 18:43:33 +0100 Subject: [PATCH 02/16] Allow DNS labels to start with an underscore. --- src/parse.peg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/parse.peg b/src/parse.peg index 6a24d65..81366ad 100644 --- a/src/parse.peg +++ b/src/parse.peg @@ -141,7 +141,7 @@ invalid_syntax = < (!eol .)+ > eol } service = name -address = ipv4 | ipv6 | hostname # TODO: IPV6 +address = ipv4 | ipv6 | hostname pattern = [0-9*?]+ ('.' [0-9*?]+ ('.' [0-9*?]+ ('.' [0-9*?]+)?)?)? number = digit+ @@ -150,14 +150,15 @@ ipv6 = (hexdigit | ':')+ | '[' ipv6 ']' hostname = (label '.')* name '.'? -name = [a-zA-Z_] [-a-zA-Z0-9_]* -label = [0-9]* name +name = id ('-' | id | digit)* +label = (id | digit) ('-' | id | digit)* # DNS labels may have digits filename = '"' [^"]+ '"' | [^ \t\r\n]+ - = [ \t]+ digit = [0-9] hexdigit = [0-9a-fA-F] +id = [a-zA-Z_] sol = { ++yy->currentLine; } eol = '\r'? '\n' | eof eof = '\0' From 4f64342ed5c39ce3ad01d90d3ce29e2f413ebc0c Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 13 Feb 2021 21:37:11 +0100 Subject: [PATCH 03/16] 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); From a5905bbcea6b17ebf3d9161e808320de708a6e22 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 00:49:31 +0100 Subject: [PATCH 04/16] Fix Windows build. --- rinetd.vcxproj | 3 +++ src/net.h | 2 ++ src/rinetd.c | 1 + 3 files changed, 6 insertions(+) diff --git a/rinetd.vcxproj b/rinetd.vcxproj index 2bca0e6..7acde11 100644 --- a/rinetd.vcxproj +++ b/rinetd.vcxproj @@ -33,6 +33,9 @@ + + + 15.0 {3F1D9D58-3205-48E9-9C93-557291A45D74} diff --git a/src/net.h b/src/net.h index 7835d88..8eb23ae 100644 --- a/src/net.h +++ b/src/net.h @@ -12,6 +12,8 @@ /* Define this to a reasonably large value */ # define FD_SETSIZE 4096 # include +# include +# include # include #else # include diff --git a/src/rinetd.c b/src/rinetd.c index 940e832..09639e3 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -654,6 +654,7 @@ static void handleAccept(ServerInfo const *srv) SOCKET nfd; if (srv->fromProto == protoTcp) { /* In TCP mode, get remote address using accept(). */ + // FIXME IPv6: need to reuse addrlen from the bind() call nfd = accept(srv->fd, &addr, &addrlen); if (nfd == INVALID_SOCKET) { syslog(LOG_ERR, "accept(%llu): %m\n", (long long unsigned int)srv->fd); From f7cd21f91f5d4540bb61eba39484d230780ecc25 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 07:51:46 +0100 Subject: [PATCH 05/16] Fix getaddrinfo() hint initialisation issues. --- src/rinetd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rinetd.c b/src/rinetd.c index 09639e3..472d7ac 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -276,6 +276,7 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto, struct addrinfo hints = { .ai_family = AF_UNSPEC, + .ai_protocol = bindProto == protoTcp ? IPPROTO_TCP : IPPROTO_UDP, .ai_socktype = bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM, .ai_flags = AI_PASSIVE, }; @@ -287,9 +288,7 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto, } 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); + si.fd = socket(it->ai_family, it->ai_socktype, it->ai_protocol); if (si.fd == INVALID_SOCKET) { syslog(LOG_ERR, "couldn't create server socket! (%m)\n"); freeaddrinfo(servinfo); From 0ef4f1042fb1868c1b68a439a3ca5f2caa9e0607 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 07:52:51 +0100 Subject: [PATCH 06/16] Add a helper function to retrieve port from addrinfo. --- src/net.c | 15 ++++++++++++--- src/net.h | 4 +++- src/rinetd.c | 12 +++++------- src/types.h | 5 +++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/net.c b/src/net.c index 85f7878..6688bed 100644 --- a/src/net.c +++ b/src/net.c @@ -1,6 +1,6 @@ /* Copyright © 1997—1999 Thomas Boutell and Boutell.Com, Inc. - © 2003—2017 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 @@ -12,8 +12,7 @@ #include "net.h" -void setSocketDefaults(SOCKET fd) -{ +void setSocketDefaults(SOCKET fd) { /* Make socket non-blocking (FIXME: this uses legacy API) */ FIONBIO_ARG_T ioctltmp = 1; #if _WIN32 @@ -33,3 +32,13 @@ void setSocketDefaults(SOCKET fd) #endif } +uint16_t getPort(struct addrinfo* ai) { + switch (ai->ai_family) { + case AF_INET: + return ntohs(((struct sockaddr_in*)ai->ai_addr)->sin_port); + case AF_INET6: + return ntohs(((struct sockaddr_in6*)ai->ai_addr)->sin6_port); + default: + return 0; + } +} diff --git a/src/net.h b/src/net.h index 8eb23ae..c486959 100644 --- a/src/net.h +++ b/src/net.h @@ -24,6 +24,8 @@ # include #endif +#include + #if defined HAVE_ERRNO_H # include #endif @@ -79,4 +81,4 @@ static inline int GetLastError(void) { #endif /* _WIN32 */ void setSocketDefaults(SOCKET fd); - +uint16_t getPort(struct addrinfo* ai); diff --git a/src/rinetd.c b/src/rinetd.c index 472d7ac..3b0fa38 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -80,7 +80,7 @@ int logFormatCommon = 0; FILE *logFile = NULL; char const *logMessages[] = { - "unknown-error", + "unknown-error", "done-local-closed", "done-remote-closed", "accept-failed -", @@ -211,6 +211,7 @@ static void clearConfiguration(void) { } free(srv->fromHost); free(srv->toHost); + freeaddrinfo(srv->fromAddrInfo); } /* Free memory associated with previous set. */ free(seInfo); @@ -296,7 +297,7 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto, } int tmp = 1; - setsockopt(si.fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &tmp, sizeof(tmp)); + setsockopt(si.fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&tmp, sizeof(tmp)); 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", @@ -320,12 +321,9 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto, 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); + si.fromAddrInfo = it; break; } - freeaddrinfo(servinfo); if (getAddress(connectAddress, &si.localAddr) < 0) { /* Warn -- don't exit. */ @@ -1006,7 +1004,7 @@ static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int resul uint16_t fromPort = 0, toPort = 0; if (srv != NULL) { fromHost = srv->fromHost; - fromPort = srv->fromPort; + fromPort = getPort(srv->fromAddrInfo); toHost = srv->toHost; toPort = srv->toPort; } diff --git a/src/types.h b/src/types.h index 6b836c7..4152e0d 100644 --- a/src/types.h +++ b/src/types.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 @@ -41,7 +41,8 @@ struct _server_info { /* In ASCII and local byte order, for logging purposes */ char *fromHost, *toHost; - int16_t fromPort, toPort; + struct addrinfo *fromAddrInfo; + int16_t toPort; protocolType fromProto, toProto; /* Offset and count into list of allow and deny rules. Any rules From 7ef50421c0417791f2e92ac201a1b19a7b061492 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 08:06:02 +0100 Subject: [PATCH 07/16] Remove the protocolType enum in favour of IPPROTO_TCP/IPPROTO_UDP. --- src/parse.c | 8 +++---- src/parse.peg | 8 +++---- src/rinetd.c | 60 +++++++++++++++++++++++++-------------------------- src/rinetd.h | 4 ++-- src/types.h | 10 ++------- 5 files changed, 42 insertions(+), 48 deletions(-) diff --git a/src/parse.c b/src/parse.c index 40964a4..616024d 100644 --- a/src/parse.c +++ b/src/parse.c @@ -493,7 +493,7 @@ YY_ACTION(void) yy_3_proto(yycontext *yy, char *yytext, int yyleng) yyprintf((stderr, "do yy_3_proto\n")); { #line 88 - yy->tmpProto = protoTcp; ; + yy->tmpProto = IPPROTO_TCP; ; } #undef yythunkpos #undef yypos @@ -507,7 +507,7 @@ YY_ACTION(void) yy_2_proto(yycontext *yy, char *yytext, int yyleng) yyprintf((stderr, "do yy_2_proto\n")); { #line 87 - yy->tmpProto = protoUdp; ; + yy->tmpProto = IPPROTO_UDP; ; } #undef yythunkpos #undef yypos @@ -521,7 +521,7 @@ YY_ACTION(void) yy_1_proto(yycontext *yy, char *yytext, int yyleng) yyprintf((stderr, "do yy_1_proto\n")); { #line 86 - yy->tmpProto = protoTcp; ; + yy->tmpProto = IPPROTO_TCP; ; } #undef yythunkpos #undef yypos @@ -550,7 +550,7 @@ YY_ACTION(void) yy_1_full_port(yycontext *yy, char *yytext, int yyleng) { #line 74 - char const *proto = yy->tmpProto == protoTcp ? "tcp" : "udp"; + char const *proto = yy->tmpProto == IPPROTO_TCP ? "tcp" : "udp"; struct servent *service = getservbyname(yy->tmpPort, proto); int port = service ? ntohs(service->s_port) : atoi(yy->tmpPort); if (port <= 0 || port >= 65536) { diff --git a/src/parse.peg b/src/parse.peg index 092ed01..4e24d32 100644 --- a/src/parse.peg +++ b/src/parse.peg @@ -72,7 +72,7 @@ option-source = "src" -? "=" -? < address > { yy->sourceAddress = strdu full-port = port proto { - char const *proto = yy->tmpProto == protoTcp ? "tcp" : "udp"; + char const *proto = yy->tmpProto == IPPROTO_TCP ? "tcp" : "udp"; struct servent *service = getservbyname(yy->tmpPort, proto); int port = service ? ntohs(service->s_port) : atoi(yy->tmpPort); if (port <= 0 || port >= 65536) { @@ -83,9 +83,9 @@ full-port = port proto } port = < (number | service) > { yy->tmpPort = strdup(yytext); } -proto = '/tcp' { yy->tmpProto = protoTcp; } - | '/udp' { yy->tmpProto = protoUdp; } - | '' { yy->tmpProto = protoTcp; } +proto = '/tcp' { yy->tmpProto = IPPROTO_TCP; } + | '/udp' { yy->tmpProto = IPPROTO_UDP; } + | '' { yy->tmpProto = IPPROTO_TCP; } auth-rule = auth-key - < pattern > { diff --git a/src/rinetd.c b/src/rinetd.c index 3b0fa38..0a0d7a4 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -253,16 +253,16 @@ static void readConfiguration(char const *file) { } } -void addServer(char *bindAddress, char *bindPort, protocolType bindProto, - char *connectAddress, uint16_t connectPort, protocolType connectProto, +void addServer(char *bindAddress, char *bindPort, int bindProtocol, + char *connectAddress, uint16_t connectPort, int connectProtocol, int serverTimeout, char *sourceAddress) { ServerInfo si = { .fromHost = bindAddress, - .fromProto = bindProto, + .fromProtocol = bindProtocol, .toHost = connectAddress, .toPort = connectPort, - .toProto = connectProto, + .toProtocol = connectProtocol, .serverTimeout = serverTimeout, }; @@ -277,8 +277,8 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto, struct addrinfo hints = { .ai_family = AF_UNSPEC, - .ai_protocol = bindProto == protoTcp ? IPPROTO_TCP : IPPROTO_UDP, - .ai_socktype = bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM, + .ai_protocol = bindProtocol, + .ai_socktype = bindProtocol == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, .ai_flags = AI_PASSIVE, }; struct addrinfo *servinfo; @@ -307,7 +307,7 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto, exit(1); } - if (bindProto == protoTcp) { + if (bindProtocol == IPPROTO_TCP) { 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", @@ -360,7 +360,7 @@ static void setConnectionCount(int newCount) closesocket(coInfo[i].local.fd); } if (coInfo[i].remote.fd != INVALID_SOCKET) { - if (coInfo[i].remote.proto == protoTcp) + if (coInfo[i].remote.protocol == IPPROTO_TCP) closesocket(coInfo[i].remote.fd); } free(coInfo[i].local.buffer); @@ -476,7 +476,7 @@ static void selectPass(void) if (cnx->remote.recvPos < RINETD_BUFFER_SIZE) { FD_SET_EXT(cnx->remote.fd, readfds); /* For UDP connections, we need to handle timeouts */ - if (cnx->remote.proto == protoUdp) { + if (cnx->remote.protocol == IPPROTO_UDP) { long delay = (long)(cnx->remoteTimeout - now); timeout.tv_sec = delay <= 1 ? 1 : (delay < timeout.tv_sec || timeout.tv_sec == 0) ? delay @@ -496,7 +496,7 @@ static void selectPass(void) if (cnx->remote.fd != INVALID_SOCKET) { /* Do not read on remote UDP sockets, the server does it, but handle timeouts instead. */ - if (cnx->remote.proto == protoTcp) { + if (cnx->remote.protocol == IPPROTO_TCP) { if (FD_ISSET_EXT(cnx->remote.fd, readfds)) { handleRead(cnx, &cnx->remote, &cnx->local); } @@ -574,7 +574,7 @@ static void handleWrite(ConnectionInfo *cnx, Socket *socket, Socket *other_socke if (cnx->coClosing && (socket->sentPos == other_socket->recvPos)) { PERROR("rinetd: local closed and no more output"); logEvent(cnx, cnx->server, cnx->coLog); - if (socket->proto == protoTcp) + if (socket->protocol == IPPROTO_TCP) closesocket(socket->fd); socket->fd = INVALID_SOCKET; return; @@ -582,7 +582,7 @@ static void handleWrite(ConnectionInfo *cnx, Socket *socket, Socket *other_socke struct sockaddr const *addr = NULL; SOCKLEN_T addrlen = 0; - if (socket->proto == protoUdp && socket == &cnx->remote) { + if (socket->protocol == IPPROTO_UDP && socket == &cnx->remote) { addr = (struct sockaddr const*)&cnx->remoteAddress; addrlen = (SOCKLEN_T)sizeof(cnx->remoteAddress); } @@ -610,16 +610,16 @@ static void handleWrite(ConnectionInfo *cnx, Socket *socket, Socket *other_socke static void handleClose(ConnectionInfo *cnx, Socket *socket, Socket *other_socket) { cnx->coClosing = 1; - if (socket->proto == protoTcp) { + if (socket->protocol == IPPROTO_TCP) { /* One end fizzled out, so make sure we're all done with that */ closesocket(socket->fd); - } else /* if (socket->proto == protoUdp) */ { + } else /* if (socket->protocol == IPPROTO_UDP) */ { /* Nothing to do in UDP mode */ } socket->fd = INVALID_SOCKET; if (other_socket->fd != INVALID_SOCKET) { - if (other_socket->proto == protoTcp) { + if (other_socket->protocol == IPPROTO_TCP) { #if !defined __linux__ && !defined _WIN32 /* Now set up the other end for a polite closing */ @@ -630,7 +630,7 @@ static void handleClose(ConnectionInfo *cnx, Socket *socket, Socket *other_socke setsockopt(other_socket->fd, SOL_SOCKET, SO_SNDLOWAT, &arg, sizeof(arg)); #endif - } else /* if (other_socket->proto == protoUdp) */ { + } else /* if (other_socket->protocol == IPPROTO_UDP) */ { if (other_socket == &cnx->local) closesocket(other_socket->fd); other_socket->fd = INVALID_SOCKET; @@ -649,7 +649,7 @@ static void handleAccept(ServerInfo const *srv) SOCKLEN_T addrlen = sizeof(addr); SOCKET nfd; - if (srv->fromProto == protoTcp) { + if (srv->fromProtocol == IPPROTO_TCP) { /* In TCP mode, get remote address using accept(). */ // FIXME IPv6: need to reuse addrlen from the bind() call nfd = accept(srv->fd, &addr, &addrlen); @@ -660,7 +660,7 @@ static void handleAccept(ServerInfo const *srv) } setSocketDefaults(nfd); - } else /* if (srv->fromProto == protoUdp) */ { + } else /* if (srv->fromProtocol == IPPROTO_UDP) */ { /* In UDP mode, get remote address using recvfrom() and check for an existing connection from this client. We need to read a lot of data otherwise the datagram contents @@ -702,16 +702,16 @@ static void handleAccept(ServerInfo const *srv) } cnx->local.fd = INVALID_SOCKET; - cnx->local.proto = srv->toProto; + cnx->local.protocol = srv->toProtocol; cnx->local.recvPos = cnx->local.sentPos = 0; cnx->local.totalBytesIn = cnx->local.totalBytesOut = 0; cnx->remote.fd = nfd; - cnx->remote.proto = srv->fromProto; + cnx->remote.protocol = srv->fromProtocol; cnx->remote.recvPos = cnx->remote.sentPos = 0; cnx->remote.totalBytesIn = cnx->remote.totalBytesOut = 0; cnx->remoteAddress = *(struct sockaddr_in *)&addr; - if (srv->fromProto == protoUdp) + if (srv->fromProtocol == IPPROTO_UDP) cnx->remoteTimeout = time(NULL) + srv->serverTimeout; cnx->coClosing = 0; @@ -722,7 +722,7 @@ static void handleAccept(ServerInfo const *srv) if (logCode != logAllowed) { /* Local fd is not open yet, so only close the remote socket. */ - if (cnx->remote.proto == protoTcp) + if (cnx->remote.protocol == IPPROTO_TCP) closesocket(cnx->remote.fd); cnx->remote.fd = INVALID_SOCKET; logEvent(cnx, cnx->server, logCode); @@ -733,19 +733,19 @@ static void handleAccept(ServerInfo const *srv) This, too, is nonblocking. Why wait for anything when you don't have to? */ struct sockaddr_in saddr; - cnx->local.fd = srv->toProto == protoTcp - ? socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) - : socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + cnx->local.fd = socket(PF_INET, + srv->toProtocol == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, + srv->toProtocol); if (cnx->local.fd == INVALID_SOCKET) { syslog(LOG_ERR, "socket(): %m\n"); - if (cnx->remote.proto == protoTcp) + if (cnx->remote.protocol == IPPROTO_TCP) closesocket(cnx->remote.fd); cnx->remote.fd = INVALID_SOCKET; logEvent(cnx, srv, logLocalSocketFailed); return; } - if (srv->toProto == protoTcp) + if (srv->toProtocol == IPPROTO_TCP) setSocketDefaults(cnx->local.fd); /* Bind the local socket even if we use connect() later, so that @@ -771,7 +771,7 @@ static void handleAccept(ServerInfo const *srv) { PERROR("rinetd: connect"); closesocket(cnx->local.fd); - if (cnx->remote.proto == protoTcp) + if (cnx->remote.protocol == IPPROTO_TCP) closesocket(cnx->remote.fd); cnx->remote.fd = INVALID_SOCKET; cnx->local.fd = INVALID_SOCKET; @@ -781,7 +781,7 @@ static void handleAccept(ServerInfo const *srv) } /* Send a zero-size UDP packet to simulate a connection */ - if (srv->toProto == protoUdp) { + if (srv->toProtocol == IPPROTO_UDP) { int got = sendto(cnx->local.fd, NULL, 0, 0, (struct sockaddr const *)&saddr, (SOCKLEN_T)sizeof(saddr)); @@ -790,7 +790,7 @@ static void handleAccept(ServerInfo const *srv) } /* Send UDP data to the other socket */ - if (srv->fromProto == protoUdp) { + if (srv->fromProtocol == IPPROTO_UDP) { handleUdpRead(cnx, globalUdpBuffer, udpBytes); } diff --git a/src/rinetd.h b/src/rinetd.h index 4f2275e..2cbd6a3 100644 --- a/src/rinetd.h +++ b/src/rinetd.h @@ -46,7 +46,7 @@ extern FILE *logFile; /* Functions */ -void addServer(char *bindAddress, char *bindPort, protocolType bindProto, - char *connectAddress, uint16_t connectPort, protocolType connectProto, +void addServer(char *bindAddress, char *bindPort, int bindProtocol, + char *connectAddress, uint16_t connectPort, int connectProtocol, int serverTimeout, char *sourceAddress); diff --git a/src/types.h b/src/types.h index 4152e0d..e16417d 100644 --- a/src/types.h +++ b/src/types.h @@ -17,12 +17,6 @@ enum _rule_type { denyRule, }; -typedef enum _protocol_type protocolType; -enum _protocol_type { - protoTcp = 1, - protoUdp = 2, -}; - typedef struct _rule Rule; struct _rule { @@ -43,7 +37,7 @@ struct _server_info { char *fromHost, *toHost; struct addrinfo *fromAddrInfo; int16_t toPort; - protocolType fromProto, toProto; + int fromProtocol, toProtocol; /* Offset and count into list of allow and deny rules. Any rules prior to globalAllowRules and globalDenyRules are global rules. */ @@ -57,7 +51,7 @@ typedef struct _socket Socket; struct _socket { SOCKET fd; - protocolType proto; + int protocol; /* recv: received on this socket sent: sent through this socket from the other buffer */ int recvPos, sentPos; From f58db7ea8d198edf7ebb1330197bff3136891196 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 08:09:08 +0100 Subject: [PATCH 08/16] Add a helper function to retrieve socket type from protocol. --- src/net.c | 4 ++++ src/net.h | 1 + src/rinetd.c | 6 ++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/net.c b/src/net.c index 6688bed..045f23c 100644 --- a/src/net.c +++ b/src/net.c @@ -32,6 +32,10 @@ void setSocketDefaults(SOCKET fd) { #endif } +int getSocketType(int protocol) { + return protocol == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM; +} + uint16_t getPort(struct addrinfo* ai) { switch (ai->ai_family) { case AF_INET: diff --git a/src/net.h b/src/net.h index c486959..c41c4d0 100644 --- a/src/net.h +++ b/src/net.h @@ -81,4 +81,5 @@ static inline int GetLastError(void) { #endif /* _WIN32 */ void setSocketDefaults(SOCKET fd); +int getSocketType(int protocol); uint16_t getPort(struct addrinfo* ai); diff --git a/src/rinetd.c b/src/rinetd.c index 0a0d7a4..3197a29 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -278,7 +278,7 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, { .ai_family = AF_UNSPEC, .ai_protocol = bindProtocol, - .ai_socktype = bindProtocol == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, + .ai_socktype = getSocketType(bindProtocol), .ai_flags = AI_PASSIVE, }; struct addrinfo *servinfo; @@ -733,9 +733,7 @@ static void handleAccept(ServerInfo const *srv) This, too, is nonblocking. Why wait for anything when you don't have to? */ struct sockaddr_in saddr; - cnx->local.fd = socket(PF_INET, - srv->toProtocol == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, - srv->toProtocol); + cnx->local.fd = socket(PF_INET, getSocketType(srv->toProtocol), srv->toProtocol); if (cnx->local.fd == INVALID_SOCKET) { syslog(LOG_ERR, "socket(): %m\n"); if (cnx->remote.protocol == IPPROTO_TCP) From 26b0e63bf528245b299f06a2bd4ae1e565d2e8ef Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 08:24:08 +0100 Subject: [PATCH 09/16] Get rid of useless fromProtocol struct member. --- src/rinetd.c | 12 ++++++------ src/types.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rinetd.c b/src/rinetd.c index 3197a29..cb8323f 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -259,7 +259,6 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, { ServerInfo si = { .fromHost = bindAddress, - .fromProtocol = bindProtocol, .toHost = connectAddress, .toPort = connectPort, .toProtocol = connectProtocol, @@ -649,7 +648,7 @@ static void handleAccept(ServerInfo const *srv) SOCKLEN_T addrlen = sizeof(addr); SOCKET nfd; - if (srv->fromProtocol == IPPROTO_TCP) { + if (srv->fromAddrInfo->ai_protocol == IPPROTO_TCP) { /* In TCP mode, get remote address using accept(). */ // FIXME IPv6: need to reuse addrlen from the bind() call nfd = accept(srv->fd, &addr, &addrlen); @@ -660,7 +659,7 @@ static void handleAccept(ServerInfo const *srv) } setSocketDefaults(nfd); - } else /* if (srv->fromProtocol == IPPROTO_UDP) */ { + } else /* if (srv->fromAddrInfo->ai_protocol == IPPROTO_UDP) */ { /* In UDP mode, get remote address using recvfrom() and check for an existing connection from this client. We need to read a lot of data otherwise the datagram contents @@ -707,11 +706,11 @@ static void handleAccept(ServerInfo const *srv) cnx->local.totalBytesIn = cnx->local.totalBytesOut = 0; cnx->remote.fd = nfd; - cnx->remote.protocol = srv->fromProtocol; + cnx->remote.protocol = srv->fromAddrInfo->ai_protocol; cnx->remote.recvPos = cnx->remote.sentPos = 0; cnx->remote.totalBytesIn = cnx->remote.totalBytesOut = 0; cnx->remoteAddress = *(struct sockaddr_in *)&addr; - if (srv->fromProtocol == IPPROTO_UDP) + if (srv->fromAddrInfo->ai_protocol == IPPROTO_UDP) cnx->remoteTimeout = time(NULL) + srv->serverTimeout; cnx->coClosing = 0; @@ -733,6 +732,7 @@ static void handleAccept(ServerInfo const *srv) This, too, is nonblocking. Why wait for anything when you don't have to? */ struct sockaddr_in saddr; + /* FIXME: don’t forget to switch to PF_INET6 for IPv6. */ cnx->local.fd = socket(PF_INET, getSocketType(srv->toProtocol), srv->toProtocol); if (cnx->local.fd == INVALID_SOCKET) { syslog(LOG_ERR, "socket(): %m\n"); @@ -788,7 +788,7 @@ static void handleAccept(ServerInfo const *srv) } /* Send UDP data to the other socket */ - if (srv->fromProtocol == IPPROTO_UDP) { + if (srv->fromAddrInfo->ai_protocol == IPPROTO_UDP) { handleUdpRead(cnx, globalUdpBuffer, udpBytes); } diff --git a/src/types.h b/src/types.h index e16417d..6b6dce1 100644 --- a/src/types.h +++ b/src/types.h @@ -37,7 +37,7 @@ struct _server_info { char *fromHost, *toHost; struct addrinfo *fromAddrInfo; int16_t toPort; - int fromProtocol, toProtocol; + int toProtocol; /* Offset and count into list of allow and deny rules. Any rules prior to globalAllowRules and globalDenyRules are global rules. */ From c9de417f2ed84281c1b5ef25d8eea9ae0e1979ce Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 08:25:27 +0100 Subject: [PATCH 10/16] Use sockaddr_storage for IPv6 compatibility. --- src/rinetd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/rinetd.c b/src/rinetd.c index cb8323f..d4e89ec 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -644,14 +644,13 @@ static void handleAccept(ServerInfo const *srv) { int udpBytes = 0; - struct sockaddr addr; + struct sockaddr_storage addr; SOCKLEN_T addrlen = sizeof(addr); SOCKET nfd; if (srv->fromAddrInfo->ai_protocol == IPPROTO_TCP) { /* In TCP mode, get remote address using accept(). */ - // FIXME IPv6: need to reuse addrlen from the bind() call - nfd = accept(srv->fd, &addr, &addrlen); + nfd = accept(srv->fd, (struct sockaddr *)&addr, &addrlen); if (nfd == INVALID_SOCKET) { syslog(LOG_ERR, "accept(%llu): %m\n", (long long unsigned int)srv->fd); logEvent(NULL, srv, logAcceptFailed); @@ -666,7 +665,7 @@ static void handleAccept(ServerInfo const *srv) may be lost later. */ nfd = srv->fd; SSIZE_T ret = recvfrom(nfd, globalUdpBuffer, - sizeof(globalUdpBuffer), 0, &addr, &addrlen); + sizeof(globalUdpBuffer), 0, (struct sockaddr *)&addr, &addrlen); if (ret < 0) { if (GetLastError() == WSAEWOULDBLOCK) { return; From b7fcf65a973c49a2ad1b9746ccc53633b2140c08 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 08:44:49 +0100 Subject: [PATCH 11/16] Use getaddrinfo() to resolve source address. --- src/rinetd.c | 39 ++++++++++++++++++++++++--------------- src/types.h | 2 +- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/rinetd.c b/src/rinetd.c index d4e89ec..5e32985 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -212,6 +212,9 @@ static void clearConfiguration(void) { free(srv->fromHost); free(srv->toHost); freeaddrinfo(srv->fromAddrInfo); + if (srv->sourceAddrInfo) { + freeaddrinfo(srv->sourceAddrInfo); + } } /* Free memory associated with previous set. */ free(seInfo); @@ -265,13 +268,6 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, .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 */ struct addrinfo hints = { @@ -324,6 +320,21 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, break; } + /* Resolve source address if applicable */ + if (sourceAddress) { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC, + hints.ai_protocol = connectProtocol, + hints.ai_socktype = getSocketType(connectProtocol), + + ret = getaddrinfo(sourceAddress, NULL, &hints, &servinfo); + if (ret != 0) { + fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerror(ret)); + exit(1); + } + si.sourceAddrInfo = servinfo; + } + if (getAddress(connectAddress, &si.localAddr) < 0) { /* Warn -- don't exit. */ syslog(LOG_ERR, "host %s could not be resolved.\n", @@ -745,15 +756,13 @@ static void handleAccept(ServerInfo const *srv) if (srv->toProtocol == IPPROTO_TCP) setSocketDefaults(cnx->local.fd); - /* Bind the local socket even if we use connect() later, so that + /* Bind the local socket even though we use connect() later, so that we can specify a source address. */ - memset(&saddr, 0, sizeof(struct sockaddr_in)); - saddr.sin_family = AF_INET; - memcpy(&saddr.sin_addr, &srv->sourceAddr, sizeof(struct in_addr)); - saddr.sin_port = 0; - if (bind(cnx->local.fd, (struct sockaddr *)&saddr, - sizeof(saddr)) == SOCKET_ERROR) { - syslog(LOG_ERR, "bind(): %m\n"); + if (srv->sourceAddrInfo) { + if (bind(cnx->local.fd, srv->sourceAddrInfo->ai_addr, + srv->sourceAddrInfo->ai_addrlen) == SOCKET_ERROR) { + syslog(LOG_ERR, "bind(): %m\n"); + } } memset(&saddr, 0, sizeof(struct sockaddr_in)); diff --git a/src/types.h b/src/types.h index 6b6dce1..6e66fc3 100644 --- a/src/types.h +++ b/src/types.h @@ -31,7 +31,7 @@ struct _server_info { /* In network order, for network purposes */ struct in_addr localAddr; uint16_t localPort; - struct in_addr sourceAddr; + struct addrinfo *sourceAddrInfo; /* In ASCII and local byte order, for logging purposes */ char *fromHost, *toHost; From 79bafee414cb120fa923cb70744a5ba96e4963d2 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 09:04:08 +0100 Subject: [PATCH 12/16] Allow connecting to remote IPv6 addresses. --- src/parse.c | 75 +++++++++++++++++---------------------------------- src/parse.peg | 22 ++++----------- src/rinetd.c | 57 ++++++++++++++++++++------------------- src/rinetd.h | 3 +-- src/types.h | 9 ++----- 5 files changed, 62 insertions(+), 104 deletions(-) diff --git a/src/parse.c b/src/parse.c index 616024d..9961664 100644 --- a/src/parse.c +++ b/src/parse.c @@ -20,12 +20,10 @@ FILE *fp; \ int currentLine; \ int isAuthAllow; \ - char *tmpPort; \ - uint16_t tmpPortNum, tmpProto; \ - uint16_t connectPortNum; \ - int bindProto, connectProto; \ + char *tmpPort, *bindPort, *connectPort; \ + int tmpProto, bindProto, connectProto; \ int serverTimeout; \ - char *bindAddress, *bindPort, *connectAddress, *sourceAddress; + char *bindAddress, *connectAddress, *sourceAddress; #define YY_INPUT(yyctx, buf, result, max_size) \ { \ int yyc = fgetc(yyctx->fp); \ @@ -358,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 162 +#line 150 ++yy->currentLine; ; } #undef yythunkpos @@ -372,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 137 +#line 125 fprintf(stderr, "rinetd: invalid syntax at line %d: %s\n", yy->currentLine, yytext); @@ -390,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 132 +#line 120 logFormatCommon = 1; ; @@ -406,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 124 +#line 112 pidLogFileName = strdup(yytext); if (!pidLogFileName) { @@ -425,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 116 +#line 104 logFileName = strdup(yytext); if (!logFileName) { @@ -444,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 113 +#line 101 yy->isAuthAllow = (yytext[0] == 'a'); ; } #undef yythunkpos @@ -458,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 91 +#line 79 allRules = (Rule *) realloc(allRules, sizeof(Rule) * (allRulesCount + 1)); @@ -492,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 88 +#line 76 yy->tmpProto = IPPROTO_TCP; ; } #undef yythunkpos @@ -506,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 87 +#line 75 yy->tmpProto = IPPROTO_UDP; ; } #undef yythunkpos @@ -520,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 86 +#line 74 yy->tmpProto = IPPROTO_TCP; ; } #undef yythunkpos @@ -534,36 +532,13 @@ YY_ACTION(void) yy_1_port(yycontext *yy, char *yytext, int yyleng) #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_port\n")); { -#line 85 +#line 73 yy->tmpPort = strdup(yytext); ; } #undef yythunkpos #undef yypos #undef yy } -YY_ACTION(void) yy_1_full_port(yycontext *yy, char *yytext, int yyleng) -{ -#define __ yy->__ -#define yypos yy->__pos -#define yythunkpos yy->__thunkpos - yyprintf((stderr, "do yy_1_full_port\n")); - { -#line 74 - - char const *proto = yy->tmpProto == IPPROTO_TCP ? "tcp" : "udp"; - struct servent *service = getservbyname(yy->tmpPort, proto); - int port = service ? ntohs(service->s_port) : atoi(yy->tmpPort); - if (port <= 0 || port >= 65536) { - syslog(LOG_ERR, "port %s/%s missing or out of range\n", yy->tmpPort, proto); - PARSE_ERROR; - } - yy->tmpPortNum = (uint16_t)port; -; - } -#undef yythunkpos -#undef yypos -#undef yy -} YY_ACTION(void) yy_1_option_source(yycontext *yy, char *yytext, int yyleng) { #define __ yy->__ @@ -571,7 +546,7 @@ 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 71 +#line 69 yy->sourceAddress = strdup(yytext); ; } #undef yythunkpos @@ -585,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 70 +#line 68 yy->serverTimeout = atoi(yytext); ; } #undef yythunkpos @@ -599,8 +574,8 @@ 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 65 - yy->connectPortNum = yy->tmpPortNum; yy->connectProto = yy->tmpProto; ; +#line 63 + yy->connectPort = yy->tmpPort; yy->connectProto = yy->tmpProto; ; } #undef yythunkpos #undef yypos @@ -613,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 64 +#line 62 yy->bindPort = yy->tmpPort; yy->bindProto = yy->tmpProto; ; } #undef yythunkpos @@ -627,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 63 +#line 61 yy->connectAddress = strdup(yytext); ; } #undef yythunkpos @@ -641,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 62 +#line 60 yy->bindAddress = strdup(yytext); ; } #undef yythunkpos @@ -655,10 +630,10 @@ YY_ACTION(void) yy_1_server_rule(yycontext *yy, char *yytext, int yyleng) #define yythunkpos yy->__thunkpos yyprintf((stderr, "do yy_1_server_rule\n")); { -#line 53 +#line 51 addServer(yy->bindAddress, yy->bindPort, yy->bindProto, - yy->connectAddress, yy->connectPortNum, yy->connectProto, + yy->connectAddress, yy->connectPort, yy->connectProto, yy->serverTimeout > 0 ? yy->serverTimeout : RINETD_DEFAULT_UDP_TIMEOUT, yy->sourceAddress); yy->bindAddress = yy->connectAddress = yy->sourceAddress = NULL; @@ -1039,7 +1014,7 @@ YY_RULE(int) yy_option_list(yycontext *yy) } 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 l92; if (!yy_proto(yy)) goto l92; 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; yyprintf((stderr, " ok %s @ %s\n", "full_port", yy->__buf+yy->__pos)); return 1; l92:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; @@ -1415,7 +1390,7 @@ YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx) } #endif -#line 166 "parse.peg" +#line 154 "parse.peg" void parseConfiguration(char const *file) diff --git a/src/parse.peg b/src/parse.peg index 4e24d32..b0762d7 100644 --- a/src/parse.peg +++ b/src/parse.peg @@ -21,12 +21,10 @@ FILE *fp; \ int currentLine; \ int isAuthAllow; \ - char *tmpPort; \ - uint16_t tmpPortNum, tmpProto; \ - uint16_t connectPortNum; \ - int bindProto, connectProto; \ + char *tmpPort, *bindPort, *connectPort; \ + int tmpProto, bindProto, connectProto; \ int serverTimeout; \ - char *bindAddress, *bindPort, *connectAddress, *sourceAddress; + char *bindAddress, *connectAddress, *sourceAddress; #define YY_INPUT(yyctx, buf, result, max_size) \ { \ int yyc = fgetc(yyctx->fp); \ @@ -52,7 +50,7 @@ comment = "#" (!eol .)* server-rule = bind-address - bind-port - connect-address - connect-port (-? server-options)? { addServer(yy->bindAddress, yy->bindPort, yy->bindProto, - yy->connectAddress, yy->connectPortNum, yy->connectProto, + yy->connectAddress, yy->connectPort, yy->connectProto, yy->serverTimeout > 0 ? yy->serverTimeout : RINETD_DEFAULT_UDP_TIMEOUT, yy->sourceAddress); yy->bindAddress = yy->connectAddress = yy->sourceAddress = NULL; @@ -62,7 +60,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->bindPort = yy->tmpPort; yy->bindProto = yy->tmpProto; } -connect-port = full-port { yy->connectPortNum = yy->tmpPortNum; yy->connectProto = yy->tmpProto; } +connect-port = full-port { yy->connectPort = yy->tmpPort; yy->connectProto = yy->tmpProto; } server-options = "[" -? option-list -? "]" option-list = option (-? ',' -? option-list)? @@ -71,16 +69,6 @@ option-timeout = "timeout" -? "=" -? < number > { yy->serverTimeout = atoi( option-source = "src" -? "=" -? < address > { yy->sourceAddress = strdup(yytext); } full-port = port proto -{ - char const *proto = yy->tmpProto == IPPROTO_TCP ? "tcp" : "udp"; - struct servent *service = getservbyname(yy->tmpPort, proto); - int port = service ? ntohs(service->s_port) : atoi(yy->tmpPort); - if (port <= 0 || port >= 65536) { - syslog(LOG_ERR, "port %s/%s missing or out of range\n", yy->tmpPort, proto); - PARSE_ERROR; - } - yy->tmpPortNum = (uint16_t)port; -} port = < (number | service) > { yy->tmpPort = strdup(yytext); } proto = '/tcp' { yy->tmpProto = IPPROTO_TCP; } diff --git a/src/rinetd.c b/src/rinetd.c index 5e32985..fd91790 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -212,6 +212,7 @@ static void clearConfiguration(void) { free(srv->fromHost); free(srv->toHost); freeaddrinfo(srv->fromAddrInfo); + freeaddrinfo(srv->toAddrInfo); if (srv->sourceAddrInfo) { freeaddrinfo(srv->sourceAddrInfo); } @@ -257,14 +258,12 @@ static void readConfiguration(char const *file) { } void addServer(char *bindAddress, char *bindPort, int bindProtocol, - char *connectAddress, uint16_t connectPort, int connectProtocol, + char *connectAddress, char *connectPort, int connectProtocol, int serverTimeout, char *sourceAddress) { ServerInfo si = { .fromHost = bindAddress, .toHost = connectAddress, - .toPort = connectPort, - .toProtocol = connectProtocol, .serverTimeout = serverTimeout, }; @@ -320,7 +319,22 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, break; } - /* Resolve source address if applicable */ + /* Resolve destination address. */ + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_protocol = connectProtocol; + hints.ai_socktype = getSocketType(connectProtocol); + hints.ai_flags = AI_PASSIVE; + ret = getaddrinfo(connectAddress, connectPort, &hints, &servinfo); + if (ret != 0) { + fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerror(ret)); + freeaddrinfo(si.fromAddrInfo); + closesocket(si.fd); + exit(1); + } + si.toAddrInfo = servinfo; + + /* Resolve source address if applicable. */ if (sourceAddress) { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC, @@ -330,20 +344,13 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, ret = getaddrinfo(sourceAddress, NULL, &hints, &servinfo); if (ret != 0) { fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerror(ret)); + freeaddrinfo(si.fromAddrInfo); + freeaddrinfo(si.toAddrInfo); exit(1); } si.sourceAddrInfo = servinfo; } - if (getAddress(connectAddress, &si.localAddr) < 0) { - /* Warn -- don't exit. */ - syslog(LOG_ERR, "host %s could not be resolved.\n", - bindAddress); - closesocket(si.fd); - exit(1); - } - si.localPort = htons(connectPort); - #ifndef _WIN32 if (si.fd > maxfd) { maxfd = si.fd; @@ -711,7 +718,7 @@ static void handleAccept(ServerInfo const *srv) } cnx->local.fd = INVALID_SOCKET; - cnx->local.protocol = srv->toProtocol; + cnx->local.protocol = srv->toAddrInfo->ai_protocol; cnx->local.recvPos = cnx->local.sentPos = 0; cnx->local.totalBytesIn = cnx->local.totalBytesOut = 0; @@ -741,9 +748,8 @@ static void handleAccept(ServerInfo const *srv) /* Now open a connection to the local server. This, too, is nonblocking. Why wait for anything when you don't have to? */ - struct sockaddr_in saddr; - /* FIXME: don’t forget to switch to PF_INET6 for IPv6. */ - cnx->local.fd = socket(PF_INET, getSocketType(srv->toProtocol), srv->toProtocol); + struct addrinfo* to = srv->toAddrInfo; + cnx->local.fd = socket(to->ai_family, to->ai_socktype, to->ai_protocol); if (cnx->local.fd == INVALID_SOCKET) { syslog(LOG_ERR, "socket(): %m\n"); if (cnx->remote.protocol == IPPROTO_TCP) @@ -753,7 +759,7 @@ static void handleAccept(ServerInfo const *srv) return; } - if (srv->toProtocol == IPPROTO_TCP) + if (srv->toAddrInfo->ai_protocol == IPPROTO_TCP) setSocketDefaults(cnx->local.fd); /* Bind the local socket even though we use connect() later, so that @@ -765,12 +771,8 @@ static void handleAccept(ServerInfo const *srv) } } - memset(&saddr, 0, sizeof(struct sockaddr_in)); - saddr.sin_family = AF_INET; - memcpy(&saddr.sin_addr, &srv->localAddr, sizeof(struct in_addr)); - saddr.sin_port = srv->localPort; - if (connect(cnx->local.fd, (struct sockaddr *)&saddr, - sizeof(struct sockaddr_in)) == SOCKET_ERROR) + if (connect(cnx->local.fd, srv->toAddrInfo->ai_addr, + srv->toAddrInfo->ai_addrlen) == SOCKET_ERROR) { if ((GetLastError() != WSAEINPROGRESS) && (GetLastError() != WSAEWOULDBLOCK)) @@ -787,10 +789,9 @@ static void handleAccept(ServerInfo const *srv) } /* Send a zero-size UDP packet to simulate a connection */ - if (srv->toProtocol == IPPROTO_UDP) { + if (srv->toAddrInfo->ai_protocol == IPPROTO_UDP) { int got = sendto(cnx->local.fd, NULL, 0, 0, - (struct sockaddr const *)&saddr, - (SOCKLEN_T)sizeof(saddr)); + srv->toAddrInfo->ai_addr, srv->toAddrInfo->ai_addrlen); /* FIXME: we ignore errors here... is it safe? */ (void)got; } @@ -1012,7 +1013,7 @@ static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int resul fromHost = srv->fromHost; fromPort = getPort(srv->fromAddrInfo); toHost = srv->toHost; - toPort = srv->toPort; + toPort = getPort(srv->toAddrInfo); } if (result==logNotAllowed || result==logDenied) diff --git a/src/rinetd.h b/src/rinetd.h index 2cbd6a3..5512f25 100644 --- a/src/rinetd.h +++ b/src/rinetd.h @@ -47,6 +47,5 @@ extern FILE *logFile; /* Functions */ void addServer(char *bindAddress, char *bindPort, int bindProtocol, - char *connectAddress, uint16_t connectPort, int connectProtocol, + char *connectAddress, char *connectPort, int connectProtocol, int serverTimeout, char *sourceAddress); - diff --git a/src/types.h b/src/types.h index 6e66fc3..9261f84 100644 --- a/src/types.h +++ b/src/types.h @@ -29,15 +29,10 @@ struct _server_info { SOCKET fd; /* In network order, for network purposes */ - struct in_addr localAddr; - uint16_t localPort; - struct addrinfo *sourceAddrInfo; + struct addrinfo *fromAddrInfo, *toAddrInfo, *sourceAddrInfo; - /* In ASCII and local byte order, for logging purposes */ + /* In ASCII, for logging purposes */ char *fromHost, *toHost; - struct addrinfo *fromAddrInfo; - int16_t toPort; - int toProtocol; /* Offset and count into list of allow and deny rules. Any rules prior to globalAllowRules and globalDenyRules are global rules. */ From 7781e97734783bf0b02fd6dae69a3d3946326c44 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 09:18:49 +0100 Subject: [PATCH 13/16] Remove deprecated getAddress() function now that we use getaddrinfo() ubiquitously. --- src/rinetd.c | 54 ---------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/src/rinetd.c b/src/rinetd.c index fd91790..da5f6f7 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -119,7 +119,6 @@ static void handleClose(ConnectionInfo *cnx, Socket *socket, Socket *other_socke static void handleAccept(ServerInfo const *srv); static ConnectionInfo *findAvailableConnection(void); static void setConnectionCount(int newCount); -static int getAddress(char const *host, struct in_addr *iaddr); static int checkConnectionAllowed(ConnectionInfo const *cnx); static int readArgs (int argc, char **argv, RinetdOptions *options); @@ -872,59 +871,6 @@ static int checkConnectionAllowed(ConnectionInfo const *cnx) return logAllowed; } -static int getAddress(char const *host, struct in_addr *iaddr) -{ - /* If this is an IP address, use inet_addr() */ - int is_ipv4 = 1, is_ipv6 = 0; - for (char const *p = host; *p; ++p) { - is_ipv6 |= (*p == ':' || *p == '[' || *p == ']'); - is_ipv4 &= (isdigit(*p) || *p == '.'); - } - if (is_ipv6) { - fprintf(stderr, "IPv6 addresses are not supported yet: %s\n", host); - return -1; - } - - if (is_ipv4) { - iaddr->s_addr = inet_addr(host); - return 0; - } - - /* Otherwise, use gethostbyname() */ - struct hostent *h = gethostbyname(host); - if (h) { -#ifdef h_addr - memcpy(&iaddr->s_addr, h->h_addr, 4); -#else - memcpy(&iaddr->s_addr, h->h_addr_list[0], 4); -#endif - return 0; - } - - char const *msg = "(unknown DNS error)"; - switch (h_errno) - { - case HOST_NOT_FOUND: - msg = "The specified host is unknown."; - break; -#ifdef NO_DATA - case NO_DATA: -#else - case NO_ADDRESS: -#endif - msg = "The requested name is valid but does not have an IP address."; - break; - case NO_RECOVERY: - msg = "A non-recoverable name server error occurred."; - break; - case TRY_AGAIN: - msg = "A temporary error occurred on an authoritative name server. Try again later."; - break; - } - syslog(LOG_ERR, "While resolving `%s' got: %s\n", host, msg); - return -1; -} - #if !HAVE_SIGACTION && !_WIN32 RETSIGTYPE plumber(int s) { From 7790a617d8688188fb60ded3b64ffefdde42c83d Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 09:48:12 +0100 Subject: [PATCH 14/16] Remove all legacy IPv4 code. --- src/net.c | 21 +++++++++++++++++++++ src/net.h | 1 + src/rinetd.c | 21 ++++++++++++--------- src/types.h | 4 ++-- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/net.c b/src/net.c index 045f23c..dea9c6d 100644 --- a/src/net.c +++ b/src/net.c @@ -36,6 +36,27 @@ int getSocketType(int protocol) { return protocol == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM; } +int sameSocketAddress(struct sockaddr_storage *a, struct sockaddr_storage *b) { + if (a->ss_family != b->ss_family) + return 0; + + switch (a->ss_family) { + case AF_INET: { + struct sockaddr_in *a4 = (struct sockaddr_in *)a; + struct sockaddr_in *b4 = (struct sockaddr_in *)b; + return a4->sin_port == b4->sin_port + && a4->sin_addr.s_addr == b4->sin_addr.s_addr; + } + case AF_INET6: { + struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)a; + struct sockaddr_in6 *b6 = (struct sockaddr_in6 *)b; + return a6->sin6_port == b6->sin6_port + && a6->sin6_addr.s6_addr == b6->sin6_addr.s6_addr; + } + } + return 0; +} + uint16_t getPort(struct addrinfo* ai) { switch (ai->ai_family) { case AF_INET: diff --git a/src/net.h b/src/net.h index c41c4d0..a043093 100644 --- a/src/net.h +++ b/src/net.h @@ -82,4 +82,5 @@ static inline int GetLastError(void) { void setSocketDefaults(SOCKET fd); int getSocketType(int protocol); +int sameSocketAddress(struct sockaddr_storage *a, struct sockaddr_storage *b); uint16_t getPort(struct addrinfo* ai); diff --git a/src/rinetd.c b/src/rinetd.c index da5f6f7..08b0672 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -697,13 +697,10 @@ static void handleAccept(ServerInfo const *srv) udpBytes = (int)ret; + /* Look for an existing connection with the same remote host and port. */ for (int i = 0; i < coTotal; ++i) { ConnectionInfo *cnx = &coInfo[i]; - struct sockaddr_in *addr_in = (struct sockaddr_in *)&addr; - if (cnx->remote.fd == nfd - && cnx->remoteAddress.sin_family == addr_in->sin_family - && cnx->remoteAddress.sin_port == addr_in->sin_port - && cnx->remoteAddress.sin_addr.s_addr == addr_in->sin_addr.s_addr) { + if (cnx->remote.fd == nfd && sameSocketAddress(&cnx->remoteAddress, &addr)) { cnx->remoteTimeout = time(NULL) + srv->serverTimeout; handleUdpRead(cnx, globalUdpBuffer, udpBytes); return; @@ -717,15 +714,17 @@ static void handleAccept(ServerInfo const *srv) } cnx->local.fd = INVALID_SOCKET; + cnx->local.family = srv->toAddrInfo->ai_family; cnx->local.protocol = srv->toAddrInfo->ai_protocol; cnx->local.recvPos = cnx->local.sentPos = 0; cnx->local.totalBytesIn = cnx->local.totalBytesOut = 0; cnx->remote.fd = nfd; + cnx->remote.family = srv->fromAddrInfo->ai_family; cnx->remote.protocol = srv->fromAddrInfo->ai_protocol; cnx->remote.recvPos = cnx->remote.sentPos = 0; cnx->remote.totalBytesIn = cnx->remote.totalBytesOut = 0; - cnx->remoteAddress = *(struct sockaddr_in *)&addr; + cnx->remoteAddress = addr; if (srv->fromAddrInfo->ai_protocol == IPPROTO_UDP) cnx->remoteTimeout = time(NULL) + srv->serverTimeout; @@ -815,7 +814,10 @@ static void handleAccept(ServerInfo const *srv) static int checkConnectionAllowed(ConnectionInfo const *cnx) { ServerInfo const *srv = cnx->server; - char const *addressText = inet_ntoa(cnx->remoteAddress.sin_addr); + + char addressText[NI_MAXHOST]; + getnameinfo((struct sockaddr *)&cnx->remoteAddress, sizeof(cnx->remoteAddress), + addressText, sizeof(addressText), NULL, 0, NI_NUMERICHOST); /* 1. Check global allow rules. If there are no global allow rules, it's presumed OK at @@ -938,6 +940,7 @@ static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int resul thanks folks */ int timz; char tstr[1024]; + char addressText[NI_MAXHOST] = { '?' }; struct tm *t = get_gmtoff(&timz); char sign = (timz < 0 ? '-' : '+'); if (timz < 0) { @@ -945,10 +948,10 @@ static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int resul } strftime(tstr, sizeof(tstr), "%d/%b/%Y:%H:%M:%S ", t); - char const *addressText = "?"; int64_t bytesOut = 0, bytesIn = 0; if (cnx != NULL) { - addressText = inet_ntoa(cnx->remoteAddress.sin_addr); + getnameinfo((struct sockaddr *)&cnx->remoteAddress, sizeof(cnx->remoteAddress), + addressText, sizeof(addressText), NULL, 0, NI_NUMERICHOST); bytesOut = cnx->remote.totalBytesOut; bytesIn = cnx->remote.totalBytesIn; } diff --git a/src/types.h b/src/types.h index 9261f84..44d9fcb 100644 --- a/src/types.h +++ b/src/types.h @@ -46,7 +46,7 @@ typedef struct _socket Socket; struct _socket { SOCKET fd; - int protocol; + int family, protocol; /* recv: received on this socket sent: sent through this socket from the other buffer */ int recvPos, sentPos; @@ -58,7 +58,7 @@ typedef struct _connection_info ConnectionInfo; struct _connection_info { Socket remote, local; - struct sockaddr_in remoteAddress; + struct sockaddr_storage remoteAddress; time_t remoteTimeout; int coClosing; int coLog; From 4c5a7a1a22628a666610bf71a68ee44a4673e479 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 09:59:38 +0100 Subject: [PATCH 15/16] Fix deny/allow rules to support IPv6 addresses. --- src/parse.c | 532 +++++++++++++++++++++++++------------------------- src/parse.peg | 4 +- 2 files changed, 270 insertions(+), 266 deletions(-) diff --git a/src/parse.c b/src/parse.c index 9961664..1554c32 100644 --- a/src/parse.c +++ b/src/parse.c @@ -311,8 +311,8 @@ YY_LOCAL(void) yySet(yycontext *yy, char *text, int count) { yy->__val[count]= 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 */ +YY_RULE(int) yy_digit(yycontext *yy); /* 37 */ +YY_RULE(int) yy_hexdigit(yycontext *yy); /* 36 */ YY_RULE(int) yy_hostname(yycontext *yy); /* 35 */ YY_RULE(int) yy_ipv6(yycontext *yy); /* 34 */ YY_RULE(int) yy_ipv4(yycontext *yy); /* 33 */ @@ -685,24 +685,24 @@ YY_RULE(int) yy_label(yycontext *yy) 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 l11; - yyprintf((stderr, " ok %s @ %s\n", "hexdigit", yy->__buf+yy->__pos)); - return 1; - 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 l12; + 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 l11; yyprintf((stderr, " ok %s @ %s\n", "digit", yy->__buf+yy->__pos)); return 1; - l12:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l11:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "digit", 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 l12; + yyprintf((stderr, " ok %s @ %s\n", "hexdigit", yy->__buf+yy->__pos)); + return 1; + l12:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "hexdigit", 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")); @@ -736,7 +736,19 @@ YY_RULE(int) yy_ipv6(yycontext *yy) 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; + l20:; yy->__pos= yypos19; yy->__thunkpos= yythunkpos19; if (!yymatchChar(yy, '[')) goto l18; + { int yypos29= yy->__pos, yythunkpos29= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l30; goto l29; + l30:; yy->__pos= yypos29; yy->__thunkpos= yythunkpos29; if (!yymatchChar(yy, ':')) goto l18; + } + l29:; + l27:; + { int yypos28= yy->__pos, yythunkpos28= yy->__thunkpos; + { int yypos31= yy->__pos, yythunkpos31= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l32; goto l31; + l32:; yy->__pos= yypos31; yy->__thunkpos= yythunkpos31; if (!yymatchChar(yy, ':')) goto l28; + } + l31:; goto l27; + l28:; yy->__pos= yypos28; yy->__thunkpos= yythunkpos28; + } if (!yymatchChar(yy, ']')) goto l18; } l19:; yyprintf((stderr, " ok %s @ %s\n", "ipv6", yy->__buf+yy->__pos)); @@ -748,89 +760,81 @@ YY_RULE(int) yy_ipv6(yycontext *yy) YY_RULE(int) yy_ipv4(yycontext *yy) { int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyprintf((stderr, "%s\n", "ipv4")); - { 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; + { int yypos34= yy->__pos, yythunkpos34= yy->__thunkpos; if (!yy_number(yy)) goto l35; if (!yymatchChar(yy, '.')) goto l35; if (!yy_number(yy)) goto l35; if (!yymatchChar(yy, '.')) goto l35; if (!yy_number(yy)) goto l35; if (!yymatchChar(yy, '.')) goto l35; if (!yy_number(yy)) goto l35; goto l34; + l35:; yy->__pos= yypos34; yy->__thunkpos= yythunkpos34; if (!yymatchChar(yy, '0')) goto l33; } - l28:; + l34:; yyprintf((stderr, " ok %s @ %s\n", "ipv4", yy->__buf+yy->__pos)); return 1; - l27:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l33:; 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 (!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; + yyprintf((stderr, "%s\n", "name")); if (!yy_id(yy)) goto l36; + l37:; + { int yypos38= yy->__pos, yythunkpos38= yy->__thunkpos; + { int yypos39= yy->__pos, yythunkpos39= yy->__thunkpos; if (!yymatchChar(yy, '-')) goto l40; goto l39; + l40:; yy->__pos= yypos39; yy->__thunkpos= yythunkpos39; if (!yy_id(yy)) goto l41; goto l39; + l41:; yy->__pos= yypos39; yy->__thunkpos= yythunkpos39; if (!yy_digit(yy)) goto l38; } - l33:; goto l31; - l32:; yy->__pos= yypos32; yy->__thunkpos= yythunkpos32; + l39:; goto l37; + l38:; yy->__pos= yypos38; yy->__thunkpos= yythunkpos38; } yyprintf((stderr, " ok %s @ %s\n", "name", yy->__buf+yy->__pos)); return 1; - l30:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l36:; 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 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; + { int yypos43= yy->__pos, yythunkpos43= yy->__thunkpos; if (!yymatchChar(yy, '"')) goto l44; 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 l44; + l45:; + { int yypos46= yy->__pos, yythunkpos46= 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 l46; goto l45; + l46:; yy->__pos= yypos46; yy->__thunkpos= yythunkpos46; + } if (!yymatchChar(yy, '"')) goto l44; goto l43; + l44:; yy->__pos= yypos43; yy->__thunkpos= yythunkpos43; 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; + l47:; + { int yypos48= yy->__pos, yythunkpos48= 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 l48; goto l47; + l48:; yy->__pos= yypos48; yy->__thunkpos= yythunkpos48; } } - l37:; + l43:; yyprintf((stderr, " ok %s @ %s\n", "filename", yy->__buf+yy->__pos)); return 1; - l36:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l42:; 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 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; + yyprintf((stderr, "%s\n", "pattern")); + { int yypos52= yy->__pos, yythunkpos52= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l53; goto l52; + l53:; yy->__pos= yypos52; yy->__thunkpos= yythunkpos52; if (!yymatchChar(yy, '[')) goto l54; goto l52; + l54:; yy->__pos= yypos52; yy->__thunkpos= yythunkpos52; if (!yymatchChar(yy, ']')) goto l55; goto l52; + l55:; yy->__pos= yypos52; yy->__thunkpos= yythunkpos52; if (!yymatchChar(yy, ':')) goto l56; goto l52; + l56:; yy->__pos= yypos52; yy->__thunkpos= yythunkpos52; if (!yymatchChar(yy, '.')) goto l57; goto l52; + l57:; yy->__pos= yypos52; yy->__thunkpos= yythunkpos52; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\000\200\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; } - { 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; - } - { 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; + l50:; + { int yypos51= yy->__pos, yythunkpos51= yy->__thunkpos; + { int yypos58= yy->__pos, yythunkpos58= yy->__thunkpos; if (!yy_hexdigit(yy)) goto l59; goto l58; + l59:; yy->__pos= yypos58; yy->__thunkpos= yythunkpos58; if (!yymatchChar(yy, '[')) goto l60; goto l58; + l60:; yy->__pos= yypos58; yy->__thunkpos= yythunkpos58; if (!yymatchChar(yy, ']')) goto l61; goto l58; + l61:; yy->__pos= yypos58; yy->__thunkpos= yythunkpos58; if (!yymatchChar(yy, ':')) goto l62; goto l58; + l62:; yy->__pos= yypos58; yy->__thunkpos= yythunkpos58; if (!yymatchChar(yy, '.')) goto l63; goto l58; + l63:; yy->__pos= yypos58; yy->__thunkpos= yythunkpos58; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\004\000\200\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 l51; } - { 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; + l58:; goto l50; + l51:; yy->__pos= yypos51; yy->__thunkpos= yythunkpos51; } - 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; - l43:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l49:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "pattern", yy->__buf+yy->__pos)); return 0; } @@ -839,46 +843,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 l58; +if (!(YY_BEGIN)) goto l64; #undef yytext #undef yyleng } - { 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; + { int yypos65= yy->__pos, yythunkpos65= yy->__thunkpos; if (!yymatchString(yy, "allow")) goto l66; goto l65; + l66:; yy->__pos= yypos65; yy->__thunkpos= yythunkpos65; if (!yymatchString(yy, "deny")) goto l64; } - l59:; yyText(yy, yy->__begin, yy->__end); { + l65:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l58; +if (!(YY_END)) goto l64; #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; - l58:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l64:; 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 l61; + yyprintf((stderr, "%s\n", "service")); if (!yy_name(yy)) goto l67; yyprintf((stderr, " ok %s @ %s\n", "service", yy->__buf+yy->__pos)); return 1; - l61:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l67:; 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 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); + { int yypos69= yy->__pos, yythunkpos69= yy->__thunkpos; if (!yymatchString(yy, "/tcp")) goto l70; yyDo(yy, yy_1_proto, yy->__begin, yy->__end); goto l69; + l70:; yy->__pos= yypos69; yy->__thunkpos= yythunkpos69; if (!yymatchString(yy, "/udp")) goto l71; yyDo(yy, yy_2_proto, yy->__begin, yy->__end); goto l69; + l71:; yy->__pos= yypos69; yy->__thunkpos= yythunkpos69; if (!yymatchString(yy, "")) goto l68; yyDo(yy, yy_3_proto, yy->__begin, yy->__end); } - l63:; + l69:; yyprintf((stderr, " ok %s @ %s\n", "proto", yy->__buf+yy->__pos)); return 1; - l62:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l68:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "proto", yy->__buf+yy->__pos)); return 0; } @@ -887,177 +891,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 l66; -#undef yytext -#undef yyleng - } - { 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; - } - l67:; yyText(yy, yy->__begin, yy->__end); { -#define yytext yy->__text -#define yyleng yy->__textlen -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; - 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 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; - 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 l72; - { int yypos73= yy->__pos, yythunkpos73= yy->__thunkpos; if (!yy__(yy)) goto l73; goto l74; - l73:; yy->__pos= yypos73; yy->__thunkpos= yythunkpos73; - } - 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; - } - l76:; yyText(yy, yy->__begin, yy->__end); { -#define yytext yy->__text -#define yyleng yy->__textlen if (!(YY_BEGIN)) goto l72; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l72; yyText(yy, yy->__begin, yy->__end); { + } + { int yypos73= yy->__pos, yythunkpos73= yy->__thunkpos; if (!yy_number(yy)) goto l74; goto l73; + l74:; yy->__pos= yypos73; yy->__thunkpos= yythunkpos73; if (!yy_service(yy)) goto l72; + } + l73:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen if (!(YY_END)) goto l72; #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; + l72:; 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 l75; + l76:; + { int yypos77= yy->__pos, yythunkpos77= yy->__thunkpos; if (!yy_digit(yy)) goto l77; goto l76; + l77:; yy->__pos= yypos77; yy->__thunkpos= yythunkpos77; + } + yyprintf((stderr, " ok %s @ %s\n", "number", yy->__buf+yy->__pos)); + return 1; + l75:; 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 l78; + { int yypos79= yy->__pos, yythunkpos79= yy->__thunkpos; if (!yy__(yy)) goto l79; goto l80; + l79:; yy->__pos= yypos79; yy->__thunkpos= yythunkpos79; + } + l80:; if (!yymatchChar(yy, '=')) goto l78; + { int yypos81= yy->__pos, yythunkpos81= yy->__thunkpos; if (!yy__(yy)) goto l81; goto l82; + l81:; yy->__pos= yypos81; yy->__thunkpos= yythunkpos81; + } + l82:; yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l78; +#undef yytext +#undef yyleng + } if (!yy_address(yy)) goto l78; yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l78; +#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; - l72:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l78:; 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 l77; - { int yypos78= yy->__pos, yythunkpos78= yy->__thunkpos; if (!yy__(yy)) goto l78; goto l79; - l78:; yy->__pos= yypos78; yy->__thunkpos= yythunkpos78; + yyprintf((stderr, "%s\n", "option_timeout")); if (!yymatchString(yy, "timeout")) goto l83; + { int yypos84= yy->__pos, yythunkpos84= yy->__thunkpos; if (!yy__(yy)) goto l84; goto l85; + l84:; yy->__pos= yypos84; yy->__thunkpos= yythunkpos84; } - 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; + l85:; if (!yymatchChar(yy, '=')) goto l83; + { int yypos86= yy->__pos, yythunkpos86= yy->__thunkpos; if (!yy__(yy)) goto l86; goto l87; + l86:; yy->__pos= yypos86; yy->__thunkpos= yythunkpos86; } - l81:; yyText(yy, yy->__begin, yy->__end); { + l87:; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l77; +if (!(YY_BEGIN)) goto l83; #undef yytext #undef yyleng - } if (!yy_number(yy)) goto l77; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_number(yy)) goto l83; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l77; +if (!(YY_END)) goto l83; #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; - l77:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l83:; 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 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; + { int yypos89= yy->__pos, yythunkpos89= yy->__thunkpos; if (!yy_option_timeout(yy)) goto l90; goto l89; + l90:; yy->__pos= yypos89; yy->__thunkpos= yythunkpos89; if (!yy_option_source(yy)) goto l88; } - l83:; + l89:; yyprintf((stderr, " ok %s @ %s\n", "option", yy->__buf+yy->__pos)); return 1; - l82:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l88:; 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 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; + yyprintf((stderr, "%s\n", "option_list")); if (!yy_option(yy)) goto l91; + { int yypos92= yy->__pos, yythunkpos92= yy->__thunkpos; + { int yypos94= yy->__pos, yythunkpos94= yy->__thunkpos; if (!yy__(yy)) goto l94; goto l95; + l94:; yy->__pos= yypos94; yy->__thunkpos= yythunkpos94; } - 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; + l95:; if (!yymatchChar(yy, ',')) goto l92; + { int yypos96= yy->__pos, yythunkpos96= yy->__thunkpos; if (!yy__(yy)) goto l96; goto l97; + l96:; yy->__pos= yypos96; yy->__thunkpos= yythunkpos96; } - l91:; if (!yy_option_list(yy)) goto l86; goto l87; - l86:; yy->__pos= yypos86; yy->__thunkpos= yythunkpos86; + l97:; if (!yy_option_list(yy)) goto l92; goto l93; + l92:; yy->__pos= yypos92; yy->__thunkpos= yythunkpos92; } - l87:; + l93:; yyprintf((stderr, " ok %s @ %s\n", "option_list", yy->__buf+yy->__pos)); return 1; - l85:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l91:; 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 l92; if (!yy_proto(yy)) goto l92; + yyprintf((stderr, "%s\n", "full_port")); if (!yy_port(yy)) goto l98; if (!yy_proto(yy)) goto l98; yyprintf((stderr, " ok %s @ %s\n", "full_port", yy->__buf+yy->__pos)); return 1; - l92:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l98:; 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 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; + { int yypos100= yy->__pos, yythunkpos100= yy->__thunkpos; if (!yy_ipv4(yy)) goto l101; goto l100; + l101:; yy->__pos= yypos100; yy->__thunkpos= yythunkpos100; if (!yy_ipv6(yy)) goto l102; goto l100; + l102:; yy->__pos= yypos100; yy->__thunkpos= yythunkpos100; if (!yy_hostname(yy)) goto l99; } - l94:; + l100:; yyprintf((stderr, " ok %s @ %s\n", "address", yy->__buf+yy->__pos)); return 1; - l93:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l99:; 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 l97; - { int yypos98= yy->__pos, yythunkpos98= yy->__thunkpos; if (!yy__(yy)) goto l98; goto l99; - l98:; yy->__pos= yypos98; yy->__thunkpos= yythunkpos98; + yyprintf((stderr, "%s\n", "server_options")); if (!yymatchChar(yy, '[')) goto l103; + { int yypos104= yy->__pos, yythunkpos104= yy->__thunkpos; if (!yy__(yy)) goto l104; goto l105; + l104:; yy->__pos= yypos104; yy->__thunkpos= yythunkpos104; } - 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; + l105:; if (!yy_option_list(yy)) goto l103; + { int yypos106= yy->__pos, yythunkpos106= yy->__thunkpos; if (!yy__(yy)) goto l106; goto l107; + l106:; yy->__pos= yypos106; yy->__thunkpos= yythunkpos106; } - l101:; if (!yymatchChar(yy, ']')) goto l97; + l107:; if (!yymatchChar(yy, ']')) goto l103; yyprintf((stderr, " ok %s @ %s\n", "server_options", yy->__buf+yy->__pos)); return 1; - l97:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l103:; 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 l102; yyDo(yy, yy_1_connect_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "connect_port")); if (!yy_full_port(yy)) goto l108; yyDo(yy, yy_1_connect_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "connect_port", yy->__buf+yy->__pos)); return 1; - l102:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l108:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "connect_port", yy->__buf+yy->__pos)); return 0; } @@ -1066,28 +1070,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 l103; +if (!(YY_BEGIN)) goto l109; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l103; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l109; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l103; +if (!(YY_END)) goto l109; #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; - l103:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l109:; 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 l104; yyDo(yy, yy_1_bind_port, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "bind_port")); if (!yy_full_port(yy)) goto l110; yyDo(yy, yy_1_bind_port, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "bind_port", yy->__buf+yy->__pos)); return 1; - l104:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l110:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "bind_port", yy->__buf+yy->__pos)); return 0; } @@ -1096,153 +1100,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 l105; +if (!(YY_BEGIN)) goto l111; #undef yytext #undef yyleng - } if (!yy_address(yy)) goto l105; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_address(yy)) goto l111; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l105; +if (!(YY_END)) goto l111; #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; - l105:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l111:; 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 l106; yyDo(yy, yy_1_logcommon, yy->__begin, yy->__end); + yyprintf((stderr, "%s\n", "logcommon")); if (!yymatchString(yy, "logcommon")) goto l112; yyDo(yy, yy_1_logcommon, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "logcommon", yy->__buf+yy->__pos)); return 1; - l106:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l112:; 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 l107; if (!yy__(yy)) goto l107; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "pidlogfile")); if (!yymatchString(yy, "pidlogfile")) goto l113; if (!yy__(yy)) goto l113; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l107; +if (!(YY_BEGIN)) goto l113; #undef yytext #undef yyleng - } if (!yy_filename(yy)) goto l107; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_filename(yy)) goto l113; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l107; +if (!(YY_END)) goto l113; #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; - l107:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l113:; 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 l108; if (!yy__(yy)) goto l108; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "logfile")); if (!yymatchString(yy, "logfile")) goto l114; if (!yy__(yy)) goto l114; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l108; +if (!(YY_BEGIN)) goto l114; #undef yytext #undef yyleng - } if (!yy_filename(yy)) goto l108; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_filename(yy)) goto l114; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l108; +if (!(YY_END)) goto l114; #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; - l108:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l114:; 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 l109; if (!yy__(yy)) goto l109; yyText(yy, yy->__begin, yy->__end); { + yyprintf((stderr, "%s\n", "auth_rule")); if (!yy_auth_key(yy)) goto l115; if (!yy__(yy)) goto l115; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_BEGIN)) goto l109; +if (!(YY_BEGIN)) goto l115; #undef yytext #undef yyleng - } if (!yy_pattern(yy)) goto l109; yyText(yy, yy->__begin, yy->__end); { + } if (!yy_pattern(yy)) goto l115; yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l109; +if (!(YY_END)) goto l115; #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; - l109:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l115:; 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 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; + yyprintf((stderr, "%s\n", "server_rule")); if (!yy_bind_address(yy)) goto l116; if (!yy__(yy)) goto l116; if (!yy_bind_port(yy)) goto l116; if (!yy__(yy)) goto l116; if (!yy_connect_address(yy)) goto l116; if (!yy__(yy)) goto l116; if (!yy_connect_port(yy)) goto l116; + { int yypos117= yy->__pos, yythunkpos117= yy->__thunkpos; + { int yypos119= yy->__pos, yythunkpos119= yy->__thunkpos; if (!yy__(yy)) goto l119; goto l120; + l119:; yy->__pos= yypos119; yy->__thunkpos= yythunkpos119; } - l114:; if (!yy_server_options(yy)) goto l111; goto l112; - l111:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111; + l120:; if (!yy_server_options(yy)) goto l117; goto l118; + l117:; yy->__pos= yypos117; yy->__thunkpos= yythunkpos117; } - l112:; yyDo(yy, yy_1_server_rule, yy->__begin, yy->__end); + l118:; yyDo(yy, yy_1_server_rule, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "server_rule", yy->__buf+yy->__pos)); return 1; - l110:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l116:; 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 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, "%s\n", "comment")); if (!yymatchChar(yy, '#')) goto l121; + l122:; + { int yypos123= yy->__pos, yythunkpos123= yy->__thunkpos; + { int yypos124= yy->__pos, yythunkpos124= yy->__thunkpos; if (!yy_eol(yy)) goto l124; goto l123; + l124:; yy->__pos= yypos124; yy->__thunkpos= yythunkpos124; + } if (!yymatchDot(yy)) goto l123; goto l122; + l123:; yy->__pos= yypos123; yy->__thunkpos= yythunkpos123; } yyprintf((stderr, " ok %s @ %s\n", "comment", yy->__buf+yy->__pos)); return 1; - l115:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l121:; 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 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; + { int yypos126= yy->__pos, yythunkpos126= yy->__thunkpos; if (!yy_server_rule(yy)) goto l127; goto l126; + l127:; yy->__pos= yypos126; yy->__thunkpos= yythunkpos126; if (!yy_auth_rule(yy)) goto l128; goto l126; + l128:; yy->__pos= yypos126; yy->__thunkpos= yythunkpos126; if (!yy_logfile(yy)) goto l129; goto l126; + l129:; yy->__pos= yypos126; yy->__thunkpos= yythunkpos126; if (!yy_pidlogfile(yy)) goto l130; goto l126; + l130:; yy->__pos= yypos126; yy->__thunkpos= yythunkpos126; if (!yy_logcommon(yy)) goto l125; } - l120:; + l126:; yyprintf((stderr, " ok %s @ %s\n", "command", yy->__buf+yy->__pos)); return 1; - l119:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l125:; 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 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, "%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 l131; + l132:; + { int yypos133= yy->__pos, yythunkpos133= 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 l133; goto l132; + l133:; yy->__pos= yypos133; yy->__thunkpos= yythunkpos133; } yyprintf((stderr, " ok %s @ %s\n", "_", yy->__buf+yy->__pos)); return 1; - l125:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l131:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "_", yy->__buf+yy->__pos)); return 0; } @@ -1251,71 +1255,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 l128; +if (!(YY_BEGIN)) goto l134; #undef yytext #undef yyleng } - { 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; + { int yypos137= yy->__pos, yythunkpos137= yy->__thunkpos; if (!yy_eol(yy)) goto l137; goto l134; + l137:; yy->__pos= yypos137; yy->__thunkpos= yythunkpos137; + } if (!yymatchDot(yy)) goto l134; + l135:; + { int yypos136= yy->__pos, yythunkpos136= yy->__thunkpos; + { int yypos138= yy->__pos, yythunkpos138= yy->__thunkpos; if (!yy_eol(yy)) goto l138; goto l136; + l138:; yy->__pos= yypos138; yy->__thunkpos= yythunkpos138; + } if (!yymatchDot(yy)) goto l136; goto l135; + l136:; yy->__pos= yypos136; yy->__thunkpos= yythunkpos136; } yyText(yy, yy->__begin, yy->__end); { #define yytext yy->__text #define yyleng yy->__textlen -if (!(YY_END)) goto l128; +if (!(YY_END)) goto l134; #undef yytext #undef yyleng - } if (!yy_eol(yy)) goto l128; yyDo(yy, yy_1_invalid_syntax, yy->__begin, yy->__end); + } if (!yy_eol(yy)) goto l134; yyDo(yy, yy_1_invalid_syntax, yy->__begin, yy->__end); yyprintf((stderr, " ok %s @ %s\n", "invalid_syntax", yy->__buf+yy->__pos)); return 1; - l128:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l134:; 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 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; + { int yypos140= yy->__pos, yythunkpos140= yy->__thunkpos; + { int yypos142= yy->__pos, yythunkpos142= yy->__thunkpos; if (!yymatchChar(yy, '\r')) goto l142; goto l143; + l142:; yy->__pos= yypos142; yy->__thunkpos= yythunkpos142; } - l137:; if (!yymatchChar(yy, '\n')) goto l135; goto l134; - l135:; yy->__pos= yypos134; yy->__thunkpos= yythunkpos134; if (!yy_eof(yy)) goto l133; + l143:; if (!yymatchChar(yy, '\n')) goto l141; goto l140; + l141:; yy->__pos= yypos140; yy->__thunkpos= yythunkpos140; if (!yy_eof(yy)) goto l139; } - l134:; + l140:; yyprintf((stderr, " ok %s @ %s\n", "eol", yy->__buf+yy->__pos)); return 1; - l133:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l139:; 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 yypos139= yy->__pos, yythunkpos139= yy->__thunkpos; if (!yy__(yy)) goto l139; goto l140; - l139:; yy->__pos= yypos139; yy->__thunkpos= yythunkpos139; - } - 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; - } - l144:; goto l142; - l141:; yy->__pos= yypos141; yy->__thunkpos= yythunkpos141; - } - l142:; - { int yypos145= yy->__pos, yythunkpos145= yy->__thunkpos; if (!yy_comment(yy)) goto l145; goto l146; + { int yypos145= yy->__pos, yythunkpos145= yy->__thunkpos; if (!yy__(yy)) goto l145; goto l146; l145:; yy->__pos= yypos145; yy->__thunkpos= yythunkpos145; } l146:; + { int yypos147= yy->__pos, yythunkpos147= yy->__thunkpos; if (!yy_command(yy)) goto l147; + { int yypos149= yy->__pos, yythunkpos149= yy->__thunkpos; if (!yy__(yy)) goto l149; goto l150; + l149:; yy->__pos= yypos149; yy->__thunkpos= yythunkpos149; + } + l150:; goto l148; + l147:; yy->__pos= yypos147; yy->__thunkpos= yythunkpos147; + } + l148:; + { int yypos151= yy->__pos, yythunkpos151= yy->__thunkpos; if (!yy_comment(yy)) goto l151; goto l152; + l151:; yy->__pos= yypos151; yy->__thunkpos= yythunkpos151; + } + l152:; yyprintf((stderr, " ok %s @ %s\n", "line", yy->__buf+yy->__pos)); return 1; - l138:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l144:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "line", yy->__buf+yy->__pos)); return 0; } @@ -1324,20 +1328,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; - l147:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + l153:; 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")); - 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; + l155:; + { int yypos156= yy->__pos, yythunkpos156= yy->__thunkpos; if (!yy_sol(yy)) goto l156; + { int yypos157= yy->__pos, yythunkpos157= yy->__thunkpos; if (!yy_line(yy)) goto l158; if (!yy_eol(yy)) goto l158; goto l157; + l158:; yy->__pos= yypos157; yy->__thunkpos= yythunkpos157; if (!yy_invalid_syntax(yy)) goto l156; } - l151:; goto l149; - l150:; yy->__pos= yypos150; yy->__thunkpos= yythunkpos150; + l157:; goto l155; + l156:; yy->__pos= yypos156; yy->__thunkpos= yythunkpos156; } yyprintf((stderr, " ok %s @ %s\n", "file", yy->__buf+yy->__pos)); return 1; diff --git a/src/parse.peg b/src/parse.peg index b0762d7..9db191a 100644 --- a/src/parse.peg +++ b/src/parse.peg @@ -130,11 +130,11 @@ invalid_syntax = < (!eol .)+ > eol service = name address = ipv4 | ipv6 | hostname -pattern = [0-9*?]+ ('.' [0-9*?]+ ('.' [0-9*?]+ ('.' [0-9*?]+)?)?)? +pattern = (hexdigit | '[' | ']' | ':' | '.' | [*?] )+ number = digit+ ipv4 = number '.' number '.' number '.' number | '0' -ipv6 = (hexdigit | ':')+ | '[' ipv6 ']' +ipv6 = (hexdigit | ':')+ | '[' (hexdigit | ':')+ ']' hostname = (label '.')* name '.'? From 655584ad787701ec63e3d982b3d816a1e70359d8 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Feb 2021 10:10:47 +0100 Subject: [PATCH 16/16] Fix a format string issue on Windows. --- src/rinetd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rinetd.c b/src/rinetd.c index 08b0672..cb54761 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -277,7 +277,7 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, struct addrinfo *servinfo; int ret = getaddrinfo(bindAddress, bindPort, &hints, &servinfo); if (ret != 0) { - fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerror(ret)); + fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerrorA(ret)); exit(1); } @@ -326,7 +326,7 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, hints.ai_flags = AI_PASSIVE; ret = getaddrinfo(connectAddress, connectPort, &hints, &servinfo); if (ret != 0) { - fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerror(ret)); + fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerrorA(ret)); freeaddrinfo(si.fromAddrInfo); closesocket(si.fd); exit(1); @@ -342,7 +342,7 @@ void addServer(char *bindAddress, char *bindPort, int bindProtocol, ret = getaddrinfo(sourceAddress, NULL, &hints, &servinfo); if (ret != 0) { - fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerror(ret)); + fprintf(stderr, "rinetd: getaddrinfo error: %s\n", gai_strerrorA(ret)); freeaddrinfo(si.fromAddrInfo); freeaddrinfo(si.toAddrInfo); exit(1);