From 241dba405ae682885ec57e4747c6a4ac83575e17 Mon Sep 17 00:00:00 2001 From: Samuel Jero Date: Thu, 12 Jun 2014 20:28:44 -0500 Subject: [PATCH] Add --bindport option to force TCP source port. https://lists.gnu.org/archive/html/bug-wget/2014-01/msg00070.html --- src/connect.c | 4 ++-- src/init.c | 1 + src/main.c | 1 + src/options.h | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/connect.c b/src/connect.c index 1e4a44ba..90e2abf4 100644 --- a/src/connect.c +++ b/src/connect.c @@ -190,7 +190,7 @@ resolve_bind_address (struct sockaddr *sa) if (called) { if (should_bind) - sockaddr_set_data (sa, &ip, 0); + sockaddr_set_data (sa, &ip, opt.bind_port); return should_bind; } called = true; @@ -212,7 +212,7 @@ resolve_bind_address (struct sockaddr *sa) ip = *address_list_address_at (al, 0); address_list_release (al); - sockaddr_set_data (sa, &ip, 0); + sockaddr_set_data (sa, &ip, opt.bind_port); should_bind = true; return true; } diff --git a/src/init.c b/src/init.c index 9a6fd2b5..fd8eb0c0 100644 --- a/src/init.c +++ b/src/init.c @@ -138,6 +138,7 @@ static const struct { { "backups", &opt.backups, cmd_number }, { "base", &opt.base_href, cmd_string }, { "bindaddress", &opt.bind_address, cmd_string }, + { "bindport", &opt.bind_port, cmd_number }, { "bodydata", &opt.body_data, cmd_string }, { "bodyfile", &opt.body_file, cmd_string }, #ifdef HAVE_SSL diff --git a/src/main.c b/src/main.c index 4b230531..1e087067 100644 --- a/src/main.c +++ b/src/main.c @@ -161,6 +161,7 @@ static struct cmdline_option option_data[] = { "backups", 0, OPT_BOOLEAN, "backups", -1 }, { "base", 'B', OPT_VALUE, "base", -1 }, { "bind-address", 0, OPT_VALUE, "bindaddress", -1 }, + { "bind-port", 0, OPT_VALUE, "bindport", -1 }, { "body-data", 0, OPT_VALUE, "bodydata", -1 }, { "body-file", 0, OPT_VALUE, "bodyfile", -1 }, { IF_SSL ("ca-certificate"), 0, OPT_VALUE, "cacertificate", -1 }, diff --git a/src/options.h b/src/options.h index cd4e5188..ccca0d30 100644 --- a/src/options.h +++ b/src/options.h @@ -195,6 +195,7 @@ struct options bool page_requisites; /* Whether we need to download all files necessary to display a page properly. */ char *bind_address; /* What local IP address to bind to. */ + int bind_port; /* What local port to bind to. */ #ifdef HAVE_SSL enum { -- 2.39.2