Skip to content

Commit d000e7a

Browse files
author
cqm
committed
merge socketio#137: In TLS build of library, support both TLS and non-TLS connections.
The choice is made at runtime, if a TLS URI (https:// or wss://) is given, the TLS client will be used, otherwise the non-TLS client will be used. Additionally, a new constructor is introduced allowing the URI to be passed at construction, which allows the above selection to occur, otherwise only the default for the library (TLS or non-TLS) will be used (preserving the original behavior).
1 parent ec4d540 commit d000e7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+39295
-126
lines changed

API.md

+14
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ Get current namespace name which the client is inside.
9191
#### Constructors
9292
`client()` default constructor.
9393

94+
`client(const std::string& uri)`
95+
96+
Constructor with URI. This form of the constructor will select automatically
97+
between TLS and non-TLS versions of the client if you are linking with the
98+
TLS build. To use TLS, provide a URI with the `https://` or `wss://` scheme,
99+
otherwise use 'http://' or 'ws://'. If an unsupported scheme is given, an
100+
exception will be thrown.
101+
102+
After constructing with this URI, you may call `connect()` with no arguments.
103+
94104
#### Connection Listeners
95105
`void set_open_listener(con_listener const& l)`
96106

@@ -130,6 +140,10 @@ Set listener for socket close event, called when any sockets being closed, after
130140
```
131141

132142
#### Connect and Close
143+
`void connect()`
144+
145+
Connect to socket.io server URI previously given to the constructor.
146+
133147
`void connect(const std::string& uri)`
134148

135149
Connect to socket.io server, e.g., `client.connect("ws://localhost:3000");`

examples/Console/SioChatDemo/SioChatDemo.vcxproj

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
55
<Configuration>Debug</Configuration>
@@ -14,18 +14,19 @@
1414
<ProjectGuid>{3503FCEB-2C8E-441A-A57C-B9DEE9171CF4}</ProjectGuid>
1515
<Keyword>Win32Proj</Keyword>
1616
<RootNamespace>SioChatDemo</RootNamespace>
17+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
1718
</PropertyGroup>
1819
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
1920
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2021
<ConfigurationType>Application</ConfigurationType>
2122
<UseDebugLibraries>true</UseDebugLibraries>
22-
<PlatformToolset>v110</PlatformToolset>
23+
<PlatformToolset>v141</PlatformToolset>
2324
<CharacterSet>Unicode</CharacterSet>
2425
</PropertyGroup>
2526
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
2627
<ConfigurationType>Application</ConfigurationType>
2728
<UseDebugLibraries>false</UseDebugLibraries>
28-
<PlatformToolset>v110</PlatformToolset>
29+
<PlatformToolset>v141</PlatformToolset>
2930
<WholeProgramOptimization>true</WholeProgramOptimization>
3031
<CharacterSet>Unicode</CharacterSet>
3132
</PropertyGroup>
@@ -41,26 +42,26 @@
4142
<PropertyGroup Label="UserMacros" />
4243
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4344
<LinkIncremental>true</LinkIncremental>
44-
<IncludePath>D:\BoostRoot\include\boost-1_55;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
45-
<LibraryPath>D:\boost_1_55_0\boost_build\debug\lib;$(SolutionDir)boost\$(Configuration)\lib;$(LibraryPath)</LibraryPath>
45+
<IncludePath>$(SolutionDir)..\..\..\lib\asio\asio\include;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(SolutionDir)..\..\..\lib\openssl\include;$(IncludePath)</IncludePath>
46+
<LibraryPath>$(SolutionDir)..\..\..\lib\openssl\win32;$(LibraryPath)</LibraryPath>
4647
</PropertyGroup>
4748
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
4849
<LinkIncremental>false</LinkIncremental>
49-
<IncludePath>$(SolutionDir)boost;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
50-
<LibraryPath>$(SolutionDir)boost\$(Configuration)\lib;$(LibraryPath)</LibraryPath>
50+
<IncludePath>$(SolutionDir)..\..\..\lib\asio\asio\include;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(SolutionDir)..\..\..\lib\openssl\include;$(IncludePath)</IncludePath>
51+
<LibraryPath>$(SolutionDir)..\..\..\lib\openssl\win32;$(LibraryPath)</LibraryPath>
5152
</PropertyGroup>
5253
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5354
<ClCompile>
5455
<PrecompiledHeader>NotUsing</PrecompiledHeader>
5556
<WarningLevel>Level3</WarningLevel>
5657
<Optimization>Disabled</Optimization>
57-
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
58+
<PreprocessorDefinitions>SIO_TLS;_SCL_SECURE_NO_WARNINGS;WIN32;_WEBSOCKETPP_CPP11_FUNCTIONAL_;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;ASIO_STANDALONE;_WEBSOCKETPP_CPP11_STL_;_WEBSOCKETPP_CPP11_FUNCTIONAL;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
5859
<SDLCheck>true</SDLCheck>
5960
</ClCompile>
6061
<Link>
6162
<SubSystem>Console</SubSystem>
6263
<GenerateDebugInformation>true</GenerateDebugInformation>
63-
<AdditionalDependencies>boost.lib;%(AdditionalDependencies)</AdditionalDependencies>
64+
<AdditionalDependencies>libeay32.lib;ssleay32.lib</AdditionalDependencies>
6465
</Link>
6566
</ItemDefinitionGroup>
6667
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -70,15 +71,15 @@
7071
<Optimization>MaxSpeed</Optimization>
7172
<FunctionLevelLinking>true</FunctionLevelLinking>
7273
<IntrinsicFunctions>true</IntrinsicFunctions>
73-
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
74+
<PreprocessorDefinitions>SIO_TLS;_SCL_SECURE_NO_WARNINGS;WIN32;_WEBSOCKETPP_CPP11_FUNCTIONAL_;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;ASIO_STANDALONE;_WEBSOCKETPP_CPP11_STL_;_WEBSOCKETPP_CPP11_FUNCTIONAL;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
7475
<SDLCheck>true</SDLCheck>
7576
</ClCompile>
7677
<Link>
7778
<SubSystem>Console</SubSystem>
7879
<GenerateDebugInformation>true</GenerateDebugInformation>
7980
<EnableCOMDATFolding>true</EnableCOMDATFolding>
8081
<OptimizeReferences>true</OptimizeReferences>
81-
<AdditionalDependencies>boost.lib;%(AdditionalDependencies)</AdditionalDependencies>
82+
<AdditionalDependencies>libeay32.lib;ssleay32.lib</AdditionalDependencies>
8283
</Link>
8384
</ItemDefinitionGroup>
8485
<ItemGroup>

lib/openssl/include/openssl/aes.h

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/* crypto/aes/aes.h */
2+
/* ====================================================================
3+
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in
14+
* the documentation and/or other materials provided with the
15+
* distribution.
16+
*
17+
* 3. All advertising materials mentioning features or use of this
18+
* software must display the following acknowledgment:
19+
* "This product includes software developed by the OpenSSL Project
20+
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21+
*
22+
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23+
* endorse or promote products derived from this software without
24+
* prior written permission. For written permission, please contact
25+
26+
*
27+
* 5. Products derived from this software may not be called "OpenSSL"
28+
* nor may "OpenSSL" appear in their names without prior written
29+
* permission of the OpenSSL Project.
30+
*
31+
* 6. Redistributions of any form whatsoever must retain the following
32+
* acknowledgment:
33+
* "This product includes software developed by the OpenSSL Project
34+
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35+
*
36+
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47+
* OF THE POSSIBILITY OF SUCH DAMAGE.
48+
* ====================================================================
49+
*
50+
*/
51+
52+
#ifndef HEADER_AES_H
53+
# define HEADER_AES_H
54+
55+
# include <openssl/opensslconf.h>
56+
57+
# ifdef OPENSSL_NO_AES
58+
# error AES is disabled.
59+
# endif
60+
61+
# include <stddef.h>
62+
63+
# define AES_ENCRYPT 1
64+
# define AES_DECRYPT 0
65+
66+
/*
67+
* Because array size can't be a const in C, the following two are macros.
68+
* Both sizes are in bytes.
69+
*/
70+
# define AES_MAXNR 14
71+
# define AES_BLOCK_SIZE 16
72+
73+
#ifdef __cplusplus
74+
extern "C" {
75+
#endif
76+
77+
/* This should be a hidden type, but EVP requires that the size be known */
78+
struct aes_key_st {
79+
# ifdef AES_LONG
80+
unsigned long rd_key[4 * (AES_MAXNR + 1)];
81+
# else
82+
unsigned int rd_key[4 * (AES_MAXNR + 1)];
83+
# endif
84+
int rounds;
85+
};
86+
typedef struct aes_key_st AES_KEY;
87+
88+
const char *AES_options(void);
89+
90+
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
91+
AES_KEY *key);
92+
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
93+
AES_KEY *key);
94+
95+
int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,
96+
AES_KEY *key);
97+
int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,
98+
AES_KEY *key);
99+
100+
void AES_encrypt(const unsigned char *in, unsigned char *out,
101+
const AES_KEY *key);
102+
void AES_decrypt(const unsigned char *in, unsigned char *out,
103+
const AES_KEY *key);
104+
105+
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
106+
const AES_KEY *key, const int enc);
107+
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
108+
size_t length, const AES_KEY *key,
109+
unsigned char *ivec, const int enc);
110+
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
111+
size_t length, const AES_KEY *key,
112+
unsigned char *ivec, int *num, const int enc);
113+
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
114+
size_t length, const AES_KEY *key,
115+
unsigned char *ivec, int *num, const int enc);
116+
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
117+
size_t length, const AES_KEY *key,
118+
unsigned char *ivec, int *num, const int enc);
119+
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
120+
size_t length, const AES_KEY *key,
121+
unsigned char *ivec, int *num);
122+
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
123+
size_t length, const AES_KEY *key,
124+
unsigned char ivec[AES_BLOCK_SIZE],
125+
unsigned char ecount_buf[AES_BLOCK_SIZE],
126+
unsigned int *num);
127+
/* NB: the IV is _two_ blocks long */
128+
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
129+
size_t length, const AES_KEY *key,
130+
unsigned char *ivec, const int enc);
131+
/* NB: the IV is _four_ blocks long */
132+
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
133+
size_t length, const AES_KEY *key,
134+
const AES_KEY *key2, const unsigned char *ivec,
135+
const int enc);
136+
137+
int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
138+
unsigned char *out,
139+
const unsigned char *in, unsigned int inlen);
140+
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
141+
unsigned char *out,
142+
const unsigned char *in, unsigned int inlen);
143+
144+
145+
#ifdef __cplusplus
146+
}
147+
#endif
148+
149+
#endif /* !HEADER_AES_H */

lib/openssl/include/openssl/applink.c

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#define APPLINK_STDIN 1
2+
#define APPLINK_STDOUT 2
3+
#define APPLINK_STDERR 3
4+
#define APPLINK_FPRINTF 4
5+
#define APPLINK_FGETS 5
6+
#define APPLINK_FREAD 6
7+
#define APPLINK_FWRITE 7
8+
#define APPLINK_FSETMOD 8
9+
#define APPLINK_FEOF 9
10+
#define APPLINK_FCLOSE 10 /* should not be used */
11+
12+
#define APPLINK_FOPEN 11 /* solely for completeness */
13+
#define APPLINK_FSEEK 12
14+
#define APPLINK_FTELL 13
15+
#define APPLINK_FFLUSH 14
16+
#define APPLINK_FERROR 15
17+
#define APPLINK_CLEARERR 16
18+
#define APPLINK_FILENO 17 /* to be used with below */
19+
20+
#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
21+
#define APPLINK_READ 19
22+
#define APPLINK_WRITE 20
23+
#define APPLINK_LSEEK 21
24+
#define APPLINK_CLOSE 22
25+
#define APPLINK_MAX 22 /* always same as last macro */
26+
27+
#ifndef APPMACROS_ONLY
28+
# include <stdio.h>
29+
# include <io.h>
30+
# include <fcntl.h>
31+
32+
static void *app_stdin(void)
33+
{
34+
return stdin;
35+
}
36+
37+
static void *app_stdout(void)
38+
{
39+
return stdout;
40+
}
41+
42+
static void *app_stderr(void)
43+
{
44+
return stderr;
45+
}
46+
47+
static int app_feof(FILE *fp)
48+
{
49+
return feof(fp);
50+
}
51+
52+
static int app_ferror(FILE *fp)
53+
{
54+
return ferror(fp);
55+
}
56+
57+
static void app_clearerr(FILE *fp)
58+
{
59+
clearerr(fp);
60+
}
61+
62+
static int app_fileno(FILE *fp)
63+
{
64+
return _fileno(fp);
65+
}
66+
67+
static int app_fsetmod(FILE *fp, char mod)
68+
{
69+
return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
70+
}
71+
72+
#ifdef __cplusplus
73+
extern "C" {
74+
#endif
75+
76+
__declspec(dllexport)
77+
void **
78+
# if defined(__BORLANDC__)
79+
/*
80+
* __stdcall appears to be the only way to get the name
81+
* decoration right with Borland C. Otherwise it works
82+
* purely incidentally, as we pass no parameters.
83+
*/
84+
__stdcall
85+
# else
86+
__cdecl
87+
# endif
88+
OPENSSL_Applink(void)
89+
{
90+
static int once = 1;
91+
static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =
92+
{ (void *)APPLINK_MAX };
93+
94+
if (once) {
95+
OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
96+
OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
97+
OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
98+
OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
99+
OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
100+
OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
101+
OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
102+
OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
103+
OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
104+
OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
105+
106+
OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
107+
OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
108+
OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
109+
OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
110+
OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
111+
OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
112+
OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
113+
114+
OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
115+
OPENSSL_ApplinkTable[APPLINK_READ] = _read;
116+
OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
117+
OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
118+
OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
119+
120+
once = 0;
121+
}
122+
123+
return OPENSSL_ApplinkTable;
124+
}
125+
126+
#ifdef __cplusplus
127+
}
128+
#endif
129+
#endif

0 commit comments

Comments
 (0)