Skip to content

Commit

Permalink
fix:cicd problem
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxuan520 committed Oct 12, 2024
1 parent 8a6cada commit 5a488f5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
- [x] 抽象出epoll层
- [ ] 支持SSL
- [x] accept 改造
- [ ] 完善多线程
- [x] 完善多线程
1 change: 1 addition & 0 deletions src/cppnet/socket/socket.hpp
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>

Expand Down
24 changes: 24 additions & 0 deletions src/cppnet/ssl/ssl_connect.hpp
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
18 changes: 15 additions & 3 deletions src/cppnet/ssl/ssl_context.hpp
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
1 change: 1 addition & 0 deletions src/test/server/tcp_server_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ TEST(TcpServer, MultiThread) {
DEBUG("client exit");

// wakeup server
server.Stop();
server.WakeUp();
});

Expand Down
2 changes: 1 addition & 1 deletion src/third_party/cpptest
Submodule cpptest updated from b61c71 to dc74c3

0 comments on commit 5a488f5

Please sign in to comment.