summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-11-25 00:20:37 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-11-25 00:20:37 +0000
commit9919091ea05e6db7738b0f896e1fe836ef23947b (patch)
tree81f50d6fc175ad9de836abe7c2b9509e581da4f4 /src
parentadded inital version (working main lopp with signal handler) (diff)
added cmd options for local and remote addr and port
added cmd option for config file git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@3 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
Diffstat (limited to 'src')
-rw-r--r--src/options.c31
-rw-r--r--src/options.h5
2 files changed, 36 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c
index 76b93e3..175507b 100644
--- a/src/options.c
+++ b/src/options.c
@@ -178,6 +178,11 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-P","--write-pid", opt->pid_file_)
PARSE_STRING_LIST("-L","--log", opt->log_targets_)
PARSE_BOOL_PARAM("-U", "--debug", opt->debug_)
+ PARSE_STRING_PARAM("-l","--local-addr", opt->local_addr_)
+ PARSE_STRING_PARAM("-p","--local-port", opt->local_port_)
+ PARSE_STRING_PARAM("-r","--remote-addr", opt->remote_addr_)
+ PARSE_STRING_PARAM("-o","--remote-port", opt->remote_port_)
+ PARSE_STRING_PARAM("-c","--config", opt->config_file_)
else
return i;
}
@@ -213,6 +218,12 @@ void options_default(options_t* opt)
opt->groupname_ = NULL;
opt->chroot_dir_ = NULL;
opt->pid_file_ = NULL;
+ opt->local_addr_ = NULL;
+ opt->local_port_ = NULL;
+ opt->remote_addr_ = NULL;
+ opt->remote_port_ = NULL;
+ // TODO set system config dir
+ opt->config_file_ = strdup("/etc/tcpproxy.conf");
string_list_init(&opt->log_targets_);
opt->debug_ = 0;
}
@@ -233,6 +244,16 @@ void options_clear(options_t* opt)
if(opt->pid_file_)
free(opt->pid_file_);
string_list_clear(&opt->log_targets_);
+ if(opt->local_addr_)
+ free(opt->local_addr_);
+ if(opt->local_port_)
+ free(opt->local_port_);
+ if(opt->remote_addr_)
+ free(opt->remote_addr_);
+ if(opt->remote_port_)
+ free(opt->remote_port_);
+ if(opt->config_file_)
+ free(opt->config_file_);
}
void options_print_usage()
@@ -248,6 +269,11 @@ void options_print_usage()
printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n");
printf(" add a log target, can be invoked several times\n");
printf(" [-U|--debug] don't daemonize and log to stdout with maximum log level\n");
+ printf(" [-l|--local-addr] <host> local address to listen on\n");
+ printf(" [-p|--local-port] <service> local port to listen on\n");
+ printf(" [-r|--remote-addr] <host> remote address to connect to\n");
+ printf(" [-o|--remote-port] <service> remote port to connect to\n");
+ printf(" [-c|--config] <file> configuration file\n");
}
void options_print_version()
@@ -269,5 +295,10 @@ void options_print(options_t* opt)
printf("pid_file: '%s'\n", opt->pid_file_);
printf("log_targets: \n");
string_list_print(&opt->log_targets_, " '", "'\n");
+ printf("local_addr: '%s'\n", opt->local_addr_);
+ printf("local_port: '%s'\n", opt->local_port_);
+ printf("remote_addr: '%s'\n", opt->remote_addr_);
+ printf("remote_port: '%s'\n", opt->remote_port_);
+ printf("config_file: '%s'\n", opt->config_file_);
printf("debug: %s\n", !opt->debug_ ? "false" : "true");
}
diff --git a/src/options.h b/src/options.h
index e3a980d..197d337 100644
--- a/src/options.h
+++ b/src/options.h
@@ -39,6 +39,11 @@ struct options_struct {
char* chroot_dir_;
char* pid_file_;
string_list_t log_targets_;
+ char* local_addr_;
+ char* local_port_;
+ char* remote_addr_;
+ char* remote_port_;
+ char* config_file_;
int debug_;
};
typedef struct options_struct options_t;