diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/anytun.cpp | 14 | ||||
-rw-r--r-- | src/options.cpp | 26 | ||||
-rw-r--r-- | src/options.h | 28 |
3 files changed, 40 insertions, 28 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp index aec1f6d..2b95b13 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -215,7 +215,19 @@ void syncListener(SyncQueue * queue ) try { boost::asio::io_service io_service; - SyncServer server(io_service,boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), gOpt.getLocalSyncPort())); + boost::asio::ip::tcp::resolver resolver(io_service); + boost::asio::ip::tcp::endpoint e; + if(gOpt.getLocalSyncAddr()!="") + { + boost::asio::ip::tcp::resolver::query query(gOpt.getLocalSyncAddr(), gOpt.getLocalSyncPort()); + e = *resolver.resolve(query); + } else { + boost::asio::ip::tcp::resolver::query query(gOpt.getLocalSyncPort()); + e = *resolver.resolve(query); + } + + + SyncServer server(io_service,e); server.onConnect=boost::bind(syncOnConnect,_1); queue->setSyncServerPtr(&server); io_service.run(); diff --git a/src/options.cpp b/src/options.cpp index 3439187..806c7c8 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -62,12 +62,12 @@ Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0)) pid_file_ = ""; sender_id_ = 0; local_addr_ = ""; - local_port_ = 4444; - local_sync_port_ = 0; - remote_sync_port_ = 0; + local_port_ = "4444"; + local_sync_port_ = ""; + remote_sync_port_ = ""; remote_sync_addr_ = ""; remote_addr_ = ""; - remote_port_ = 4444; + remote_port_ = "4444"; dev_name_ = ""; dev_type_ = ""; ifconfig_param_local_ = ""; @@ -396,34 +396,34 @@ Options& Options::setLocalSyncAddr(std::string l) return *this; } -u_int16_t Options::getLocalPort() +std::string Options::getLocalPort() { return local_port_; } -Options& Options::setLocalPort(u_int16_t l) +Options& Options::setLocalPort(std::string l) { local_port_ = l; return *this; } -u_int16_t Options::getLocalSyncPort() +std::string Options::getLocalSyncPort() { return local_sync_port_; } -Options& Options::setLocalSyncPort(u_int16_t l) +Options& Options::setLocalSyncPort(std::string l) { local_sync_port_ = l; return *this; } -u_int16_t Options::getRemoteSyncPort() +std::string Options::getRemoteSyncPort() { return remote_sync_port_; } -Options& Options::setRemoteSyncPort(u_int16_t l) +Options& Options::setRemoteSyncPort(std::string l) { remote_sync_port_ = l; return *this; @@ -455,18 +455,18 @@ Options& Options::setRemoteAddr(std::string r) return *this; } -u_int16_t Options::getRemotePort() +std::string Options::getRemotePort() { return remote_port_; } -Options& Options::setRemotePort(u_int16_t r) +Options& Options::setRemotePort(std::string r) { remote_port_ = r; return *this; } -Options& Options::setRemoteAddrPort(std::string addr, u_int16_t port) +Options& Options::setRemoteAddrPort(std::string addr, std::string port) { Lock lock(mutex); remote_addr_ = addr; diff --git a/src/options.h b/src/options.h index 98210b1..4224640 100644 --- a/src/options.h +++ b/src/options.h @@ -40,7 +40,7 @@ typedef struct { std::string host; - uint16_t port; + std::string port; } OptionConnectTo; typedef std::list<OptionConnectTo> ConnectToList; @@ -74,17 +74,17 @@ public: Options& setLocalSyncAddr(std::string l); std::string getRemoteSyncAddr(); Options& setRemoteSyncAddr(std::string l); - u_int16_t getRemoteSyncPort(); - Options& setRemoteSyncPort(u_int16_t l); - u_int16_t getLocalPort(); - Options& setLocalPort(u_int16_t l); + std::string getRemoteSyncPort(); + Options& setRemoteSyncPort(std::string l); + std::string getLocalPort(); + Options& setLocalPort(std::string l); std::string getRemoteAddr(); Options& setRemoteAddr(std::string r); - u_int16_t getLocalSyncPort(); - Options& setLocalSyncPort(u_int16_t l); - u_int16_t getRemotePort(); - Options& setRemotePort(u_int16_t r); - Options& setRemoteAddrPort(std::string addr, u_int16_t port); + std::string getLocalSyncPort(); + Options& setLocalSyncPort(std::string l); + std::string getRemotePort(); + Options& setRemotePort(std::string r); + Options& setRemoteAddrPort(std::string addr, std::string port); std::string getDevName(); Options& setDevName(std::string d); std::string getDevType(); @@ -139,12 +139,12 @@ private: sender_id_t sender_id_; std::string local_addr_; std::string local_sync_addr_; - u_int16_t local_port_; - u_int16_t local_sync_port_; + std::string local_port_; + std::string local_sync_port_; std::string remote_sync_addr_; - u_int16_t remote_sync_port_; + std::string remote_sync_port_; std::string remote_addr_; - u_int16_t remote_port_; + std::string remote_port_; std::string dev_name_; std::string dev_type_; std::string ifconfig_param_local_; |