Working with Linux
This commit is contained in:
parent
1d6f2bfd84
commit
ae93b73f27
8
linux/dh2048.pem
Executable file
8
linux/dh2048.pem
Executable file
@ -0,0 +1,8 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIIBCAKCAQEArjoon6Luh44PeVx1xPx6cuTzRVXgYoF17KrR6Tqww7b4P+ogrZp1
|
||||
wSLci+1RnlrkwWn1rFu0eHAbbSzvHlrmwkS2NRZcU+Zm7uNkPeE/6pzBd5HZnoRM
|
||||
yjiOL8DWTyaumdp4srLYLUplO2HVsdOyYh5Z3+GhsiTTVZfYjqyQD7qOaIpgv0Ri
|
||||
XMgVgVX8lQAd0IE7DfJyC6R/8CLoVaUIThEMQFJn4GH/ylnjW+kpOajyFeC0tU5F
|
||||
yFn40sI8qu/y1rKw8ZRYRnhSsLUmndfgAmfKNn80kFZTaOxHcaqbkRrocAV9QnHy
|
||||
6l+ytTbHOoFbCGyBQ/unRxxu9jD1qq/B6wIBAg==
|
||||
-----END DH PARAMETERS-----
|
65
linux/makefile
Executable file
65
linux/makefile
Executable file
@ -0,0 +1,65 @@
|
||||
CC=g++
|
||||
CFLAGS=-Wall -O3 -fpermissive -std=c++11 -DOPENSSL_NO_SSL2 -DOPENSSL_USE_DEPRECATED
|
||||
LDFLAGS= -lpthread -lrt -lssl -lcrypto \
|
||||
-L/home/ubuntu/work/openssl-out/lib
|
||||
BOOST_PATH=/home/ubuntu/work/boost_1_63_0
|
||||
#======================================================
|
||||
#====================== BOOST =========================
|
||||
#======================================================
|
||||
CFLAGS += -I$(BOOST_PATH)
|
||||
#thread
|
||||
LOCAL_SRC_FILES := $(BOOST_PATH)/libs/thread/src/pthread/thread.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/thread/src/pthread/once.cpp
|
||||
#signals
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/signals/src/connection.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/signals/src/named_slot_map.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/signals/src/signal_base.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/signals/src/slot.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/signals/src/trackable.cpp
|
||||
#system
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/system/src/error_code.cpp
|
||||
#regex
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/c_regex_traits.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/cpp_regex_traits.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/cregex.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/fileiter.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/icu.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/instances.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/posix_api.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/regex.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/regex_debug.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/regex_raw_buffer.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/regex_traits_defaults.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/static_mutex.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/usinstances.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/w32_regex_traits.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/wc_regex_traits.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/wide_posix_api.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/regex/src/winstances.cpp
|
||||
#date_time
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/date_time/src/gregorian/greg_month.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/date_time/src/gregorian/greg_weekday.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/date_time/src/gregorian/date_generators.cpp
|
||||
#program_options
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/cmdline.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/config_file.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/convert.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/options_description.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/parsers.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/positional_options.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/split.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/utf8_codecvt_facet.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/value_semantic.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/variables_map.cpp
|
||||
LOCAL_SRC_FILES += $(BOOST_PATH)/libs/program_options/src/winmain.cpp
|
||||
#======================================================
|
||||
#======================= APP ==========================
|
||||
#======================================================
|
||||
CFLAGS += -I../ \
|
||||
-I/home/ubuntu/work/openssl-out/include \
|
||||
-I/home/ubuntu/work/openssl \
|
||||
-I/home/ubuntu/work/openssl/include
|
||||
LOCAL_SRC_FILES += ../main.cpp
|
||||
|
||||
all:
|
||||
$(CC) $(LOCAL_SRC_FILES) $(CFLAGS) $(LDFLAGS) -o proxyServerTest
|
55
linux/nohup.out
Executable file
55
linux/nohup.out
Executable file
@ -0,0 +1,55 @@
|
||||
ProxySession Create
|
||||
ProxySession::start
|
||||
ProxySession::asyncHandshake
|
||||
ProxySession::asyncHandshake inner
|
||||
ProxySession::readClientVersion
|
||||
ProxySession::readClientVersion inner
|
||||
ProxySession::sendServerVersionNoAuth
|
||||
ProxySession::sendServerVersionNoAuth inner
|
||||
ProxySession::readConnectRequest
|
||||
ProxySession::readConnectRequest iner
|
||||
End of file
|
||||
Operation canceled
|
||||
ProxySession Destroy
|
||||
ProxySession Create
|
||||
ProxySession::start
|
||||
ProxySession::asyncHandshake
|
||||
ProxySession::asyncHandshake inner
|
||||
ProxySession::readClientVersion
|
||||
ProxySession::readClientVersion inner
|
||||
ProxySession Destroy
|
||||
ProxySession Create
|
||||
ProxySession::start
|
||||
ProxySession::asyncHandshake
|
||||
ProxySession::asyncHandshake inner
|
||||
ProxySession::readClientVersion
|
||||
ProxySession::readClientVersion inner
|
||||
ProxySession Destroy
|
||||
ProxySession Create
|
||||
ProxySession::start
|
||||
ProxySession::asyncHandshake
|
||||
ProxySession::asyncHandshake inner
|
||||
ProxySession::readClientVersion
|
||||
ProxySession::readClientVersion inner
|
||||
ProxySession Destroy
|
||||
ProxySession Create
|
||||
ProxySession::start
|
||||
ProxySession::asyncHandshake
|
||||
ProxySession::asyncHandshake inner
|
||||
ProxySession::readClientVersion
|
||||
ProxySession::readClientVersion inner
|
||||
ProxySession Destroy
|
||||
ProxySession Create
|
||||
ProxySession::start
|
||||
ProxySession::asyncHandshake
|
||||
ProxySession::asyncHandshake inner
|
||||
ProxySession::readClientVersion
|
||||
ProxySession::readClientVersion inner
|
||||
ProxySession Destroy
|
||||
ProxySession Create
|
||||
ProxySession::start
|
||||
ProxySession::asyncHandshake
|
||||
ProxySession::asyncHandshake inner
|
||||
ProxySession::readClientVersion
|
||||
ProxySession::readClientVersion inner
|
||||
ProxySession Destroy
|
BIN
linux/proxyServerTest
Executable file
BIN
linux/proxyServerTest
Executable file
Binary file not shown.
24
linux/rootca.crt
Executable file
24
linux/rootca.crt
Executable file
@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIECTCCAvGgAwIBAgIJAKlzlxSAr1BkMA0GCSqGSIb3DQEBCwUAMIGZMQswCQYD
|
||||
VQQGEwJMVjETMBEGA1UECAwKU29tZS1TdGF0ZTENMAsGA1UEBwwEUmlnYTEbMBkG
|
||||
A1UECgwSRmlzaCBSdW4gR2FtZXMgU0lBMRcwFQYDVQQDDA5mcmctcHJveHktcm9v
|
||||
dDEwMC4GCSqGSIb3DQEJARYhdmxhZGlzbGF2Lmtob3JldkBmaXNocnVuZ2FtZXMu
|
||||
Y29tMCAXDTE3MDgwNjE4MjgxMFoYDzIwNzIwNTA5MTgyODEwWjCBmTELMAkGA1UE
|
||||
BhMCTFYxEzARBgNVBAgMClNvbWUtU3RhdGUxDTALBgNVBAcMBFJpZ2ExGzAZBgNV
|
||||
BAoMEkZpc2ggUnVuIEdhbWVzIFNJQTEXMBUGA1UEAwwOZnJnLXByb3h5LXJvb3Qx
|
||||
MDAuBgkqhkiG9w0BCQEWIXZsYWRpc2xhdi5raG9yZXZAZmlzaHJ1bmdhbWVzLmNv
|
||||
bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM5NIDsckYAgP1zhXwzg
|
||||
DHOnFbpQCF0gJVOQK66tgda7o5vbLFqzqW5R6rRieNdlUEtztXrRMjO+1LYBQ+vD
|
||||
bT058uwlTgD7xpRtr73kMoPBosZpxRxBKJpp60wOHLyZJqSn16WlgTm8/TTTaF2R
|
||||
yFYhHxGM+xkDzgXo0LU0yjHOgsJSlnBHGC6mmbrdzCGY9c7hFcYPawCty+FNIqVW
|
||||
eFEWHSOXqAhADxp5KbdrcUK8EmVljRLEGItctiRdq9PWxhHpodEgKiwOUk0bXds/
|
||||
ErTw1ozopqSYZD5RgL1DcL3T/bKbGDdqp+blIZN1nsL6hYW4b2gHPTSNrUkBkt5v
|
||||
oz0CAwEAAaNQME4wHQYDVR0OBBYEFHhY1354tUtbEk1mMtRcRbgK4LPsMB8GA1Ud
|
||||
IwQYMBaAFHhY1354tUtbEk1mMtRcRbgK4LPsMAwGA1UdEwQFMAMBAf8wDQYJKoZI
|
||||
hvcNAQELBQADggEBAMEiLatj4IURN1U1779TLRbKf4gIVlopey0xbzSRSosNtAOu
|
||||
s+zApVzaDEDdULM7YhkXo+kThp41xCU7xMZZan0XyvTcos1KTjHISf3swJb9L8XT
|
||||
S6t/D2bUt+FnjKCyRC3xtheNhoxOwCAQXNvXu5HJ1O87eDxYorQQ5ujAjbToxbTs
|
||||
i8xR9HwLe3h36NY22qsX6LRohZufXa3S8YUATW2frDp1q7vArBXuY7o/+UIQxn49
|
||||
dTzAqYhEpBJZw7MZB/3BqHPzmZ3jqEsj3HK6rgxwlYEnY6kB6eAhiAtaPVARx538
|
||||
6Yz8LsofRoZSVnytmYquxiWB7YJuhEYiIwrpcXo=
|
||||
-----END CERTIFICATE-----
|
5
linux/run.sh
Executable file
5
linux/run.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
LD_LIBRARY_PATH="/home/ubuntu/work/openssl-out/lib"
|
||||
export LD_LIBRARY_PATH
|
||||
nohup /home/ubuntu/work/proxyServerTest/linux/proxyServerTest &
|
||||
|
22
linux/server.crt
Executable file
22
linux/server.crt
Executable file
@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDqDCCApACCQCHryODPTrImDANBgkqhkiG9w0BAQsFADCBmTELMAkGA1UEBhMC
|
||||
TFYxEzARBgNVBAgMClNvbWUtU3RhdGUxDTALBgNVBAcMBFJpZ2ExGzAZBgNVBAoM
|
||||
EkZpc2ggUnVuIEdhbWVzIFNJQTEXMBUGA1UEAwwOZnJnLXByb3h5LXJvb3QxMDAu
|
||||
BgkqhkiG9w0BCQEWIXZsYWRpc2xhdi5raG9yZXZAZmlzaHJ1bmdhbWVzLmNvbTAg
|
||||
Fw0xNzA4MDYxODI5NDVaGA8yMDcyMDUwOTE4Mjk0NVowgY8xCzAJBgNVBAYTAkxW
|
||||
MRMwEQYDVQQIDApTb21lLVN0YXRlMQ0wCwYDVQQHDARSaWdhMRswGQYDVQQKDBJG
|
||||
aXNoIFJ1biBHYW1lcyBTSUExDTALBgNVBAMMBHVzZXIxMDAuBgkqhkiG9w0BCQEW
|
||||
IXZsYWRpc2xhdi5raG9yZXZAZmlzaHJ1bmdhbWVzLmNvbTCCASIwDQYJKoZIhvcN
|
||||
AQEBBQADggEPADCCAQoCggEBAKk5iMe4m8SW9vV/VDePQznIiZ870b5CXrklOzcV
|
||||
iI3kFDAsfnk9AR6UALfojCjDFO97DfaKDXOJBH+hkyJVuDQt25unnsG9Sbtr/Uwn
|
||||
msdOTv8hr2IPyRnBIJc1MW7zoYaNOZ/etJcAyAYVMsr8/8CoTZi4vhARvgdgXmZd
|
||||
bI+wMt13ZObihobuyLrjvRvoc1se/gwN8AkluQBz7h7FFYTda7sBdCw/qAz2/hUT
|
||||
zskPLiPwbXWm7iC1eAoQgXy/DZLzXUVVJ94CmkUflsVbjKq3Z9wudYIptMqG9tsO
|
||||
mKOhbwi579NbiB1afeSf4cHtDcnH3JM4AgEgcru5Js27pocCAwEAATANBgkqhkiG
|
||||
9w0BAQsFAAOCAQEAiRySYyBhpksv1vOvc7eMKcpGh+1wS85PpcwH8uOaBGsqgjxz
|
||||
mQZK+tnw/WmL9mlgOY6GqfEpz1VW6gytD3kvlmXrIDUgUGxthVZ7pZhc7lsACkU1
|
||||
TN+kZUP1wVeHhYdoAFdCnFQjsm4DEGB8ArXAAteN1onnPC7wUTiDeVDLyhTAYzj9
|
||||
9o/4nrP941QgACBt9h+mXAKwUCD8Zr9GhcktlZA+XvF+z6ckV8L6XyepdEvriVT/
|
||||
84jEOOdPYmI5/FJRxCriDxmVJubwswDiIezgZ0vo2pdPVftEoTR6/iebu+lUWXFV
|
||||
5mqnHTucNTHVWmimiv/de0FHbO/qnwYnQPgaMA==
|
||||
-----END CERTIFICATE-----
|
27
linux/server.key
Executable file
27
linux/server.key
Executable file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAqTmIx7ibxJb29X9UN49DOciJnzvRvkJeuSU7NxWIjeQUMCx+
|
||||
eT0BHpQAt+iMKMMU73sN9ooNc4kEf6GTIlW4NC3bm6eewb1Ju2v9TCeax05O/yGv
|
||||
Yg/JGcEglzUxbvOhho05n960lwDIBhUyyvz/wKhNmLi+EBG+B2BeZl1sj7Ay3Xdk
|
||||
5uKGhu7IuuO9G+hzWx7+DA3wCSW5AHPuHsUVhN1ruwF0LD+oDPb+FRPOyQ8uI/Bt
|
||||
dabuILV4ChCBfL8NkvNdRVUn3gKaRR+WxVuMqrdn3C51gim0yob22w6Yo6FvCLnv
|
||||
01uIHVp95J/hwe0NycfckzgCASByu7kmzbumhwIDAQABAoIBAEdIOvuWIdc/mCt1
|
||||
RS5aJIE0nfP7KLCyGGB49GaRpYHPb0mTlHrRXaVZxquxQ0jwU+NEvG77XAsszj5M
|
||||
+0NdREiGgJkilFcbuvE93ea0UBhgPhpuQAhYiedVWLsY5wfLjGC3IGzdTMjGxXr6
|
||||
dvjWdYzb2EPangT61EcbKuiHtfEYIhQ26Mdb3tVWPMW/g2KMYCTOFSraNZoSHXLn
|
||||
f7gpzP1dY/aoL2FYz7GBV/7W2corA5iYIFe4HVHpppEjnPja6+WZwsTR2rndSvj7
|
||||
N9zwdXcpLJr1GJCrta8RiJTlD0kHAKXOMPYTG/pcxwUfLr8ceP5HTh/7624sPsYo
|
||||
rnyt7fECgYEA0+RMZ9tYT3i0peaLC12MTyr8X+xzDnHK501Ep+0VnpS0quHwWJ0u
|
||||
3ab9EFhM1u8NEFwF6YnXyORq1AMHIU/O+O3rHt6VlF4z625tF6Wu61zQNerCVM/M
|
||||
bOqX9yl+ukNW4qx1maSEqhajKhhp69qJ3Cr+2eD+igENuDRqn/2eHtsCgYEAzHOC
|
||||
4/xrF4iWlx4MYflENa9miTGxnYDz9rDuhZu9Zqlv55dtv39WEkhKvcFjMx4McvNy
|
||||
nu0yKBdpZ75QORfjaAHX0J47+RnDZhiSxh53P7vSy7/jDbUDle44x+H0IWJwoK4b
|
||||
ECqvKIh/tibYukFFoSJyBdZQ4U67kaXbsrNKOMUCgYEAoFUhk3ygCBJ37wjRsZnp
|
||||
r4YBTbwnG4jzVa5cAw0czNANHTi1mvflHIdc+d821XQxWG2pc5uAElz0kNRxsr0n
|
||||
CalNviAC4y+c7cqy9a/C+glS61lmDrLmJowkzTsyz1JhDkgc/FNGp0VV1WZ/z52f
|
||||
r19BVDAxqs89SGMxQzqvSP0CgYB2r7PTX+xXXA53qZTsp0Smma0/hZ6jXYHCutGs
|
||||
tE1ONJxm6Cxo16YCtP7Wi1ZoDVCSxqrKgc31IiopdHyjuC9maHN9gu4z3HXnZeqG
|
||||
opb9Y66qYzmO8n8jYYiK2KvdWYUicg/54Z2PPTZOatyzu0KNmS5yHwkS0p7mnU8d
|
||||
vSEgNQKBgC0eq1urDxRl0FbcoLPNaxwVRRyUhcZZc7RRDz8TH0Z2/iVdnsmhBhum
|
||||
Z27ZfBfp7HZA4k44sld15ZIw5H2lsFlEz/oHiJgAobGx556WbQwJypvY/Ii3jtap
|
||||
sE6umZIoJF90oo33ARRC743Ed46fD1BrIFaJ+BBG3raheA3SONmG
|
||||
-----END RSA PRIVATE KEY-----
|
125
main.cpp
125
main.cpp
@ -7,6 +7,8 @@
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#define SSL_R_SHORT_READ 219
|
||||
#include "ssl/ssl_locl.h"
|
||||
#include <boost/asio/ssl.hpp>
|
||||
@ -172,6 +174,10 @@ private:
|
||||
{
|
||||
sendServerVersion();
|
||||
}
|
||||
else if (clientVersion[0] == 0x05 && clientVersion[1] == 0x01 && clientVersion[2] == 0x00)
|
||||
{
|
||||
sendServerVersionNoAuth();
|
||||
}
|
||||
else
|
||||
{
|
||||
lowerSocket().close();
|
||||
@ -210,6 +216,32 @@ private:
|
||||
});
|
||||
}
|
||||
|
||||
void sendServerVersionNoAuth()
|
||||
{
|
||||
|
||||
std::cout << "ProxySession::sendServerVersionNoAuth" << std::endl;
|
||||
|
||||
auto self(shared_from_this());
|
||||
|
||||
std::array<char, 2> version = { 0x05, 0x00 };
|
||||
|
||||
boost::asio::async_write(socket(),
|
||||
boost::asio::buffer(version.data(), version.size()),
|
||||
[this, self](boost::system::error_code ec, std::size_t length)
|
||||
{
|
||||
std::cout << "ProxySession::sendServerVersionNoAuth inner" << std::endl;
|
||||
if (!ec)
|
||||
{
|
||||
//readLoginPassword();
|
||||
readConnectRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
lowerSocket().close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void readLoginPassword()
|
||||
{
|
||||
@ -254,7 +286,7 @@ private:
|
||||
|
||||
}
|
||||
|
||||
std::array<unsigned char, 2> authStatus = { 0x01, 0x00 };
|
||||
std::array<unsigned char, 2> authStatus = std::array<unsigned char, 2>{ (unsigned char)0x01, (unsigned char)0x00 };
|
||||
|
||||
void sendAuthStatus()
|
||||
{
|
||||
@ -273,6 +305,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
}
|
||||
});
|
||||
@ -280,6 +314,9 @@ private:
|
||||
|
||||
void readConnectRequest()
|
||||
{
|
||||
|
||||
std::cout << "ProxySession::readConnectRequest" << std::endl;
|
||||
|
||||
std::shared_ptr<std::array<unsigned char, 5>> firstPartPtr = std::make_shared<std::array<unsigned char, 5>>();
|
||||
|
||||
|
||||
@ -290,6 +327,8 @@ private:
|
||||
boost::asio::buffer(firstPartPtr->data(), firstPartPtr->size()),
|
||||
[this, self, firstPartPtr](boost::system::error_code ec, std::size_t /*length*/)
|
||||
{
|
||||
std::cout << "ProxySession::readConnectRequest iner" << std::endl;
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
if ((*firstPartPtr)[0] == 0x05 && (*firstPartPtr)[1] == 0x01 && (*firstPartPtr)[2] == 0x00)
|
||||
@ -306,11 +345,15 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
}
|
||||
});
|
||||
@ -351,6 +394,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
}
|
||||
});
|
||||
@ -393,6 +438,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
}
|
||||
});
|
||||
@ -413,6 +460,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
outsideConnectSocket.close();
|
||||
}
|
||||
@ -432,6 +481,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
outsideConnectSocket.close();
|
||||
}
|
||||
@ -468,6 +519,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
outsideConnectSocket.close();
|
||||
}
|
||||
@ -507,6 +560,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
lowerSocket().close();
|
||||
outsideConnectSocket.close();
|
||||
}
|
||||
@ -514,23 +569,32 @@ private:
|
||||
|
||||
}
|
||||
|
||||
unsigned char forwardChar;
|
||||
unsigned char backwardChar;
|
||||
|
||||
std::array<unsigned char, 8192> forwardBuffer;
|
||||
std::array<unsigned char, 8192> backwardBuffer;
|
||||
//unsigned char forwardChar;
|
||||
//unsigned char backwardChar;
|
||||
|
||||
|
||||
void transferDataForward()
|
||||
{
|
||||
auto self(shared_from_this());
|
||||
|
||||
boost::asio::async_read(socket(),
|
||||
boost::asio::buffer(&forwardChar, 1),
|
||||
[this, self](boost::system::error_code ec, std::size_t /*length*/)
|
||||
socket().async_read_some(boost::asio::buffer(forwardBuffer),
|
||||
[this, self](boost::system::error_code ec, std::size_t length)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
|
||||
std::shared_ptr<std::vector<unsigned char>> data = std::make_shared<std::vector<unsigned char>>();
|
||||
data->resize(length);
|
||||
|
||||
std::copy(&forwardBuffer[0], &forwardBuffer[0] + length, &(*data)[0]);
|
||||
|
||||
|
||||
boost::asio::async_write(outsideConnectSocket,
|
||||
boost::asio::buffer(&forwardChar, 1),
|
||||
[this, self](boost::system::error_code ec, std::size_t length)
|
||||
boost::asio::buffer(*data),
|
||||
[this, self, data](boost::system::error_code ec, std::size_t length)
|
||||
{
|
||||
|
||||
if (!ec)
|
||||
@ -539,6 +603,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
outsideConnectSocket.close();
|
||||
lowerSocket().close();
|
||||
}
|
||||
@ -546,6 +612,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
outsideConnectSocket.close();
|
||||
lowerSocket().close();
|
||||
}
|
||||
@ -556,15 +624,21 @@ private:
|
||||
{
|
||||
auto self(shared_from_this());
|
||||
|
||||
boost::asio::async_read(outsideConnectSocket,
|
||||
boost::asio::buffer(&backwardChar, 1),
|
||||
[this, self](boost::system::error_code ec, std::size_t /*length*/)
|
||||
outsideConnectSocket.async_read_some(boost::asio::buffer(backwardBuffer),
|
||||
[this, self](boost::system::error_code ec, std::size_t length)
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
|
||||
std::shared_ptr<std::vector<unsigned char>> data = std::make_shared<std::vector<unsigned char>>();
|
||||
data->resize(length);
|
||||
|
||||
std::copy(&backwardBuffer[0], &backwardBuffer[0] + length, &(*data)[0]);
|
||||
|
||||
|
||||
boost::asio::async_write(socket(),
|
||||
boost::asio::buffer(&backwardChar, 1),
|
||||
[this, self](boost::system::error_code ec, std::size_t length)
|
||||
boost::asio::buffer(*data),
|
||||
[this, self, data](boost::system::error_code ec, std::size_t length)
|
||||
{
|
||||
|
||||
if (!ec)
|
||||
@ -573,6 +647,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
outsideConnectSocket.close();
|
||||
lowerSocket().close();
|
||||
}
|
||||
@ -580,6 +656,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = ec.message();
|
||||
std::cout << msg << std::endl;
|
||||
outsideConnectSocket.close();
|
||||
lowerSocket().close();
|
||||
}
|
||||
@ -671,7 +749,26 @@ int main()
|
||||
|
||||
ProxyServer proxyServer(ioService, endpoint, sslContext);
|
||||
|
||||
ioService.run();
|
||||
|
||||
boost::thread_group threadpool;
|
||||
/*
|
||||
threadpool.create_thread(
|
||||
boost::bind(&boost::asio::io_service::run, &ioService)
|
||||
);
|
||||
threadpool.create_thread(
|
||||
boost::bind(&boost::asio::io_service::run, &ioService)
|
||||
);
|
||||
threadpool.create_thread(
|
||||
boost::bind(&boost::asio::io_service::run, &ioService)
|
||||
);*/
|
||||
threadpool.create_thread(
|
||||
boost::bind(&boost::asio::io_service::run, &ioService)
|
||||
);
|
||||
|
||||
|
||||
threadpool.join_all();
|
||||
|
||||
//ioService.run();
|
||||
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
@ -75,6 +75,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../boost_1_63_0;../../openssl-master;../../openssl-master/include;../../openssl-master/output/include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -88,6 +89,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../boost_1_63_0</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -102,6 +104,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../boost_1_63_0;../../openssl-master;../../openssl-master/include;../../openssl-master/output/include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -119,6 +122,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../boost_1_63_0</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
Loading…
Reference in New Issue
Block a user