@@ -58,6 +58,8 @@ static void print_usage(const char *name)
5858 " -i <interface> work on specified network interface\n"
5959 "\n"
6060 "General Options:\n"
61+ " -0 process inbound connections\n"
62+ " -1 process outbound connections\n"
6163 " -4 process IPv4 connections\n"
6264 " -6 process IPv6 connections\n"
6365 " -d run as a daemon\n"
@@ -86,7 +88,7 @@ int main(int argc, char *argv[])
8688{
8789 unsigned long long tmp ;
8890 int res , opt , exitcode ;
89- char * ipproto_info ;
91+ char * direction_info , * ipproto_info ;
9092
9193 if (!argc || !argv [0 ]) {
9294 print_usage (PROGNAME );
@@ -98,8 +100,16 @@ int main(int argc, char *argv[])
98100
99101 exitcode = EXIT_FAILURE ;
100102
101- while ((opt = getopt (argc , argv , "46b :dfh:i:km:n:r:st:w:x:z" )) != -1 ) {
103+ while ((opt = getopt (argc , argv , "0146b :dfh:i:km:n:r:st:w:x:z" )) != -1 ) {
102104 switch (opt ) {
105+ case '0' :
106+ g_ctx .inbound = 1 ;
107+ break ;
108+
109+ case '1' :
110+ g_ctx .outbound = 1 ;
111+ break ;
112+
103113 case '4' :
104114 g_ctx .use_ipv4 = 1 ;
105115 break ;
@@ -235,6 +245,10 @@ int main(int argc, char *argv[])
235245 return res < 0 ? EXIT_FAILURE : EXIT_SUCCESS ;
236246 }
237247
248+ if (!g_ctx .inbound && !g_ctx .outbound ) {
249+ g_ctx .inbound = g_ctx .outbound = 1 ;
250+ }
251+
238252 if (!g_ctx .use_ipv4 && !g_ctx .use_ipv6 ) {
239253 g_ctx .use_ipv4 = g_ctx .use_ipv6 = 1 ;
240254 }
@@ -324,8 +338,17 @@ int main(int argc, char *argv[])
324338 } else {
325339 ipproto_info = "" ;
326340 }
327- E ("listening on %s%s, netfilter queue number %" PRIu32 "..." , g_ctx .iface ,
328- ipproto_info , g_ctx .nfqnum );
341+
342+ if (g_ctx .inbound && !g_ctx .outbound ) {
343+ direction_info = " (inbound only)" ;
344+ } else if (!g_ctx .inbound && g_ctx .outbound ) {
345+ direction_info = " (outbound only)" ;
346+ } else {
347+ direction_info = "" ;
348+ }
349+
350+ E ("listening on %s%s%s, netfilter queue number %" PRIu32 "..." ,
351+ g_ctx .iface , ipproto_info , direction_info , g_ctx .nfqnum );
329352
330353 /*
331354 Main Loop
0 commit comments