summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2008-02-28 20:52:02 +0000
committerErwin Nindl <nine@wirdorange.org>2008-02-28 20:52:02 +0000
commit24cafee6154b7e4e3b206f8a88fa08ffca11b2b1 (patch)
treed8841d8650d0a25e5c01af85b2dbc1681b5ab660
parentsync bugfix (diff)
added file parameter to anymux
modified makefile
-rw-r--r--Makefile14
-rw-r--r--anymux.cpp23
-rw-r--r--muxSocket.cpp10
-rw-r--r--muxSocket.h6
4 files changed, 35 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 17bae3a..e45a271 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,6 @@ OBJS = tunDevice.o \
keyDerivation.o \
mpi.o \
cipherFactory.o \
- muxSocket.o \
authAlgoFactory.o \
keyDerivationFactory.o \
connectionList.o \
@@ -81,6 +80,12 @@ OBJS = tunDevice.o \
$(OPENVPNDEPS) \
$(SOCKETDEPS)
+ANYMUXOBJS = muxSocket.o \
+ anymuxOptions.o \
+ signalController.o \
+ log.o \
+ $(SOCKETDEPS)
+
EXECUTABLE = anytun anyctr anymux anytun-showtables
all: $(EXECUTABLE) libAnysync.a
@@ -94,8 +99,8 @@ anytun-showtables: $(OBJS) anytun-showtables.o
anyctr: $(OBJS) anyctr.o
$(LD) $(OBJS) anyctr.o -o $@ $(LDFLAGS)
-anymux: $(OBJS) anymux.o
- $(LD) $(OBJS) anymux.o -o $@ $(LDFLAGS)
+anymux: $(ANYMUXOBJS) anymux.o
+ $(LD) $(ANYMUXOBJS) anymux.o -o $@ $(LDFLAGS)
tunDevice.o: tunDevice.cpp tunDevice.h
$(C++) $(CCFLAGS) $< -c
@@ -121,6 +126,9 @@ cipher.o: cipher.cpp cipher.h buffer.h
muxSocket.o: muxSocket.cpp muxSocket.h
$(C++) $(CCFLAGS) $< -c
+anymuxOptions.o: anymuxOptions.cpp anymuxOptions.h
+ $(C++) $(CCFLAGS) $< -c
+
authAlgo.o: authAlgo.cpp authAlgo.h buffer.h
$(C++) $(CCFLAGS) $< -c
diff --git a/anymux.cpp b/anymux.cpp
index f02a3f4..8f0bc55 100644
--- a/anymux.cpp
+++ b/anymux.cpp
@@ -31,27 +31,32 @@
#include <iostream>
#include <poll.h>
-#include <cerrno> // for ENOMEM
-
#include "datatypes.h"
#include "log.h"
#include "signalController.h"
-#include "options.h"
+#include "anymuxOptions.h"
#include "muxSocket.h"
#include "Sockets/ListenSocket.h"
#include "Sockets/SocketHandler.h"
-void* syncListener(void* p )
+class ThreadParam
{
- //ThreadParam* param = reinterpret_cast<ThreadParam*>(p);
+public:
+ ThreadParam() : port(0) {};
+ u_int16_t port;
+};
+
+void* syncListener(void* p )
+{
+ ThreadParam* param = reinterpret_cast<ThreadParam*>(p);
SOCKETS_NAMESPACE::SocketHandler h;
SOCKETS_NAMESPACE::ListenSocket<MuxSocket> l(h,true);
- if (l.Bind(1234))
+ if( l.Bind(param->port) )
pthread_exit(NULL);
Utility::ResolveLocal(); // resolve local hostname
@@ -72,10 +77,10 @@ int main(int argc, char* argv[])
SignalController sig;
sig.init();
-// ThreadParam p(4445);
- int port;
+ ThreadParam p;
+ p.port = gOpt.getLocalPort();
pthread_t syncListenerThread;
- pthread_create(&syncListenerThread, NULL, syncListener, &port);
+ pthread_create(&syncListenerThread, NULL, syncListener, &p);
int ret = sig.run();
diff --git a/muxSocket.cpp b/muxSocket.cpp
index ac49415..0e0a43f 100644
--- a/muxSocket.cpp
+++ b/muxSocket.cpp
@@ -3,26 +3,26 @@
#include <fstream>
#include <string>
+#include "anymuxOptions.h"
+
#include "Sockets/Utility.h"
#include "muxSocket.h"
+
#ifdef SOCKETS_NAMESPACE
using namespace SOCKETS_NAMESPACE;
#endif // SOCKETS_NAMESPACE
-MuxSocket::MuxSocket(ISocketHandler& h)
-:TcpSocket(h)
+MuxSocket::MuxSocket(ISocketHandler& h) : TcpSocket(h), filename_(gOpt.getFileName())
{
SetConnectTimeout(12);
}
-
void MuxSocket::OnAccept()
{
- std::string filename("testoutput.txt");
- std::ifstream file(filename.c_str());
+ std::ifstream file(filename_.c_str());
if( file.is_open() )
{
std::string line;
diff --git a/muxSocket.h b/muxSocket.h
index 9b431b4..e32c45d 100644
--- a/muxSocket.h
+++ b/muxSocket.h
@@ -8,15 +8,19 @@
using namespace SOCKETS_NAMESPACE;
#endif // SOCKETS_NAMESPACE
+
class MuxSocket : public TcpSocket
{
public:
- MuxSocket(ISocketHandler& );
+ MuxSocket(ISocketHandler&);
void OnAccept();
// void Init();
// void InitSSLServer();
+
+private:
+ std::string filename_;
};