summaryrefslogtreecommitdiffstats
path: root/src/Net
diff options
context:
space:
mode:
Diffstat (limited to 'src/Net')
-rw-r--r--src/Net/ClientConnection.cpp7
-rw-r--r--src/Net/Connection.cpp10
-rw-r--r--src/Net/Connection.h12
3 files changed, 14 insertions, 15 deletions
diff --git a/src/Net/ClientConnection.cpp b/src/Net/ClientConnection.cpp
index d818f7e..695cba5 100644
--- a/src/Net/ClientConnection.cpp
+++ b/src/Net/ClientConnection.cpp
@@ -56,13 +56,18 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Con
daemon = daemon0;
if(isConnected())
- disconnect();
+ return;
+ // TODO Error
sock = socket(PF_INET, SOCK_STREAM, 0);
if(sock < 0)
throw ConnectionException("socket()", std::strerror(errno));
+ if(peer)
+ delete peer;
peer = new IPAddress(address);
+ authenticated = false;
+ identified = false;
if(::connect(sock, peer->getSockAddr(), peer->getSockAddrLength()) < 0) {
close(sock);
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index 22f4570..8eee0cc 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -38,6 +38,9 @@ Connection::~Connection() {
}
gnutls_certificate_free_credentials(x509_cred);
+
+ if(peer)
+ delete peer;
}
void Connection::handshake() {
@@ -276,13 +279,6 @@ void Connection::doDisconnect() {
gnutls_deinit(session);
- if(peer)
- delete peer;
- peer = 0;
-
- authenticated = false;
- name.clear();
-
state = DISCONNECTED;
}
diff --git a/src/Net/Connection.h b/src/Net/Connection.h
index 953ccc8..77b8cc4 100644
--- a/src/Net/Connection.h
+++ b/src/Net/Connection.h
@@ -56,9 +56,6 @@ class Connection {
sigc::signal<void,Connection*,const Packet&> signal;
- bool authenticated;
- std::string name;
-
void doHandshake();
void packetHeaderReceiveHandler(const void *data, unsigned long length);
@@ -99,6 +96,7 @@ class Connection {
gnutls_certificate_credentials_t x509_cred;
IPAddress *peer;
+ bool authenticated, identified;
void handshake();
@@ -110,7 +108,7 @@ class Connection {
bool enterReceiveLoop();
public:
- Connection() : state(DISCONNECTED), authenticated(false), peer(0) {
+ Connection() : state(DISCONNECTED), peer(0), authenticated(false), identified(false) {
transR.length = transR.transmitted = 0;
transR.data = 0;
@@ -131,6 +129,9 @@ class Connection {
bool isAuthenticated() const {return authenticated;}
void setAuthenticated() {authenticated = true;}
+ bool isIdentified() const {return identified;}
+ void setIdentified() {identified = true;}
+
const gnutls_datum_t* getCertificate() {
return gnutls_certificate_get_ours(session);
}
@@ -155,9 +156,6 @@ class Connection {
sigc::signal<void,Connection*,const Packet&> signalReceive() const {return signal;}
- std::string getName() const {return name;}
- void setName(const std::string& name0) {name = name0;}
-
static void init() {
gnutls_global_init();
}