From: Remi Gacogne Date: Thu, 9 Mar 2017 14:59:44 +0000 (+0100) Subject: dnsreplay: Add `--source-ip` and `--source-port` options X-Git-Tag: rec-4.1.0-alpha1~213^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F5130%2Fhead;p=thirdparty%2Fpdns.git dnsreplay: Add `--source-ip` and `--source-port` options --- diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index f6b27d2693..4e6874ecb4 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -709,7 +709,9 @@ try ("speedup", po::value()->default_value(1), "replay at this speedup") ("timeout-msec", po::value()->default_value(500), "wait at least this many milliseconds for a reply") ("ecs-stamp", "Add original IP address to ECS in replay") - ("ecs-mask", po::value(), "Replace first octet of src IP address with this value in ECS"); + ("ecs-mask", po::value(), "Replace first octet of src IP address with this value in ECS") + ("source-ip", po::value()->default_value(""), "IP to send the replayed packet from") + ("source-port", po::value()->default_value(0), "Port to send the replayed packet from"); po::options_description alloptions; po::options_description hidden("hidden options"); @@ -759,6 +761,10 @@ try s_socket= new Socket(AF_INET, SOCK_DGRAM); s_socket->setNonBlocking(); + + if(g_vm.count("source-ip") && !g_vm["source-ip"].as().empty()) + s_socket->bind(ComboAddress(g_vm["source-ip"].as(), g_vm["source-port"].as())); + setSocketReceiveBuffer(s_socket->getHandle(), 2000000); setSocketSendBuffer(s_socket->getHandle(), 2000000);