summaryrefslogtreecommitdiff
path: root/syncSocket.cpp
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2007-12-12 16:14:44 +0000
committerOthmar Gsenger <otti@anytun.org>2007-12-12 16:14:44 +0000
commit0b6d2c2c6e866ff9f2ff095003d8299291446f4d (patch)
treec7f279fdd8aef1acfc932c16bfc6cd78c77cffd3 /syncSocket.cpp
parent* renamed HmacAuthAlgo to Sha1AuthAlgo (diff)
added full sync support (max 2 anycast servers)
Diffstat (limited to 'syncSocket.cpp')
-rw-r--r--syncSocket.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/syncSocket.cpp b/syncSocket.cpp
index f22ad21..5db5fbd 100644
--- a/syncSocket.cpp
+++ b/syncSocket.cpp
@@ -9,6 +9,8 @@
//#include "connectionParam.h"
#include "Sockets/Utility.h"
#include "syncSocket.h"
+#include "buffer.h"
+//#include "log.h"
SyncSocket::SyncSocket(ISocketHandler& h,ConnectionList & cl)
:TcpSocket(h),cl_(cl)
@@ -47,18 +49,31 @@ void SyncSocket::OnAccept()
boost::archive::text_oarchive oa(sout);
const ConnectionParam conn = cl_.getConnection();
oa << conn;
- Send(sout.str());
+ Send(sout.str()+"\n");
}
}
-void SyncSocket::OnRawData(const char *buf,size_t len)
+//void SyncSocket::OnRawData(const char *buf,size_t len)
+void SyncSocket::OnLine(const std::string& line)
{
- std::cout << "recieved sync inforamtaion:"<< std::endl;
- for(size_t index=0;index<len;index++)
- {
- std::cout << buf[index];
- }
- std::cout << std::endl;
+// std::cout << "recieved sync inforamtaion:"<< std::endl;
+// for(size_t index=0;index<len;index++)
+// {
+// std::cout << buf[index];
+// }
+ std::cout << line << std::endl;
+ std::istringstream iss;
+ iss.str(line);
+ boost::archive::text_iarchive ia(iss);
+ SeqWindow * seq= new SeqWindow(0);
+ seq_nr_t seq_nr_=0;
+ KeyDerivation * kd = new KeyDerivation;
+ kd->init(::Buffer(), ::Buffer());
+ ConnectionParam conn ( (*kd), (*seq), seq_nr_, "", 0);
+ ia >> conn;
+ std::cout << "sync connection remote host " << conn.remote_host_ << ":" << conn.remote_port_ << std::endl;
+ cl_.clear();
+ cl_.addConnection(conn,std::string("default"));
}
//void StatusSocket::InitSSLServer()
//{