diff options
author | Christian Pointner <equinox@anytun.org> | 2009-03-22 18:49:35 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-03-22 18:49:35 +0000 |
commit | 6be7bf8698f0f374281343ad709d4977297be449 (patch) | |
tree | 91b5a652c3fb0ff71cb61b8b939bcb1cfaff05fe | |
parent | added error callback to resolver for better handling (diff) |
added gResolver to anytun-config
-rw-r--r-- | src/Makefile | 3 | ||||
-rw-r--r-- | src/anytun-config.cpp | 28 | ||||
-rw-r--r-- | src/options.cpp | 7 |
3 files changed, 28 insertions, 10 deletions
diff --git a/src/Makefile b/src/Makefile index 78806ee..4f75c70 100644 --- a/src/Makefile +++ b/src/Makefile @@ -97,7 +97,8 @@ ANYCONFOBJS := log.o \ syncServer.o \ syncTcpConnection.o \ syncRouteCommand.o \ - syncConnectionCommand.o + syncConnectionCommand.o \ + resolver.o EXECUTABLE := anytun anytun-config anytun-controld anytun-showtables anytun-nosync EXEOBJS := anytun.o anytun-config.o anytun-controld.o anytun-showtables.o diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp index 466c36f..75f418a 100644 --- a/src/anytun-config.cpp +++ b/src/anytun-config.cpp @@ -43,13 +43,14 @@ #include "routingTable.h" #include "networkAddress.h" #include "packetSource.h" +#include "resolver.h" #include "syncQueue.h" #include "syncCommand.h" -void createConnection(const PacketSourceEndpoint & remote_end, ConnectionList & cl, u_int16_t seqSize, SyncQueue & queue, mux_t mux) +void createConnection(const PacketSourceEndpoint & remote_end, ConnectionList & cl, u_int16_t seqSize, SyncQueue & queue, mux_t mux, Semaphore& sem) { SeqWindow * seq = new SeqWindow(seqSize); seq_nr_t seq_nr_ = 0; @@ -83,11 +84,18 @@ void createConnection(const PacketSourceEndpoint & remote_end, ConnectionList & oa2 << scom2; std::cout << std::setw(5) << std::setfill('0') << sout2.str().size()<< ' ' << sout2.str() << std::endl; } + sem.up(); +} + +void createConnectionError(const std::exception& e, Semaphore& sem, int& ret) +{ + cLog.msg(Log::PRIO_ERROR) << "uncaught runtime error: " << e.what(); + ret = -1; + sem.up(); } int main(int argc, char* argv[]) { - int ret=0; try { bool result = gOpt.parse(argc, argv); @@ -114,19 +122,21 @@ int main(int argc, char* argv[]) gOpt.parse_post(); // print warnings + gResolver.init(); ConnectionList cl; SyncQueue queue; + Semaphore sem; + int ret = 0; UDPPacketSource::proto::endpoint endpoint; - if (gOpt.getRemoteAddr()!="" && gOpt.getRemotePort()!="") - { - boost::asio::io_service io_service; - UDPPacketSource::proto::resolver resolver(io_service); - UDPPacketSource::proto::resolver::query query(gOpt.getRemoteAddr(), gOpt.getRemotePort()); - endpoint = *resolver.resolve(query); + if (gOpt.getRemoteAddr()!="" && gOpt.getRemotePort()!="") { + gResolver.resolveUdp(gOpt.getRemoteAddr(), gOpt.getRemotePort(), + boost::bind(createConnection, _1, boost::ref(cl), gOpt.getSeqWindowSize(), boost::ref(queue), gOpt.getMux(), boost::ref(sem)), + boost::bind(createConnectionError, _1, boost::ref(sem), boost::ref(ret)), + gOpt.getResolvAddrType()); + sem.down(); } - createConnection(endpoint,cl,gOpt.getSeqWindowSize(), queue, gOpt.getMux()); return ret; } diff --git a/src/options.cpp b/src/options.cpp index 94e3c44..7d01d49 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -179,6 +179,7 @@ Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0)) mux_ = 0; seq_window_size_ = 0; +#if !defined(ANYCONF_OPTIONS) #ifndef NO_CRYPT cipher_ = "aes-ctr"; auth_algo_ = "sha1"; @@ -190,6 +191,12 @@ Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0)) auth_tag_length_ = 0; kd_prf_ = "null"; #endif +#else + cipher_ = "null"; + auth_algo_ = "null"; + auth_tag_length_ = 0; + kd_prf_ = "null"; +#endif role_ = ROLE_LEFT; anytun02_compat_ = false; } |