From 12abc2e3aa350b7930b07ec26426f541ff033357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= <ecklm94@gmail.com> Date: Fri, 27 May 2016 09:57:12 +0200 Subject: [PATCH] =?UTF-8?q?Port=20be=C3=A1ll=C3=ADthat=C3=B3s=C3=A1g=20?= =?UTF-8?q?=C3=A9s=20n=C3=A9mi=20manual=20jav=C3=ADt=C3=A1s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/main.cpp b/main.cpp index 457edff..c66faf7 100644 --- a/main.cpp +++ b/main.cpp @@ -32,14 +32,14 @@ void print_help(); int main(int argc, char *argv[]) { int cli_option; - int thread_num = 1; + int thread_num = 1, port = 53; char working_dir[PATH_MAX] = { 0 }; getcwd(working_dir, PATH_MAX-1 ); bool run_as_daemon = false; std::vector<command> command_list; - while((cli_option = getopt (argc, argv, "dkvt:w:h")) != -1) + while((cli_option = getopt (argc, argv, "dkvt:w:p:h")) != -1) { - int ti = 0; + int tmp = 0; switch(cli_option) { case 'd': @@ -52,13 +52,18 @@ int main(int argc, char *argv[]) verbose = true; break; case 't': - ti = atoi(optarg); - if(ti>0) - thread_num = ti; + tmp = atoi(optarg); + if(tmp > 0) + thread_num = tmp; break; case 'w': strncpy(working_dir, optarg, PATH_MAX-1); break; + case 'p': + tmp = atoi(optarg); + if(tmp > 1) + port = tmp; + break; case 'h': print_help(); exit(EXIT_SUCCESS); @@ -87,7 +92,7 @@ int main(int argc, char *argv[]) if(getuid() != 0) { - log_on_demand(LOG_ERR, "You should run with root privileges!"); + log_on_demand(LOG_ERR, "You should run it with root privileges!"); exit(EXIT_FAILURE); } @@ -150,7 +155,7 @@ int main(int argc, char *argv[]) memset(&server_address, 0, sizeof(server_address)); server_address.sin6_family = AF_INET6; server_address.sin6_addr = in6_addr_any; - server_address.sin6_port = htons(10053); + server_address.sin6_port = htons(port); server.init(general_sockaddr_wp((sockaddr *) &server_address, sizeof(server_address))); if(verbose) @@ -192,12 +197,18 @@ Therefore and some other reason the server must be run with root privileges. In daemon mode, the working directory must contain the dns.db file. +There are some command line options with which you can make +modifications to the default attributes of the runtime. +See them below. + Options: - -d Run as daemon - -t threads Number of threads to start. Only makes sense with -d. - -k Kill daemon - -w workind_dir Set working directory. Absolute path needed. + -d Run as daemon. + -t THREAD_NUMBER Number of threads to start. Only makes sense with -d. + -k Kill daemon. + -w WORKING_DIR Set working directory. Absolute path needed. If not set, the actual PWD will be used. + -p PORT Specifies the port for the server to bind to. + Only makes sense with -d -v Verbose -h help )"); -- GitLab