-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a6cada
commit 5a488f5
Showing
6 changed files
with
43 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
- [x] 抽象出epoll层 | ||
- [ ] 支持SSL | ||
- [x] accept 改造 | ||
- [ ] 完善多线程 | ||
- [x] 完善多线程 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include "address.hpp" | ||
#include <cstring> | ||
#include <sys/socket.h> | ||
#include <unistd.h> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
#ifdef CPPNET_OPENSSL | ||
#include "../socket/socket.hpp" | ||
#include <openssl/ssl.h> | ||
|
||
namespace cppnet { | ||
|
||
class SSLConnect { | ||
public: | ||
SSLConnect(SSL *ssl) : ssl_(ssl){}; | ||
virtual ~SSLConnect(); | ||
int BindSoc(const Socket &soc) const; | ||
int Read(void *buf, size_t len, bool complete = false) const; | ||
int Read(std::string &buf, size_t len, bool complete = false) const; | ||
int Write(const void *buf, size_t len) const; | ||
int Write(const std::string &buf) const; | ||
void Close(); | ||
|
||
private: | ||
SSL *ssl_ = nullptr; | ||
}; | ||
|
||
} // namespace cppnet | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
#pragma once | ||
#include <memory> | ||
#ifdef CPPNET_OPENSSL | ||
#include "ssl_connect.hpp" | ||
#include <openssl/ssl.h> | ||
|
||
namespace cppnet { | ||
|
||
class SSLContext { | ||
public: | ||
SSLContext(); | ||
~SSLContext(); | ||
int Init(const std::string &cert_path, const std::string &key_path, | ||
const std::string &password = ""); | ||
std::shared_ptr<SSLConnect> CreateSSLConnect() const; | ||
|
||
public: | ||
const std::string &err_msg() const { return err_msg_; } | ||
|
||
private: | ||
SSL_CTX *ssl_ctx_; | ||
SSL_CTX *ssl_ctx_ = nullptr; | ||
std::string err_msg_; | ||
}; | ||
|
||
#endif | ||
|
||
} // namespace cppnet | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule cpptest
updated
from b61c71 to dc74c3