From dfb30b157a0720399d8dd7ca9383f616291d0063 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Tue, 15 Nov 2011 20:09:58 -0600 Subject: [PATCH] merge with new ssl and policy code --- Policy Test/Policy_Test.1 | 79 +++++ Policy Test/main.cpp | 18 + src/policy.cpp | 464 ++++++++++++++++++++++++++ src/ssl/client.pem | 58 ++++ src/ssl/dh512.pem | 12 + src/ssl/server.cer | 40 +++ src/ssl/server.pem | 58 ++++ websocketpp.xcodeproj/project.pbxproj | 117 +++++++ 8 files changed, 846 insertions(+) create mode 100644 Policy Test/Policy_Test.1 create mode 100644 Policy Test/main.cpp create mode 100644 src/policy.cpp create mode 100644 src/ssl/client.pem create mode 100644 src/ssl/dh512.pem create mode 100644 src/ssl/server.cer create mode 100644 src/ssl/server.pem diff --git a/Policy Test/Policy_Test.1 b/Policy Test/Policy_Test.1 new file mode 100644 index 0000000000..b2403c0224 --- /dev/null +++ b/Policy Test/Policy_Test.1 @@ -0,0 +1,79 @@ +.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. +.\"See Also: +.\"man mdoc.samples for a complete listing of options +.\"man mdoc for the short list of editing options +.\"/usr/share/misc/mdoc.template +.Dd 2011-11-15 \" DATE +.Dt Policy Test 1 \" Program name and manual section number +.Os Darwin +.Sh NAME \" Section Header - required - don't modify +.Nm Policy Test, +.\" The following lines are read in generating the apropos(man -k) database. Use only key +.\" words here as the database is built based on the words here and in the .ND line. +.Nm Other_name_for_same_program(), +.Nm Yet another name for the same program. +.\" Use .Nm macro to designate other names for the documented program. +.Nd This line parsed for whatis database. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm +.Op Fl abcd \" [-abcd] +.Op Fl a Ar path \" [-a path] +.Op Ar file \" [file] +.Op Ar \" [file ...] +.Ar arg0 \" Underlined argument - use .Ar anywhere to underline +arg2 ... \" Arguments +.Sh DESCRIPTION \" Section Header - required - don't modify +Use the .Nm macro to refer to your program throughout the man page like such: +.Nm +Underlining is accomplished with the .Ar macro like this: +.Ar underlined text . +.Pp \" Inserts a space +A list of items with descriptions: +.Bl -tag -width -indent \" Begins a tagged list +.It item a \" Each item preceded by .It macro +Description of item a +.It item b +Description of item b +.El \" Ends the list +.Pp +A list of flags and their descriptions: +.Bl -tag -width -indent \" Differs from above in tag removed +.It Fl a \"-a flag as a list item +Description of -a flag +.It Fl b +Description of -b flag +.El \" Ends the list +.Pp +.\" .Sh ENVIRONMENT \" May not be needed +.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 +.\" .It Ev ENV_VAR_1 +.\" Description of ENV_VAR_1 +.\" .It Ev ENV_VAR_2 +.\" Description of ENV_VAR_2 +.\" .El +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact +.It Pa /usr/share/file_name +FILE_1 description +.It Pa /Users/joeuser/Library/really_long_file_name +FILE_2 description +.El \" Ends the list +.\" .Sh DIAGNOSTICS \" May not be needed +.\" .Bl -diag +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.\" Please do not reference files that do not exist without filing a bug report +.Xr a 1 , +.Xr b 1 , +.Xr c 1 , +.Xr a 2 , +.Xr b 2 , +.Xr a 3 , +.Xr b 3 +.\" .Sh BUGS \" Document known, unremedied bugs +.\" .Sh HISTORY \" Document history if command behaves in a unique manner \ No newline at end of file diff --git a/Policy Test/main.cpp b/Policy Test/main.cpp new file mode 100644 index 0000000000..cc0a444436 --- /dev/null +++ b/Policy Test/main.cpp @@ -0,0 +1,18 @@ +// +// main.cpp +// Policy Test +// +// Created by Peter Thorson on 2011-11-15. +// Copyright (c) 2011 The University of Chicago. All rights reserved. +// + +#include + +int main (int argc, const char * argv[]) +{ + + // insert code here... + std::cout << "Hello, World!\n"; + return 0; +} + diff --git a/src/policy.cpp b/src/policy.cpp new file mode 100644 index 0000000000..a059b0cc8c --- /dev/null +++ b/src/policy.cpp @@ -0,0 +1,464 @@ +/* +build situation +general: +- libboost_system + +SSL: +- libcrypto +- libssl + +*/ + +#include +#include +#include +#include +#include + + +class server_handler { + virtual void on_action() = 0; +}; + +typedef boost::shared_ptr server_handler_ptr; + +class client_handler { + virtual void on_action() = 0; +}; + +typedef boost::shared_ptr client_handler_ptr; + + +namespace connection { +template class security_policy> +class connection : public security_policy< connection > { +public: + //typedef role< connection > role_type; + typedef security_policy< connection > security_policy_type; + + //typedef typename role_type::handler_ptr handler_ptr; + + connection(endpoint_type& e) : security_policy_type(e),m_endpoint(e) { + std::cout << "setup connection" << std::endl; + } + + void websocket_handshake() { + std::cout << "Websocket Handshake" << std::endl; + this->websocket_messages(); + } + void websocket_messages() { + std::cout << "Websocket Messages" << std::endl; + } +protected: + endpoint_type& m_endpoint; +}; + +// Connection roles +template +class server { +public: + typedef server_handler_ptr handler_ptr; + + server (handler_ptr h) : m_handler(h) { + std::cout << "setup server connection role" << std::endl; + } + + void public_api() { + std::cout << "connection::server::public_api()" << std::endl; + } +protected: + void protected_api() { + std::cout << "connection::server::protected_api()" << std::endl; + } +private: + void private_api() { + std::cout << "connection::server::private_api()" << std::endl; + } + handler_ptr m_handler; +}; + +template +class client { +public: + typedef client_handler_ptr handler_ptr; + + client (handler_ptr h) : m_handler(h) { + std::cout << "setup client connection role" << std::endl; + } + + void public_api() { + std::cout << "connection::client::public_api()" << std::endl; + } +protected: + void protected_api() { + std::cout << "connection::client::protected_api()" << std::endl; + } +private: + void private_api() { + std::cout << "connection::client::private_api()" << std::endl; + } + handler_ptr m_handler; +}; + +} + +namespace endpoint { + +// test +template +struct endpoint_traits; + +class endpoint_base { +protected: + boost::asio::io_service m_io_service; +}; + +template