Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
main.cpp File Reference
#include <random>
#include <boost/timer/timer.hpp>
#include <websocketpp/config/core.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
#include <sstream>
Include dependency graph for main.cpp:

Go to the source code of this file.

Typedefs

typedef websocketpp::server< websocketpp::config::coreserver
 

Functions

int main ()
 

Typedef Documentation

◆ server

Definition at line 24 of file main.cpp.

Function Documentation

◆ main()

int main ( void )

Definition at line 65 of file main.cpp.

65 {
67 message_type;
69 con_msg_man_type;
70
71 con_msg_man_type::ptr manager = websocketpp::lib::make_shared<con_msg_man_type>();
72
73 size_t foo = 1024;
74
75 message_type::ptr input = manager->get_message(websocketpp::frame::opcode::TEXT,foo);
76 message_type::ptr output = manager->get_message(websocketpp::frame::opcode::TEXT,foo);
78
79 std::random_device dev;
80
81
82
83 key.i = 0x12345678;
84
85 double m = 18094238402394.0824923;
86
87 /*std::cout << "Some Math" << std::endl;
88 {
89 boost::timer::auto_cpu_timer t;
90
91 for (int i = 0; i < foo; i++) {
92 m /= 1.001;
93 }
94
95 }*/
96
97 std::cout << m << std::endl;
98
99 std::cout << "Random Gen" << std::endl;
100 {
101 boost::timer::auto_cpu_timer t;
102
103 input->get_raw_payload().replace(0,foo,foo,'\0');
104 output->get_raw_payload().replace(0,foo,foo,'\0');
105 }
106
107 std::cout << "Out of place accelerated" << std::endl;
108 {
109 boost::timer::auto_cpu_timer t;
110
111 websocketpp::frame::word_mask_exact(reinterpret_cast<uint8_t*>(const_cast<char*>(input->get_raw_payload().data())), reinterpret_cast<uint8_t*>(const_cast<char*>(output->get_raw_payload().data())), foo, key);
112 }
113
114 std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
115 std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
116
117 input->get_raw_payload().replace(0,foo,foo,'\0');
118 output->get_raw_payload().replace(0,foo,foo,'\0');
119
120 std::cout << "In place accelerated" << std::endl;
121 {
122 boost::timer::auto_cpu_timer t;
123
124 websocketpp::frame::word_mask_exact(reinterpret_cast<uint8_t*>(const_cast<char*>(input->get_raw_payload().data())), reinterpret_cast<uint8_t*>(const_cast<char*>(input->get_raw_payload().data())), foo, key);
125 }
126
127 std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
128 std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
129
130 input->get_raw_payload().replace(0,foo,foo,'\0');
131 output->get_raw_payload().replace(0,foo,foo,'\0');
132 std::cout << "Out of place byte by byte" << std::endl;
133 {
134 boost::timer::auto_cpu_timer t;
135
136 websocketpp::frame::byte_mask(input->get_raw_payload().begin(), input->get_raw_payload().end(), output->get_raw_payload().begin(), key);
137 }
138
139 std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
140 std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
141
142 input->get_raw_payload().replace(0,foo,foo,'\0');
143 output->get_raw_payload().replace(0,foo,foo,'\0');
144 std::cout << "In place byte by byte" << std::endl;
145 {
146 boost::timer::auto_cpu_timer t;
147
148 websocketpp::frame::byte_mask(input->get_raw_payload().begin(), input->get_raw_payload().end(), input->get_raw_payload().begin(), key);
149 }
150
151 std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
152 std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
153
154 input->get_raw_payload().replace(0,foo,foo,'a');
155 output->get_raw_payload().replace(0,foo,foo,'b');
156 std::cout << "Copy" << std::endl;
157 {
158 boost::timer::auto_cpu_timer t;
159
160 std::copy(input->get_raw_payload().begin(), input->get_raw_payload().end(), output->get_raw_payload().begin());
161 }
162
163 std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
164 std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
165
166 /*server::handler::ptr h(new handler());
167
168 server test_server(h);
169 server::connection_ptr con;
170
171 std::stringstream output;
172
173 test_server.register_ostream(&output);
174
175 con = test_server.get_connection();
176
177 con->start();
178
179 //foo.handle_accept(con,true);
180
181 std::stringstream input;
182 input << "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
183 //input << "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n";
184 input >> *con;
185
186 std::stringstream input2;
187 input2 << "messageabc2";
188 input2 >> *con;
189
190 std::stringstream input3;
191 input3 << "messageabc3";
192 input3 >> *con;
193
194 std::stringstream input4;
195 input4 << "close";
196 input4 >> *con;
197
198 std::cout << "connection output:" << std::endl;
199 std::cout << output.str() << std::endl;*/
200}
Represents a buffer for a single WebSocket message.
Definition pool.hpp:101
void byte_mask(input_iter b, input_iter e, output_iter o, masking_key_type const &key, size_t key_offset=0)
Byte by byte mask/unmask.
Definition frame.hpp:642
void word_mask_exact(uint8_t *input, uint8_t *output, size_t length, masking_key_type const &key)
Exact word aligned mask/unmask.
Definition frame.hpp:699
std::string to_hex(std::string const &input)
Convert std::string to ascii printed string of hex digits.
unsigned char uint8_t
Definition stdint.h:124
Four byte conversion union.
Definition frame.hpp:61
uint8_t key[16]
Definition yubico_otp.c:41
Here is the call graph for this function: