-
Notifications
You must be signed in to change notification settings - Fork 1
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
e10ff57
commit 813cbd9
Showing
12 changed files
with
392 additions
and
225 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*~ | ||
build | ||
bin | ||
.sconsign.dblite | ||
.sconsign.dblite | ||
server.pem |
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,3 +1,5 @@ | ||
Import('env') | ||
|
||
env.Append(LIBS=['ssl','crypto']) | ||
|
||
env.CompileFolderDWIM('.', requires='asio') |
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,21 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# Make a key | ||
openssl genrsa -des3 -out server.key 1024 | ||
|
||
# Make a signing request | ||
openssl req -new -key server.key -out server.csr | ||
|
||
# Fulfill the signing request, with own key | ||
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt | ||
|
||
# Make a Diffie-Hallman pair | ||
openssl dhparam -out dh1024.pem 1024 | ||
|
||
# Merge files | ||
cat server.key > server.pem | ||
cat server.crt >> server.pem | ||
cat dh1024.pem >> server.pem | ||
rm -f server.key dh1024.pem server.csr |
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
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
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,43 @@ | ||
#ifndef _HTTP_SERVER_H_ | ||
#define _HTTP_SERVER_H_ | ||
|
||
#include <functional> | ||
#include <set> | ||
#include <string> | ||
|
||
#include <asio.hpp> | ||
|
||
#include "Connection.hh" | ||
#include "Reply.hh" | ||
#include "Request.hh" | ||
|
||
namespace http { | ||
class http_server { | ||
typedef asio::ip::tcp::socket socket_t; | ||
//typedef asio::ssl::stream<asio::ip::tcp::socket> ssl_socket; | ||
|
||
public: | ||
http_server(asio::io_service& io_service, | ||
std::string address, std::string port, | ||
std::function<Reply(Request)> generator); | ||
|
||
void run(); | ||
void stop_all(); | ||
void close(); | ||
|
||
private: | ||
void do_wait_for_signal(); | ||
void do_accept(); | ||
|
||
void setup_new_conn(); | ||
|
||
asio::io_service& io_service; | ||
asio::ip::tcp::acceptor acceptor; | ||
std::unique_ptr<socket_t> socket; | ||
|
||
std::function<Reply(Request)> generator; | ||
std::set<std::shared_ptr<Connection<socket_t> > > connections; | ||
}; | ||
} | ||
|
||
#endif /* _HTTP_SERVER_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,48 @@ | ||
#ifndef _HTTPS_SERVER_H_ | ||
#define _HTTPS_SERVER_H_ | ||
|
||
#include <functional> | ||
#include <set> | ||
#include <string> | ||
|
||
#include <asio.hpp> | ||
#include <asio/ssl.hpp> | ||
|
||
#include "Connection.hh" | ||
#include "Reply.hh" | ||
#include "Request.hh" | ||
|
||
namespace http { | ||
class https_server { | ||
public: | ||
typedef asio::ssl::stream<asio::ip::tcp::socket> socket_t; | ||
|
||
https_server(asio::io_service& io_service, | ||
std::string address, std::string port, | ||
std::function<Reply(Request)> generator); | ||
|
||
void run(); | ||
void stop_all(); | ||
void close(); | ||
|
||
private: | ||
void do_wait_for_signal(); | ||
void do_accept(); | ||
|
||
void setup_new_conn(); | ||
|
||
std::string get_password(); | ||
|
||
asio::ssl::context& generate_context(); | ||
|
||
asio::io_service& io_service; | ||
asio::ip::tcp::acceptor acceptor; | ||
asio::ssl::context context; | ||
std::unique_ptr<socket_t> socket; | ||
|
||
std::function<Reply(Request)> generator; | ||
std::set<std::shared_ptr<Connection<socket_t> > > connections; | ||
}; | ||
} | ||
|
||
#endif /* _HTTPS_SERVER_H_ */ |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.