config_parse.c

来自「sock protocol ,it is useful!」· C语言 代码 · 共 1,716 行 · 第 1/4 页

C
1,716
字号
  125,  132,  279,  280,  224,   58,  226,  194,  274,  275,  276,  277,   81,  233,  301,  302,  303,  304,  305,   58,  157,  266,  267,  157,  123,    0,  157,  311,  312,  313,  314,  315,  296,  297,  298,   10,  316,  317,  318,  292,  293,  316,  317,  322,  320,  321,   70,   71,  286,  123,   58,  123,  125,   58,  194,  125,  269,    0,  281,  194,  129,  212,  194,  322,  322,  316,   58,   10,   58,   58,   58,   58,   58,  323,  281,  319,  307,  324,   58,  273,  268,  125,  288,  125,   58,  273,  268,   58,   45,    0,  125,  273,   47,  320,  288,    0,    0,  291,  323,   10,  125,  295,  323,  291,  323,  299,  300,  295,  125,  291,  125,  299,  300,  295,  308,  125,  310,  299,  300,  268,  308,    0,  310,    7,  273,  194,  308,  273,  310,  163,  324,   10,  323,  323,  323,  323,  167,  170,    7,   87,  178,  323,  291,  268,    7,  291,  295,    7,  273,  295,  299,  300,   90,  299,  300,   79,  102,   99,  186,  308,   21,  310,  308,   10,  310,  212,  291,  207,  200,   -1,  295,   -1,   -1,   -1,  323,  300,   -1,  323,  259,   -1,   -1,   -1,  263,  264,   -1,   -1,   -1,   -1,   -1,  259,  260,  261,  262,   -1,  264,  265,   -1,   -1,  268,   -1,  273,  271,  272,  273,  285,   -1,  287,   -1,  278,   -1,   -1,   -1,  282,  283,  284,  285,   -1,   -1,  291,  289,  290,  291,  295,   -1,   -1,  295,  299,  300,   -1,  299,  300,   -1,   -1,   -1,   -1,  308,   -1,  310,  308,   -1,  310,   -1,  259,  260,  261,  262,   -1,  264,  265,   -1,  323,  268,   -1,  323,  271,  272,  273,   -1,   -1,   -1,   -1,  278,   -1,   -1,   -1,  282,  283,  284,  285,   -1,   -1,   -1,  289,  290,  291,   -1,   -1,   -1,  295,   -1,   -1,   -1,   -1,  300,  259,  260,  261,  262,  263,  264,  265,   -1,   -1,  268,   -1,   -1,  271,  272,  273,   -1,   -1,   -1,   -1,  278,   -1,   -1,  323,  282,  283,  284,  285,   -1,  287,   -1,  289,  290,  259,  260,  261,  262,   -1,  264,  265,   -1,   -1,  268,   -1,   -1,  271,  272,  273,   -1,   -1,   -1,   -1,  278,   -1,   -1,   -1,  282,  283,  284,  285,   -1,   -1,   -1,  289,  290,  259,  260,  261,  262,   -1,  264,  265,   -1,   -1,  268,   -1,   -1,  271,  272,  273,   -1,   -1,   -1,   -1,  278,   -1,   -1,   -1,  282,  283,  284,  285,   -1,   -1,   -1,  289,  290,  259,  260,  261,  262,   -1,  264,  265,   -1,   -1,  268,   -1,   -1,  271,  272,  273,   -1,   -1,   -1,   -1,  278,   -1,   -1,   -1,  282,  283,  284,  285,   -1,   -1,   -1,  289,  290,  259,  260,  261,  262,   -1,  264,  265,   -1,   -1,  268,   -1,   -1,  271,  272,  273,   -1,   -1,   -1,   -1,  278,   -1,   -1,   -1,  282,  283,  284,  285,   -1,   -1,   -1,  289,  290,};#define YYFINAL 3#ifndef YYDEBUG#define YYDEBUG 0#endif#define YYMAXTOKEN 324#if YYDEBUGchar *socks_yyname[] = {"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"SERVERCONFIG","CLIENTCONFIG","DEPRECATED","CLIENTRULE","INTERNAL","EXTERNAL","DEBUGING","RESOLVEPROTOCOL","SRCHOST","NOMISMATCH","NOUNKNOWN","EXTENSION","BIND","PRIVILEGED","IOTIMEOUT","CONNECTTIMEOUT","METHOD","NONE","GSSAPI","UNAME","RFC931","COMPATIBILITY","REUSEADDR","SAMEPORT","USERNAME","USER_PRIVILEGED","USER_UNPRIVILEGED","USER_LIBWRAP","LOGOUTPUT","LOGFILE","ROUTE","VIA","VERDICT_BLOCK","VERDICT_PASS","PROTOCOL","PROTOCOL_TCP","PROTOCOL_UDP","PROTOCOL_FAKE","PROXYPROTOCOL","PROXYPROTOCOL_SOCKS_V4","PROXYPROTOCOL_SOCKS_V5","PROXYPROTOCOL_MSPROXY_V2","USER","COMMAND","COMMAND_BIND","COMMAND_CONNECT","COMMAND_UDPASSOCIATE","COMMAND_BINDREPLY","COMMAND_UDPREPLY","ACTION","LINE","LIBWRAPSTART","OPERATOR","LOG","LOG_CONNECT","LOG_DATA","LOG_DISCONNECT","LOG_ERROR","LOG_IOOPERATION","IPADDRESS","DOMAIN","DIRECT","PORT","PORTNUMBER","SERVICENAME","NUMBER","FROM","TO",};char *socks_yyrule[] = {"$accept : configtype","configtype : serverinit serverline","configtype : clientinit clientline","serverinit : SERVERCONFIG","serverline :","serverline : serverline '\\n'","serverline : serverline serverconfig","serverline : serverline clientrule","serverline : serverline rule","clientline :","clientline : clientline '\\n'","clientline : clientline clientconfig","clientline : clientline route","clientinit : CLIENTCONFIG","clientconfig : clientoption","clientconfig : deprecated","serverconfig : authmethod","serverconfig : deprecated","serverconfig : internal","serverconfig : external","serverconfig : logoutput","serverconfig : serveroption","serverconfig : userids","serveroption : compatibility","serveroption : connecttimeout","serveroption : extension","serveroption : iotimeout","serveroption : resolveprotocol","serveroption : srchost","deprecated : DEPRECATED","route : ROUTE routeinit '{' routeoptions fromto gateway routeoptions '}'","routeinit :","proxyprotocol : PROXYPROTOCOL ':' proxyprotocols","proxyprotocolname : PROXYPROTOCOL_SOCKS_V4","proxyprotocolname : PROXYPROTOCOL_SOCKS_V5","proxyprotocolname : PROXYPROTOCOL_MSPROXY_V2","proxyprotocols : proxyprotocolname","proxyprotocols : proxyprotocolname proxyprotocols","user : USER ':' usernames","username : USERNAME","usernames : username","usernames : username usernames","extension : EXTENSION ':' extensions","extensionname : BIND","extensions : extensionname","extensions : extensionname extensions","internal : INTERNAL internalinit ':' ipaddress port","internalinit :","external : EXTERNAL externalinit ':' ipaddress","externalinit :","clientoption : logoutput","clientoption : debuging","clientoption : resolveprotocol","logoutput : LOGOUTPUT ':' logoutputdevices","logoutputdevice : LOGFILE","logoutputdevices : logoutputdevice","logoutputdevices : logoutputdevice logoutputdevices","userids : user_privileged","userids : user_unprivileged","userids : user_libwrap","user_privileged : USER_PRIVILEGED ':' userid","user_unprivileged : USER_UNPRIVILEGED ':' userid","user_libwrap : USER_LIBWRAP ':' userid","userid : USERNAME","iotimeout : IOTIMEOUT ':' NUMBER","connecttimeout : CONNECTTIMEOUT ':' NUMBER","debuging : DEBUGING ':' NUMBER","compatibility : COMPATIBILITY ':' compatibilitys","compatibilityname : REUSEADDR","compatibilityname : SAMEPORT","compatibilitys : compatibilityname","compatibilitys : compatibilityname compatibilitys","resolveprotocol : RESOLVEPROTOCOL ':' resolveprotocolname","resolveprotocolname : PROTOCOL_FAKE","resolveprotocolname : PROTOCOL_TCP","resolveprotocolname : PROTOCOL_UDP","srchost : SRCHOST ':' srchostoptions","srchostoption : NOMISMATCH","srchostoption : NOUNKNOWN","srchostoptions : srchostoption","srchostoptions : srchostoption srchostoptions","authmethod : METHOD ':' authmethods","authmethodname : NONE","authmethodname : GSSAPI","authmethodname : UNAME","authmethodname : RFC931","authmethods : authmethodname","authmethods : authmethodname authmethods","clientrule : CLIENTRULE verdict '{' clientruleoptions fromto clientruleoptions '}'","clientruleoption : libwrap","clientruleoption : log","clientruleoption : user","clientruleoptions :","clientruleoptions : clientruleoption clientruleoptions","rule : verdict '{' ruleoptions fromto ruleoptions '}'","ruleoption : authmethod","ruleoption : command","ruleoption : libwrap","ruleoption : log","ruleoption : protocol","ruleoption : proxyprotocol","ruleoption : user","ruleoptions :","ruleoptions : ruleoption ruleoptions","verdict : VERDICT_BLOCK","verdict : VERDICT_PASS","command : COMMAND ':' commands","commandname : COMMAND_BIND","commandname : COMMAND_CONNECT","commandname : COMMAND_UDPASSOCIATE","commandname : COMMAND_BINDREPLY","commandname : COMMAND_UDPREPLY","commands : commandname","commands : commandname commands","protocol : PROTOCOL ':' protocols","protocolname : PROTOCOL_TCP","protocolname : PROTOCOL_UDP","protocols : protocolname","protocols : protocolname protocols","fromto : srcaddress dstaddress","log : LOG ':' logs","logname : LOG_CONNECT","logname : LOG_DATA","logname : LOG_DISCONNECT","logname : LOG_ERROR","logname : LOG_IOOPERATION","logs : logname","logs : logname logs","libwrap : LIBWRAPSTART ':' LINE","srcaddress : from ':' address","dstaddress : to ':' address","gateway : via ':' gwaddress","routeoption : command","routeoption : extension","routeoption : protocol","routeoption : proxyprotocol","routeoption : authmethod","routeoptions :","routeoptions : routeoption routeoptions","from : FROM","to : TO","via : VIA","address : ipaddress '/' netmask port","address : domain port","gwaddress : ipaddress port","gwaddress : domain port","gwaddress : direct","ipaddress : IPADDRESS","netmask : NUMBER","netmask : IPADDRESS","domain : DOMAIN","direct : DIRECT","port :","port : PORT portoperator portnumber","port : PORT portrange","portnumber : portservice","portnumber : portstart","portrange : portstart '-' portend","portstart : PORTNUMBER","portservice : SERVICENAME","portend : PORTNUMBER","portoperator : OPERATOR",};#endif#ifdef YYSTACKSIZE#undef YYMAXDEPTH#define YYMAXDEPTH YYSTACKSIZE#else#ifdef YYMAXDEPTH#define YYSTACKSIZE YYMAXDEPTH#else#define YYSTACKSIZE 10000#define YYMAXDEPTH 10000#endif#endif#define YYINITSTACKSIZE 200int yydebug;int yynerrs;int yyerrflag;int yychar;short *yyssp;YYSTYPE *yyvsp;YYSTYPE yyval;YYSTYPE yylval;short *yyss;short *yysslim;YYSTYPE *yyvs;int yystacksize;#line 1043 "config_parse.y"#define INTERACTIVE		0#if SOCKS_SERVER#define ELECTRICFENCE	0#else#define ELECTRICFENCE	0#endif#if ELECTRICFENCE	extern int EF_PROTECT_FREE;	extern int EF_ALLOW_MALLOC_0;	extern int EF_ALIGNMENT;	extern int EF_PROTECT_BELOW;#endif /* ELECTRICFENCE */extern FILE *yyin;int parseinit;intreadconfig(filename)	const char *filename;{	const char *function = "readconfig()";#if ELECTRICFENCE	EF_PROTECT_FREE         = 1;	EF_ALLOW_MALLOC_0       = 1;	EF_ALIGNMENT            = 0;	EF_PROTECT_BELOW			= 0;#endif /* ELECTRICFENCE *//*	yydebug		= 0; */	yylineno		= 1;	parseinit	= 0;	if ((yyin = fopen(filename, "r")) == NULL) {		swarn("%s: %s", function, filename);		return -1;	}	yyparse();	fclose(yyin);	errno = 0; /* yacc for some reason alters errno sometimes. */	return 0;}voidyyerror(s)	const char *s;{	serrx(1, "%s: error on line %d, near '%.10s': %s",	config.option.configfile, yylineno,	(yytext == NULL || *yytext == NUL) ? "'start of line'" : yytext, s);}static voidaddressinit(address)	struct ruleaddress_t *address;{		ruleaddress	= address;		atype			= &ruleaddress->atype;		ipaddr		= &ruleaddress->addr.ipv4.ip;		netmask		= &ruleaddress->addr.ipv4.mask;		domain		= ruleaddress->addr.domain;		port_tcp		= &ruleaddress->port.tcp;		port_udp		= &ruleaddress->port.udp;		operator		= &ruleaddress->operator;}#line 772 "y.tab.c"/* allocate initial stack or double stack size, up to YYMAXDEPTH */#if defined(__cplusplus) || __STDC__static int yygrowstack(void)#elsestatic int yygrowstack()#endif{    int newsize, i;    short *newss;    YYSTYPE *newvs;    if ((newsize = yystacksize) == 0)        newsize = YYINITSTACKSIZE;    else if (newsize >= YYMAXDEPTH)        return -1;    else if ((newsize *= 2) > YYMAXDEPTH)        newsize = YYMAXDEPTH;    i = yyssp - yyss;    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :      (short *)malloc(newsize * sizeof *newss);    if (newss == NULL)        return -1;    yyss = newss;    yyssp = newss + i;    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :      (YYSTYPE *)malloc(newsize * sizeof *newvs);    if (newvs == NULL)        return -1;    yyvs = newvs;    yyvsp = newvs + i;    yystacksize = newsize;    yysslim = yyss + newsize - 1;    return 0;}#define YYABORT goto yyabort#define YYREJECT goto yyabort#define YYACCEPT goto yyaccept#define YYERROR goto yyerrlabint#if defined(__cplusplus) || __STDC__yyparse(void)#elseyyparse()#endif{    register int yym, yyn, yystate;#if YYDEBUG    register char *yys;    if ((yys = getenv("YYDEBUG")))    {        yyn = *yys;        if (yyn >= '0' && yyn <= '9')            yydebug = yyn - '0';    }#endif    yynerrs = 0;    yyerrflag = 0;    yychar = (-1);    if (yyss == NULL && yygrowstack()) goto yyoverflow;    yyssp = yyss;    yyvsp = yyvs;    *yyssp = yystate = 0;yyloop:    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;    if (yychar < 0)    {        if ((yychar = yylex()) < 0) yychar = 0;#if YYDEBUG        if (yydebug)        {            yys = 0;            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];            if (!yys) yys = "illegal-symbol";            printf("%sdebug: state %d, reading %d (%s)\n",                    YYPREFIX, yystate, yychar, yys);        }#endif    }    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)    {#if YYDEBUG

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?