summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/anyrtpproxy/commandHandler.cpp6
-rw-r--r--src/anyrtpproxy/options.cpp17
-rw-r--r--src/anyrtpproxy/options.h3
3 files changed, 25 insertions, 1 deletions
diff --git a/src/anyrtpproxy/commandHandler.cpp b/src/anyrtpproxy/commandHandler.cpp
index 032d001..6df044e 100644
--- a/src/anyrtpproxy/commandHandler.cpp
+++ b/src/anyrtpproxy/commandHandler.cpp
@@ -41,6 +41,7 @@
#include "../syncCommand.h"
#include "../rtpSessionTable.h"
#include "callIdQueue.h"
+#include "options.h"
#define MAX_COMMAND_LENGTH 1000
@@ -179,7 +180,10 @@ string CommandHandler::handleRequest(string modifiers, string call_id, string ad
throw std::runtime_error("no free port found");
}
- session.setLocalAddr("0.0.0.0"); // TODO: read this from config
+ if(gOpt.getLocalAddr() == "")
+ session.setLocalAddr("0.0.0.0");
+ else
+ session.setLocalAddr(gOpt.getLocalAddr());
session.setLocalPort1(port1);
session.setLocalPort2(port2);
}
diff --git a/src/anyrtpproxy/options.cpp b/src/anyrtpproxy/options.cpp
index be912e2..ed01020 100644
--- a/src/anyrtpproxy/options.cpp
+++ b/src/anyrtpproxy/options.cpp
@@ -57,6 +57,7 @@ Options::Options() : control_interface_("0.0.0.0", 22222)
username_ = "nobody";
chroot_dir_ = "/var/run";
daemonize_ = true;
+ local_addr_ = "";
local_sync_port_ = 0;
rtp_start_port_ = 34000;
rtp_end_port_ = 35000;
@@ -161,6 +162,7 @@ bool Options::parse(int argc, char* argv[])
PARSE_SCALAR_PARAM("-u","--user", username_)
PARSE_SCALAR_PARAM("-c","--chroot-dir", chroot_dir_)
PARSE_INVERSE_BOOL_PARAM("-d","--nodaemonize", daemonize_)
+ PARSE_SCALAR_PARAM("-i","--interface", local_addr_)
PARSE_STRING_PARAM("-s","--control", control_interface_)
PARSE_SCALAR_PARAM2("-p","--port-range", rtp_start_port_, rtp_end_port_)
PARSE_CSLIST_PARAM("-M","--sync-hosts", host_port_queue)
@@ -198,6 +200,7 @@ void Options::printUsage()
std::cout << " [-u|--username] <username> in case of chroot run as this user" << std::endl;
std::cout << " [-c|--chroot-dir] <directory> directory to make a chroot to" << std::endl;
std::cout << " [-d|--nodaemonize] don't run in background" << std::endl;
+ std::cout << " [-i|--interface] <ip-address> local ip address to listen to for RTP packets" << std::endl;
std::cout << " [-s|--control] <addr[:port]> the address/port to listen on for control commands" << std::endl;
std::cout << " [-p|--port-range] <start> <end> port range used to relay rtp connections" << std::endl;
std::cout << " [-n|--nat] enable permantent automatic nat detection(use only with anytun)" << std::endl;
@@ -217,6 +220,7 @@ void Options::printOptions()
std::cout << "chroot-dir='" << chroot_dir_ << "'" << std::endl;
std::cout << "daemonize='" << daemonize_ << "'" << std::endl;
std::cout << "control-interface='" << control_interface_.toString() << "'" << std::endl;
+ std::cout << "local_addr='" << local_addr_ << "'" << std::endl;
}
std::string Options::getProgname()
@@ -267,6 +271,19 @@ Host Options::getControlInterface()
return control_interface_;
}
+std::string Options::getLocalAddr()
+{
+ Lock lock(mutex);
+ return local_addr_;
+}
+
+Options& Options::setLocalAddr(std::string l)
+{
+ Lock lock(mutex);
+ local_addr_ = l;
+ return *this;
+}
+
u_int16_t Options::getLocalSyncPort()
{
return local_sync_port_;
diff --git a/src/anyrtpproxy/options.h b/src/anyrtpproxy/options.h
index b6ac957..1eb176d 100644
--- a/src/anyrtpproxy/options.h
+++ b/src/anyrtpproxy/options.h
@@ -83,6 +83,8 @@ public:
std::string getChrootDir();
bool getDaemonize();
Host getControlInterface();
+ std::string getLocalAddr();
+ Options& setLocalAddr(std::string l);
u_int16_t getLocalSyncPort();
Options& setLocalSyncPort(u_int16_t l);
u_int16_t getRtpStartPort();
@@ -118,6 +120,7 @@ private:
std::string chroot_dir_;
bool daemonize_;
u_int16_t local_sync_port_;
+ std::string local_addr_;
u_int16_t rtp_start_port_;
u_int16_t rtp_end_port_;
ConnectToList connect_to_;