testnftpinhole: call init_redirect() / shutdown_redirect()

This commit is contained in:
Thomas Bernard 2023-11-18 18:15:34 +01:00
parent b3b5dd16d2
commit 25206a7a3f
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
2 changed files with 10 additions and 3 deletions

View File

@ -21,7 +21,7 @@ config.h:
testnftnlrdr: nftnlrdr.o nftnlrdr_misc.o testnftnlrdr.o $(LIBS) testnftnlrdr: nftnlrdr.o nftnlrdr_misc.o testnftnlrdr.o $(LIBS)
testnftpinhole: nftpinhole.o nftnlrdr_misc.o testnftpinhole.o \ testnftpinhole: nftpinhole.o nftnlrdr.o nftnlrdr_misc.o testnftpinhole.o \
../upnputils.o ../linux/getroute.o $(LIBS) ../upnputils.o ../linux/getroute.o $(LIBS)
test_nfct_get: test_nfct_get.o test_nfct_get.o -lmnl -lnetfilter_conntrack test_nfct_get: test_nfct_get.o test_nfct_get.o -lmnl -lnetfilter_conntrack

View File

@ -47,7 +47,7 @@ static void print_infos(unsigned short uid)
int main(int argc, char * * argv) int main(int argc, char * * argv)
{ {
int uid; int uid, r;
const char * ifname = "eth0"; const char * ifname = "eth0";
const char * rem_host = "2a00::dead:beaf"; const char * rem_host = "2a00::dead:beaf";
unsigned short rem_port = 1911; unsigned short rem_port = 1911;
@ -58,6 +58,12 @@ int main(int argc, char * * argv)
openlog("testnftpinhole", LOG_PERROR|LOG_CONS, LOG_LOCAL0); openlog("testnftpinhole", LOG_PERROR|LOG_CONS, LOG_LOCAL0);
r = init_redirect();
if (r < 0) {
syslog(LOG_ERR, "init_redirect() failed");
return 1;
}
uid = add_pinhole(ifname, rem_host, rem_port, int_client, int_port, IPPROTO_TCP, uid = add_pinhole(ifname, rem_host, rem_port, int_client, int_port, IPPROTO_TCP,
"dummy description", upnp_time() + 60 /* timestamp */); "dummy description", upnp_time() + 60 /* timestamp */);
syslog(LOG_INFO, "add_pinhole(): uid=%d", uid); syslog(LOG_INFO, "add_pinhole(): uid=%d", uid);
@ -68,7 +74,6 @@ int main(int argc, char * * argv)
syslog(LOG_INFO, "find_pinhole(): uid=%d desc=\"%s\" timestamp=%u", uid, desc, timestamp); syslog(LOG_INFO, "find_pinhole(): uid=%d desc=\"%s\" timestamp=%u", uid, desc, timestamp);
if (uid >= 0) { if (uid >= 0) {
int r;
print_infos(uid); print_infos(uid);
r = update_pinhole(uid, upnp_time() + 3600); r = update_pinhole(uid, upnp_time() + 3600);
@ -79,6 +84,8 @@ int main(int argc, char * * argv)
syslog(LOG_INFO, "delete_pinhole(%d) returned %d", uid, r); syslog(LOG_INFO, "delete_pinhole(%d) returned %d", uid, r);
} }
shutdown_redirect();
return 0; return 0;
} }