summaryrefslogtreecommitdiff
path: root/src/SocketCore.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-04-03 02:24:41 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-04-03 02:24:41 +0900
commit8580c98bce8e5b85c1cf7be150d9315cd663db93 (patch)
tree5609db1007160261366fe3a2f699bf74f6c606ac /src/SocketCore.h
parent10a19b138209fde31841a4271582b51940e607d4 (diff)
Abstract TLS session implementation
Now TLS session object is abstracted as TLSSession class. Currently, we have GNUTLS and OpenSSL implementations.
Diffstat (limited to 'src/SocketCore.h')
-rw-r--r--src/SocketCore.h37
1 files changed, 8 insertions, 29 deletions
diff --git a/src/SocketCore.h b/src/SocketCore.h
index acabe77c..5d27fe2e 100644
--- a/src/SocketCore.h
+++ b/src/SocketCore.h
@@ -43,16 +43,6 @@
#include <vector>
#include "a2netcompat.h"
-
-#ifdef HAVE_OPENSSL
-// for SSL
-# include <openssl/ssl.h>
-# include <openssl/err.h>
-#endif // HAVE_OPENSSL
-#ifdef HAVE_LIBGNUTLS
-# include <gnutls/gnutls.h>
-#endif // HAVE_LIBGNUTLS
-
#include "SharedHandle.h"
#include "a2io.h"
#include "a2netcompat.h"
@@ -62,6 +52,7 @@ namespace aria2 {
#ifdef ENABLE_SSL
class TLSContext;
+class TLSSession;
#endif // ENABLE_SSL
class SocketCore {
@@ -89,27 +80,9 @@ private:
static SharedHandle<TLSContext> clTlsContext_;
// TLS context for server side
static SharedHandle<TLSContext> svTlsContext_;
-#endif // ENABLE_SSL
-
-#ifdef HAVE_OPENSSL
- // for SSL
- SSL* ssl;
-
- int sslHandleEAGAIN(int ret);
-#endif // HAVE_OPENSSL
-#ifdef HAVE_LIBGNUTLS
- gnutls_session_t sslSession_;
-
- void gnutlsRecordCheckDirection();
-#endif // HAVE_LIBGNUTLS
-
- void init();
-
- void bind(const struct sockaddr* addr, socklen_t addrlen);
- void setSockOpt(int level, int optname, void* optval, socklen_t optlen);
+ SharedHandle<TLSSession> tlsSession_;
-#ifdef ENABLE_SSL
/**
* Makes this socket secure. The connection must be established
* before calling this method.
@@ -119,6 +92,12 @@ private:
bool tlsHandshake(TLSContext* tlsctx, const std::string& hostname);
#endif // ENABLE_SSL
+ void init();
+
+ void bind(const struct sockaddr* addr, socklen_t addrlen);
+
+ void setSockOpt(int level, int optname, void* optval, socklen_t optlen);
+
SocketCore(sock_t sockfd, int sockType);
public:
SocketCore(int sockType = SOCK_STREAM);