⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config_parse.c

📁 sock protocol ,it is useful!
💻 C
📖 第 1 页 / 共 4 页
字号:
        if (yydebug)            printf("%sdebug: state %d, shifting to state %d\n",                    YYPREFIX, yystate, yytable[yyn]);#endif        if (yyssp >= yysslim && yygrowstack())        {            goto yyoverflow;        }        *++yyssp = yystate = yytable[yyn];        *++yyvsp = yylval;        yychar = (-1);        if (yyerrflag > 0)  --yyerrflag;        goto yyloop;    }    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)    {        yyn = yytable[yyn];        goto yyreduce;    }    if (yyerrflag) goto yyinrecovery;#if defined(lint) || defined(__GNUC__)    goto yynewerror;#endifyynewerror:    yyerror("syntax error");#if defined(lint) || defined(__GNUC__)    goto yyerrlab;#endifyyerrlab:    ++yynerrs;yyinrecovery:    if (yyerrflag < 3)    {        yyerrflag = 3;        for (;;)        {            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)            {#if YYDEBUG                if (yydebug)                    printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);#endif                if (yyssp >= yysslim && yygrowstack())                {                    goto yyoverflow;                }                *++yyssp = yystate = yytable[yyn];                *++yyvsp = yylval;                goto yyloop;            }            else            {#if YYDEBUG                if (yydebug)                    printf("%sdebug: error recovery discarding state %d\n",                            YYPREFIX, *yyssp);#endif                if (yyssp <= yyss) goto yyabort;                --yyssp;                --yyvsp;            }        }    }    else    {        if (yychar == 0) goto yyabort;#if YYDEBUG        if (yydebug)        {            yys = 0;            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];            if (!yys) yys = "illegal-symbol";            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",                    YYPREFIX, yystate, yychar, yys);        }#endif        yychar = (-1);        goto yyloop;    }yyreduce:#if YYDEBUG    if (yydebug)        printf("%sdebug: state %d, reducing by rule %d (%s)\n",                YYPREFIX, yystate, yyn, yyrule[yyn]);#endif    yym = yylen[yyn];    yyval = yyvsp[1-yym];    switch (yyn)    {case 3:#line 250 "config_parse.y"{#if SOCKS_SERVER		protocol			= &protocolmem;		extension		= &config.extension;		methodv			= config.methodv;		methodc			= &config.methodc;#endif	}break;case 4:#line 261 "config_parse.y"{ yyval.string = NULL; }break;case 9:#line 268 "config_parse.y"{ yyval.string = NULL; }break;case 13:#line 275 "config_parse.y"{	}break;case 29:#line 301 "config_parse.y"{		yyerror("given keyword is deprecated");	}break;case 30:#line 305 "config_parse.y"{#if SOCKS_CLIENT		route.src		= src;		route.dst		= dst;		ruleaddress2sockshost(&gw, &route.gw.host, SOCKS_TCP);		route.gw.state	= state;		addroute(&route);#endif	}break;case 31:#line 317 "config_parse.y"{#if SOCKS_CLIENT		command			= &state.command;		extension		= &state.extension;		methodv			= state.methodv;		methodc			= &state.methodc;		protocol			= &state.protocol;		proxyprotocol	= &state.proxyprotocol;		bzero(&state, sizeof(state));		bzero(&route, sizeof(route));		bzero(&gw, sizeof(gw));		bzero(&src, sizeof(src));		bzero(&dst, sizeof(dst));		src.atype		= SOCKS_ADDR_IPV4;		dst.atype		= SOCKS_ADDR_IPV4;#endif	}break;case 33:#line 341 "config_parse.y"{			proxyprotocol->socks_v4 = 1;	}break;case 34:#line 344 "config_parse.y"{			proxyprotocol->socks_v5 = 1;	}break;case 35:#line 347 "config_parse.y"{			proxyprotocol->msproxy_v2 = 1;	}break;case 39:#line 359 "config_parse.y"{#if SOCKS_SERVER#if !HAVE_LIBWRAP		if (strcmp(yyvsp[0].string, method2string(AUTHMETHOD_RFC931)) == 0)			yyerror("method rfc931 requires libwrap");#endif /* !HAVE_LIBWRAP */		if (adduser(userbase, yyvsp[0].string) == NULL)			yyerror(NOMEM);#endif /* SOCKS_SERVER */	}break;case 43:#line 378 "config_parse.y"{			extension->bind = 1;	}break;case 46:#line 388 "config_parse.y"{#if SOCKS_SERVER		if (config.state.init) {			int i;			for (i = 0; i < config.internalc; ++i)				if (config.internalv[i].addr.sin_addr.s_addr == ipaddr->s_addr				&&	 config.internalv[i].addr.sin_port == *port_tcp)					break;			if (i == config.internalc)				swarnx("can not change internal addresses once running");		}#endif /* SOCKS_SERVER */	}break;case 47:#line 405 "config_parse.y"{#if SOCKS_SERVER	static struct ruleaddress_t mem;	struct servent	*service;	addressinit(&mem);	if (!config.state.init) {		if ((config.internalv = (struct listenaddress_t *)		realloc(config.internalv, sizeof(*config.internalv) * ++config.internalc))		== NULL)			yyerror(NOMEM);		bzero(&config.internalv[config.internalc - 1].addr,		sizeof((*config.internalv).addr));		config.internalv[config.internalc - 1].addr.sin_family = AF_INET;		ipaddr		= &config.internalv[config.internalc - 1].addr.sin_addr;		port_tcp		= &config.internalv[config.internalc - 1].addr.sin_port;	}	else { /* can only set internal addresses once. */		static struct in_addr inaddrmem;		static in_port_t portmem;		ipaddr		= &inaddrmem;		port_tcp		= &portmem;	}	/* set default port. */	if ((service = getservbyname("socks", "tcp")) == NULL)		*port_tcp = htons(SOCKD_PORT);	else		*port_tcp = service->s_port;#endif	}break;case 48:#line 442 "config_parse.y"{#if SOCKS_SERVER		if (config.externalv[config.externalc - 1].sin_addr.s_addr		== htonl(INADDR_ANY))			yyerror("external address can't be a wildcard address");#endif		}break;case 49:#line 451 "config_parse.y"{#if SOCKS_SERVER		static struct ruleaddress_t mem;		if ((config.externalv = (struct sockaddr_in *)realloc(config.externalv,		sizeof(*config.externalv) * ++config.externalc)) == NULL)			yyerror(NOMEM);		bzero(&config.externalv[config.externalc - 1], sizeof(*config.externalv));		config.externalv[config.externalc - 1].sin_family = AF_INET;		addressinit(&mem);		ipaddr = &config.externalv[config.externalc - 1].sin_addr;#endif	}break;case 54:#line 477 "config_parse.y"{		if (!config.state.init) {			const char *syslogname = "syslog";			if (strncmp(yyvsp[0].string, syslogname, strlen(syslogname)) == 0			&& (yyvsp[0].string[strlen(syslogname)] == NUL || yyvsp[0].string[strlen(syslogname)] == '/')) {				char *sl;				config.log.type |= LOGTYPE_SYSLOG;				if (*(sl = &(yyvsp[0].string[strlen(syslogname)])) == '/') { /* facility. */					size_t i;					for (i = 0, ++sl; i < ELEMENTS(syslogfacility); ++i)						if (strcmp(sl, syslogfacility[i].name) == 0)							break;					if (i == ELEMENTS(syslogfacility))						serrx(EXIT_FAILURE, "unknown syslog facility \"%s\"", sl);					config.log.facility = syslogfacility[i].value;				}				else					config.log.facility = LOG_DAEMON; /* default. */			}			else {				config.log.type |= LOGTYPE_FILE;				if ((config.log.fpv = (FILE **)realloc(config.log.fpv,				sizeof(*config.log.fpv) * (config.log.fpc + 1))) == NULL				|| (config.log.fplockv = (int *)realloc(config.log.fplockv,				sizeof(*config.log.fplockv) * (config.log.fpc + 1))) == NULL)					serrx(EXIT_FAILURE, NOMEM);				if ((config.log.fplockv[config.log.fpc]				= socks_mklock(SOCKS_LOCKFILE)) == -1)					serr(EXIT_FAILURE, "socks_mklock()");				if (strcmp(yyvsp[0].string, "stdout") == 0)					config.log.fpv[config.log.fpc] = stdout;				else if (strcmp(yyvsp[0].string, "stderr") == 0)					config.log.fpv[config.log.fpc] = stderr;				else {					int flag;					if ((config.log.fpv[config.log.fpc] = fopen(yyvsp[0].string, "a"))					== NULL)						serr(EXIT_FAILURE, "fopen(%s)", yyvsp[0].string);					if ((flag = fcntl(fileno(config.log.fpv[config.log.fpc]),					F_GETFD, 0)) == -1					||  fcntl(fileno(config.log.fpv[config.log.fpc]), F_SETFD,					flag | FD_CLOEXEC) == -1)						serr(EXIT_FAILURE, "fcntl(F_GETFD/F_SETFD)");				}				++config.log.fpc;			}		}		else			;	/* XXX warn/exit if output changed. */	}break;case 60:#line 548 "config_parse.y"{#if SOCKS_SERVER		config.uid.privileged			= yyvsp[0].uid;		config.uid.privileged_isset	= 1;#endif	}break;case 61:#line 556 "config_parse.y"{#if SOCKS_SERVER		config.uid.unprivileged			= yyvsp[0].uid;		config.uid.unprivileged_isset	= 1;#endif	}break;case 62:#line 564 "config_parse.y"{#if HAVE_LIBWRAP && SOCKS_SERVER		config.uid.libwrap			= yyvsp[0].uid;		config.uid.libwrap_isset	= 1;#else  /* HAVE_LIBWRAP */		yyerror("libwrap support not compiled in");#endif /* !HAVE_LIBWRAP */	}break;case 63:#line 575 "config_parse.y"{		struct passwd *pw;		if ((pw = getpwnam(yyvsp[0].string)) == NULL)			serrx(EXIT_FAILURE, "no such user \"%s\"", yyvsp[0].string);		else			yyval.uid = pw->pw_uid;	}break;case 64:#line 585 "config_parse.y"{#if SOCKS_SERVER		config.timeout.io = atol(yyvsp[0].string);#endif	}break;case 65:#line 592 "config_parse.y"{#if SOCKS_SERVER		config.timeout.negotiate = atol(yyvsp[0].string);#endif	}break;case 66:#line 599 "config_parse.y"{		config.option.debug = atoi(yyvsp[0].string);	}break;case 68:#line 607 "config_parse.y"{#if SOCKS_SERVER		config.compat.reuseaddr = 1;	}break;case 69:#line 611 "config_parse.y"{		config.compat.sameport = 1;#endif	}break;case 73:#line 624 "config_parse.y"{			config.resolveprotocol = RESOLVEPROTOCOL_FAKE;	}break;case 74:#line 627 "config_parse.y"{#if HAVE_NO_RESOLVESTUFF			yyerror("resolveprotocol keyword not supported on this installation");#else /* HAVE_NO_RESOLVESTUFF */

⌨️ 快捷键说明

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