mirror of
https://github.com/darkk/redsocks.git
synced 2025-08-30 21:55:31 +00:00
Added command-line opts: "-t" to test config, and "-c /config/path".
This commit is contained in:
parent
36dc692ab3
commit
c4c35981fd
29
main.c
29
main.c
@ -3,6 +3,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -18,11 +19,34 @@ app_subsys *subsystems[] = {
|
|||||||
// &reddns_subsys,
|
// &reddns_subsys,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *confname = "redsocks.conf";
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
app_subsys **ss;
|
app_subsys **ss;
|
||||||
FILE *f = fopen("redsocks.conf", "r");
|
bool conftest = false;
|
||||||
|
int opt;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "tc:")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 't':
|
||||||
|
conftest = true;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
confname = optarg;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf(
|
||||||
|
"Usage: %s [-t] [-c config]\n"
|
||||||
|
" -t test config syntax\n",
|
||||||
|
argv[0]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FILE *f = fopen(confname, "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
perror("Unable to open config file");
|
perror("Unable to open config file");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -43,6 +67,9 @@ int main(int argc, char **argv)
|
|||||||
if (error)
|
if (error)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
if (conftest)
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
event_init();
|
event_init();
|
||||||
|
|
||||||
FOREACH(ss, subsystems) {
|
FOREACH(ss, subsystems) {
|
||||||
|
Loading…
Reference in New Issue
Block a user