summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorArturo Borrero <arturo.borrero.glez@gmail.com>2014-11-06 09:05:28 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2014-11-06 12:51:40 +0100
commit31f031b0d348afd1c343692eca4b496c4bf5d05d (patch)
tree7012e6344f70274e8cfcdcd093241730ec4270ff /src/main.c
parent3cc636eda67c9dd416e584e21ccb9031d44dcbd0 (diff)
nft: don't resolve hostnames by default
This patch changes the default behaviour of nft to not translate IP addresses to hostnames when printing rules if no options are passed. The options regarding translations after this patch are: <no -n/-N> show IP addresses numerically (default behaviour) -n show IP addresses numerically -nn show Internet services and uid/gid numerically -nnn show protocols numerically -N (--reversedns) translate IP addresses to names The idea is to avoid breaking existing scripts that most likely rely on '-n' to save the ruleset, so we reduce the impact of this patch and provide a default behaviour that doesn't generate network traffic when listing / saving the ruleset. Joint work with Pablo. Suggested-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 3607bd58..16259143 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,6 +28,7 @@
unsigned int max_errors = 10;
unsigned int numeric_output;
+unsigned int ip2name_output;
unsigned int handle_output;
#ifdef DEBUG
unsigned int debug_level;
@@ -43,12 +44,13 @@ enum opt_vals {
OPT_INTERACTIVE = 'i',
OPT_INCLUDEPATH = 'I',
OPT_NUMERIC = 'n',
+ OPT_IP2NAME = 'N',
OPT_DEBUG = 'd',
OPT_HANDLE_OUTPUT = 'a',
OPT_INVALID = '?',
};
-#define OPTSTRING "hvf:iI:vna"
+#define OPTSTRING "hvf:iI:vnNa"
static const struct option options[] = {
{
@@ -73,6 +75,10 @@ static const struct option options[] = {
.val = OPT_NUMERIC,
},
{
+ .name = "reversedns",
+ .val = OPT_IP2NAME,
+ },
+ {
.name = "includepath",
.val = OPT_INCLUDEPATH,
.has_arg = 1,
@@ -105,10 +111,11 @@ static void show_help(const char *name)
" -f/--file <filename> Read input from <filename>\n"
" -i/--interactive Read input from interactive CLI\n"
"\n"
-" -n/--numeric When specified once, show network addresses numerically.\n"
-" When specified twice, also show Internet services,\n"
+" -n/--numeric When specified once, show network addresses numerically (default behaviour).\n"
+" When specified twice, show Internet services,\n"
" user IDs and group IDs numerically.\n"
" When specified thrice, also show protocols numerically.\n"
+" -N Translate IP addresses to names.\n"
" -a/--handle Output rule handle.\n"
" -I/--includepath <directory> Add <directory> to the paths searched for include files.\n"
#ifdef DEBUG
@@ -279,6 +286,9 @@ int main(int argc, char * const *argv)
case OPT_NUMERIC:
numeric_output++;
break;
+ case OPT_IP2NAME:
+ ip2name_output++;
+ break;
#ifdef DEBUG
case OPT_DEBUG:
for (;;) {