zeroc-ice 3.8.1 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dist/IceRuby/Operation.cpp +22 -6
- data/dist/ice/cpp/include/Ice/Config.h +2 -2
- data/dist/ice/cpp/include/Ice/LocalExceptions.h +21 -0
- data/dist/ice/cpp/include/Ice/OutputStream.h +7 -5
- data/dist/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/Context.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/Identity.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/Locator.h +9 -11
- data/dist/ice/cpp/include/generated/Ice/LocatorRegistry.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/Metrics.h +7 -7
- data/dist/ice/cpp/include/generated/Ice/OperationMode.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/Process.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/PropertiesAdmin.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/PropertyDict.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/RemoteLogger.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/ReplyStatus.h +8 -4
- data/dist/ice/cpp/include/generated/Ice/Router.h +7 -7
- data/dist/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
- data/dist/ice/cpp/include/generated/Ice/Version.h +2 -2
- data/dist/ice/cpp/include/generated/IceDiscovery/Lookup.h +2 -2
- data/dist/ice/cpp/include/generated/IceLocatorDiscovery/Lookup.h +2 -2
- data/dist/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +5 -3
- data/dist/ice/cpp/src/Ice/ConnectionI.cpp +27 -9
- data/dist/ice/cpp/src/Ice/ConnectionI.h +1 -1
- data/dist/ice/cpp/src/Ice/FileUtil.cpp +3 -67
- data/dist/ice/cpp/src/Ice/FileUtil.h +0 -3
- data/dist/ice/cpp/src/Ice/IPEndpointI.cpp +4 -0
- data/dist/ice/cpp/src/Ice/IncomingRequest.cpp +1 -1
- data/dist/ice/cpp/src/Ice/InputStream.cpp +28 -15
- data/dist/ice/cpp/src/Ice/LocalExceptions.cpp +6 -0
- data/dist/ice/cpp/src/Ice/OutgoingAsync.cpp +1 -1
- data/dist/ice/cpp/src/Ice/OutgoingResponse.cpp +127 -127
- data/dist/ice/cpp/src/Ice/OutgoingResponseInternal.h +21 -0
- data/dist/ice/cpp/src/Ice/OutputStream.cpp +46 -61
- data/dist/ice/cpp/src/Ice/PropertyNames.cpp +2 -1
- data/dist/ice/cpp/src/Ice/ProxyFunctions.cpp +4 -4
- data/dist/ice/cpp/src/Ice/Reference.cpp +15 -15
- data/dist/ice/cpp/src/Ice/ReferenceFactory.cpp +16 -13
- data/dist/ice/cpp/src/Ice/ResourceConfig.h +2 -2
- data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.cpp +12 -11
- data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.h +1 -2
- data/dist/ice/cpp/src/Ice/SSL/SSLEndpointI.cpp +1 -1
- data/dist/ice/cpp/src/Ice/SSL/SSLEngine.h +1 -4
- data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.cpp +50 -43
- data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.h +1 -5
- data/dist/ice/cpp/src/Ice/SSL/SchannelTransceiverI.cpp +9 -0
- data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.cpp +107 -14
- data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.h +7 -2
- data/dist/ice/cpp/src/Ice/TcpEndpointI.cpp +2 -2
- data/dist/ice/cpp/src/Ice/UdpEndpointI.cpp +2 -2
- data/dist/ice/cpp/src/Ice/WSAcceptor.cpp +8 -3
- data/dist/ice/cpp/src/Ice/WSAcceptor.h +5 -1
- data/dist/ice/cpp/src/Ice/WSEndpoint.cpp +45 -2
- data/dist/ice/cpp/src/Ice/WSTransceiver.cpp +118 -7
- data/dist/ice/cpp/src/Ice/WSTransceiver.h +12 -1
- data/dist/ice/cpp/src/Ice/generated/BuiltinSequences.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/Context.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/EndpointTypes.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/Identity.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/Locator.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/LocatorRegistry.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/Metrics.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/OperationMode.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/Process.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/PropertiesAdmin.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/PropertyDict.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/RemoteLogger.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/ReplyStatus.cpp +4 -2
- data/dist/ice/cpp/src/Ice/generated/Router.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/SliceChecksumDict.cpp +2 -2
- data/dist/ice/cpp/src/Ice/generated/Version.cpp +2 -2
- data/dist/ice/cpp/src/IceDiscovery/generated/Lookup.cpp +2 -2
- data/dist/ice/cpp/src/IceLocatorDiscovery/generated/Lookup.cpp +2 -2
- data/dist/ice/cpp/src/Slice/DocCommentParser.cpp +6 -6
- data/dist/ice/cpp/src/Slice/DocCommentParser.h +4 -2
- data/dist/ice/cpp/src/Slice/MetadataValidation.cpp +24 -5
- data/dist/ice/cpp/src/Slice/MetadataValidation.h +3 -2
- data/dist/ice/cpp/src/Slice/Parser.cpp +117 -77
- data/dist/ice/cpp/src/Slice/Parser.h +19 -4
- data/dist/ice/cpp/src/Slice/Preprocessor.cpp +75 -19
- data/dist/ice/cpp/src/Slice/Preprocessor.h +0 -1
- data/dist/ice/cpp/src/Slice/SliceUtil.cpp +6 -58
- data/dist/ice/cpp/src/Slice/Util.h +0 -3
- data/dist/ice/cpp/src/slice2rb/RubyUtil.cpp +10 -8
- data/dist/ice/cpp/src/slice2rb/RubyUtil.h +10 -13
- data/dist/ice/slice/Ice/Identity.ice +3 -0
- data/dist/ice/slice/Ice/Locator.ice +6 -5
- data/dist/ice/slice/Ice/LocatorRegistry.ice +3 -0
- data/dist/ice/slice/Ice/Metrics.ice +1 -1
- data/dist/ice/slice/Ice/OperationMode.ice +8 -0
- data/dist/ice/slice/Ice/Process.ice +3 -0
- data/dist/ice/slice/Ice/ReplyStatus.ice +13 -0
- data/dist/lib/Glacier2/Metrics.rb +1 -1
- data/dist/lib/Glacier2/PermissionsVerifier.rb +3 -3
- data/dist/lib/Glacier2/Router.rb +8 -8
- data/dist/lib/Glacier2/SSLInfo.rb +1 -1
- data/dist/lib/Glacier2/Session.rb +15 -15
- data/dist/lib/Ice/BuiltinSequences.rb +1 -1
- data/dist/lib/Ice/Context.rb +1 -1
- data/dist/lib/Ice/EndpointTypes.rb +1 -1
- data/dist/lib/Ice/Identity.rb +1 -1
- data/dist/lib/Ice/LocalExceptions.rb +3 -0
- data/dist/lib/Ice/Locator.rb +5 -5
- data/dist/lib/Ice/LocatorRegistry.rb +4 -4
- data/dist/lib/Ice/Metrics.rb +7 -7
- data/dist/lib/Ice/OperationMode.rb +1 -1
- data/dist/lib/Ice/Process.rb +3 -3
- data/dist/lib/Ice/PropertiesAdmin.rb +4 -4
- data/dist/lib/Ice/PropertyDict.rb +1 -1
- data/dist/lib/Ice/ProxyFunctions.rb +8 -4
- data/dist/lib/Ice/RemoteLogger.rb +6 -6
- data/dist/lib/Ice/ReplyStatus.rb +3 -2
- data/dist/lib/Ice/Router.rb +5 -5
- data/dist/lib/Ice/SliceChecksumDict.rb +1 -1
- data/dist/lib/Ice/Version.rb +1 -1
- data/dist/lib/IceBox/ServiceManager.rb +8 -8
- data/dist/lib/IceGrid/Admin.rb +83 -83
- data/dist/lib/IceGrid/Descriptor.rb +1 -1
- data/dist/lib/IceGrid/Exception.rb +1 -1
- data/dist/lib/IceGrid/FileParser.rb +2 -2
- data/dist/lib/IceGrid/Registry.rb +13 -13
- data/dist/lib/IceGrid/Session.rb +6 -6
- data/dist/lib/IceGrid/UserAccountMapper.rb +2 -2
- data/dist/lib/IceStorm/IceStorm.rb +16 -16
- data/dist/lib/IceStorm/Metrics.rb +1 -1
- data/ice.gemspec +1 -1
- metadata +2 -1
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include "TargetCompare.h"
|
|
11
11
|
#include "WSAcceptor.h"
|
|
12
12
|
#include "WSConnector.h"
|
|
13
|
+
#include "WSTransceiver.h"
|
|
13
14
|
|
|
14
15
|
#include <algorithm>
|
|
15
16
|
|
|
@@ -21,6 +22,36 @@ namespace
|
|
|
21
22
|
{
|
|
22
23
|
const char* const wsPluginName = "IceWS";
|
|
23
24
|
|
|
25
|
+
// Parse the values of the ObjectAdapter property "AllowedOrigins" into a canonicalized set of origins.
|
|
26
|
+
// Each entry is "scheme://host[:port]", lowercased, with the default port for the scheme (80/443) omitted.
|
|
27
|
+
// The literal "*" disables enforcement; in that case the returned set is empty -- handleRequest treats an empty
|
|
28
|
+
// allowlist as "allow any origin", so the two cases (unset and wildcard) collapse into one.
|
|
29
|
+
// Throws PropertyException if any entry is not a syntactically valid origin; propertyName is included in the
|
|
30
|
+
// message so the operator can identify which adapter is misconfigured.
|
|
31
|
+
set<string> parseAllowedOrigins(const vector<string>& entries, const string& propertyName)
|
|
32
|
+
{
|
|
33
|
+
set<string> result;
|
|
34
|
+
for (const auto& entry : entries)
|
|
35
|
+
{
|
|
36
|
+
if (entry == "*")
|
|
37
|
+
{
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
try
|
|
41
|
+
{
|
|
42
|
+
result.insert(canonicalizeOrigin(entry));
|
|
43
|
+
}
|
|
44
|
+
catch (const std::invalid_argument&)
|
|
45
|
+
{
|
|
46
|
+
throw PropertyException(
|
|
47
|
+
__FILE__,
|
|
48
|
+
__LINE__,
|
|
49
|
+
"malformed origin '" + entry + "' in property '" + propertyName + "'");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
24
55
|
class WSEndpointFactoryPlugin : public Plugin
|
|
25
56
|
{
|
|
26
57
|
public:
|
|
@@ -246,8 +277,20 @@ IceInternal::WSEndpoint::acceptor(
|
|
|
246
277
|
const string& adapterName,
|
|
247
278
|
const optional<Ice::SSL::ServerAuthenticationOptions>& serverAuthenticationOptions) const
|
|
248
279
|
{
|
|
280
|
+
// Parse AllowedOrigins before creating the delegate acceptor so a malformed property doesn't leave an open socket
|
|
281
|
+
// hanging on a TcpAcceptor whose destructor asserts INVALID_SOCKET.
|
|
282
|
+
set<string> allowedOrigins;
|
|
283
|
+
if (!adapterName.empty())
|
|
284
|
+
{
|
|
285
|
+
const string propertyName = adapterName + ".AllowedOrigins";
|
|
286
|
+
allowedOrigins = parseAllowedOrigins(_instance->properties()->getPropertyAsList(propertyName), propertyName);
|
|
287
|
+
}
|
|
249
288
|
AcceptorPtr acceptor = _delegate->acceptor(adapterName, serverAuthenticationOptions);
|
|
250
|
-
return make_shared<WSAcceptor>(
|
|
289
|
+
return make_shared<WSAcceptor>(
|
|
290
|
+
const_cast<WSEndpoint*>(this)->shared_from_this(),
|
|
291
|
+
_instance,
|
|
292
|
+
acceptor,
|
|
293
|
+
std::move(allowedOrigins));
|
|
251
294
|
}
|
|
252
295
|
|
|
253
296
|
WSEndpointPtr
|
|
@@ -255,7 +298,7 @@ IceInternal::WSEndpoint::endpoint(const EndpointIPtr& delEndp) const
|
|
|
255
298
|
{
|
|
256
299
|
if (delEndp.get() == _delegate.get())
|
|
257
300
|
{
|
|
258
|
-
return
|
|
301
|
+
return static_pointer_cast<WSEndpoint>(const_cast<WSEndpoint*>(this)->shared_from_this());
|
|
259
302
|
}
|
|
260
303
|
else
|
|
261
304
|
{
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
#include <climits>
|
|
17
17
|
#include <cstdint>
|
|
18
|
+
#include <stdexcept>
|
|
18
19
|
|
|
19
20
|
using namespace std;
|
|
20
21
|
using namespace Ice;
|
|
@@ -124,6 +125,49 @@ namespace
|
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
string
|
|
129
|
+
IceInternal::canonicalizeOrigin(string_view origin)
|
|
130
|
+
{
|
|
131
|
+
// Throws std::invalid_argument for any input that is not a serialized origin per RFC 6454.
|
|
132
|
+
auto sep = origin.find("://");
|
|
133
|
+
if (sep == string_view::npos || sep == 0)
|
|
134
|
+
{
|
|
135
|
+
throw invalid_argument{"malformed origin '" + string{origin} + "'"};
|
|
136
|
+
}
|
|
137
|
+
string scheme{origin.substr(0, sep)};
|
|
138
|
+
transform(
|
|
139
|
+
scheme.begin(),
|
|
140
|
+
scheme.end(),
|
|
141
|
+
scheme.begin(),
|
|
142
|
+
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
|
143
|
+
string_view authority = origin.substr(sep + 3);
|
|
144
|
+
// Tolerate a single trailing slash (some peers send "https://example.com/" as an Origin); reject any other
|
|
145
|
+
// path/query/fragment/userinfo.
|
|
146
|
+
if (!authority.empty() && authority.back() == '/')
|
|
147
|
+
{
|
|
148
|
+
authority.remove_suffix(1);
|
|
149
|
+
}
|
|
150
|
+
if (authority.empty() || authority.find_first_of("/?#@") != string_view::npos)
|
|
151
|
+
{
|
|
152
|
+
throw invalid_argument{"malformed origin '" + string{origin} + "'"};
|
|
153
|
+
}
|
|
154
|
+
string hostAndPort{authority};
|
|
155
|
+
transform(
|
|
156
|
+
hostAndPort.begin(),
|
|
157
|
+
hostAndPort.end(),
|
|
158
|
+
hostAndPort.begin(),
|
|
159
|
+
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
|
160
|
+
if (auto colon = hostAndPort.rfind(':'); colon != string::npos)
|
|
161
|
+
{
|
|
162
|
+
string_view port = string_view{hostAndPort}.substr(colon + 1);
|
|
163
|
+
if ((scheme == "http" && port == "80") || (scheme == "https" && port == "443"))
|
|
164
|
+
{
|
|
165
|
+
hostAndPort = hostAndPort.substr(0, colon);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return scheme + "://" + hostAndPort;
|
|
169
|
+
}
|
|
170
|
+
|
|
127
171
|
NativeInfoPtr
|
|
128
172
|
IceInternal::WSTransceiver::getNativeInfo()
|
|
129
173
|
{
|
|
@@ -845,9 +889,10 @@ IceInternal::WSTransceiver::WSTransceiver(
|
|
|
845
889
|
//
|
|
846
890
|
}
|
|
847
891
|
|
|
848
|
-
IceInternal::WSTransceiver::WSTransceiver(ProtocolInstancePtr instance, TransceiverPtr del)
|
|
892
|
+
IceInternal::WSTransceiver::WSTransceiver(ProtocolInstancePtr instance, TransceiverPtr del, set<string> allowedOrigins)
|
|
849
893
|
: _instance(std::move(instance)),
|
|
850
894
|
_delegate(std::move(del)),
|
|
895
|
+
_allowedOrigins(std::move(allowedOrigins)),
|
|
851
896
|
_incoming(true),
|
|
852
897
|
_state(StateInitializeDelegate),
|
|
853
898
|
_parser(make_shared<HttpParser>()),
|
|
@@ -961,6 +1006,32 @@ IceInternal::WSTransceiver::handleRequest(Buffer& responseBuffer)
|
|
|
961
1006
|
throw WebSocketException("invalid value '" + key + "' for WebSocket key");
|
|
962
1007
|
}
|
|
963
1008
|
|
|
1009
|
+
//
|
|
1010
|
+
// Optionally validate the Origin header against the adapter's allowed-origins list.
|
|
1011
|
+
// Browsers always send Origin; non-browser clients do not, so an absent header bypasses the check.
|
|
1012
|
+
// A wildcard ("*") allowlist is normalized to an empty set at parse time, so empty here means "no enforcement".
|
|
1013
|
+
//
|
|
1014
|
+
if (!_allowedOrigins.empty())
|
|
1015
|
+
{
|
|
1016
|
+
string origin;
|
|
1017
|
+
if (_parser->getHeader("Origin", origin, false))
|
|
1018
|
+
{
|
|
1019
|
+
string canonical;
|
|
1020
|
+
try
|
|
1021
|
+
{
|
|
1022
|
+
canonical = canonicalizeOrigin(IceInternal::trim(origin));
|
|
1023
|
+
}
|
|
1024
|
+
catch (const std::invalid_argument&)
|
|
1025
|
+
{
|
|
1026
|
+
throw WebSocketException("invalid Origin header '" + origin + "'");
|
|
1027
|
+
}
|
|
1028
|
+
if (_allowedOrigins.count(canonical) == 0)
|
|
1029
|
+
{
|
|
1030
|
+
throw WebSocketException("origin '" + origin + "' is not allowed");
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
964
1035
|
//
|
|
965
1036
|
// Retain the target resource.
|
|
966
1037
|
//
|
|
@@ -1120,6 +1191,16 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
|
|
|
1120
1191
|
byte ch = *_readI++;
|
|
1121
1192
|
_readOpCode = static_cast<int>(ch & byte{0xf});
|
|
1122
1193
|
|
|
1194
|
+
//
|
|
1195
|
+
// No extension is negotiated, so the RSV1, RSV2, and RSV3 bits must all be 0.
|
|
1196
|
+
//
|
|
1197
|
+
if ((ch & byte{0x70}) != byte{0})
|
|
1198
|
+
{
|
|
1199
|
+
throw ProtocolException(__FILE__, __LINE__, "invalid WebSocket frame: RSV bits must be 0");
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
const bool finalFrame = (ch & byte{FLAG_FINAL}) == byte{FLAG_FINAL};
|
|
1203
|
+
|
|
1123
1204
|
//
|
|
1124
1205
|
// Remember if last frame if we're going to read a data or
|
|
1125
1206
|
// continuation frame, this is only for protocol
|
|
@@ -1131,7 +1212,7 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
|
|
|
1131
1212
|
{
|
|
1132
1213
|
throw ProtocolException(__FILE__, __LINE__, "invalid data frame, no FIN on previous frame");
|
|
1133
1214
|
}
|
|
1134
|
-
_readLastFrame =
|
|
1215
|
+
_readLastFrame = finalFrame;
|
|
1135
1216
|
}
|
|
1136
1217
|
else if (_readOpCode == OP_CONT)
|
|
1137
1218
|
{
|
|
@@ -1139,7 +1220,7 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
|
|
|
1139
1220
|
{
|
|
1140
1221
|
throw ProtocolException(__FILE__, __LINE__, "invalid continuation frame, previous frame FIN set");
|
|
1141
1222
|
}
|
|
1142
|
-
_readLastFrame =
|
|
1223
|
+
_readLastFrame = finalFrame;
|
|
1143
1224
|
}
|
|
1144
1225
|
|
|
1145
1226
|
ch = *_readI++;
|
|
@@ -1162,6 +1243,30 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
|
|
|
1162
1243
|
// 127: The subsequent eight bytes contain the payload length
|
|
1163
1244
|
//
|
|
1164
1245
|
_readPayloadLength = static_cast<size_t>((ch & byte{0x7f}));
|
|
1246
|
+
|
|
1247
|
+
//
|
|
1248
|
+
// RFC 6455 section 5.5: control frames (close, ping, and pong) must not be fragmented
|
|
1249
|
+
// and must have a payload length of 125 bytes or less - they cannot use the 16-bit or
|
|
1250
|
+
// 64-bit extended length encoding. Enforce this before allocating any payload buffer.
|
|
1251
|
+
//
|
|
1252
|
+
if (_readOpCode == OP_CLOSE || _readOpCode == OP_PING || _readOpCode == OP_PONG)
|
|
1253
|
+
{
|
|
1254
|
+
if (!finalFrame)
|
|
1255
|
+
{
|
|
1256
|
+
throw ProtocolException(
|
|
1257
|
+
__FILE__,
|
|
1258
|
+
__LINE__,
|
|
1259
|
+
"invalid WebSocket control frame: the FIN bit is not set");
|
|
1260
|
+
}
|
|
1261
|
+
if (_readPayloadLength > 125)
|
|
1262
|
+
{
|
|
1263
|
+
throw ProtocolException(
|
|
1264
|
+
__FILE__,
|
|
1265
|
+
__LINE__,
|
|
1266
|
+
"invalid WebSocket control frame: the payload length exceeds 125 bytes");
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1165
1270
|
if (_readPayloadLength < 126)
|
|
1166
1271
|
{
|
|
1167
1272
|
_readHeaderLength = 0;
|
|
@@ -1194,7 +1299,10 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
|
|
|
1194
1299
|
|
|
1195
1300
|
if (_readPayloadLength == 126)
|
|
1196
1301
|
{
|
|
1197
|
-
|
|
1302
|
+
// memcpy avoids the alignment UB of a direct uint16_t* dereference on _readI.
|
|
1303
|
+
uint16_t length;
|
|
1304
|
+
memcpy(&length, _readI, sizeof(length));
|
|
1305
|
+
_readPayloadLength = static_cast<size_t>(ntohs(length));
|
|
1198
1306
|
_readI += 2;
|
|
1199
1307
|
}
|
|
1200
1308
|
else if (_readPayloadLength == 127)
|
|
@@ -1467,8 +1575,9 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
|
|
|
1467
1575
|
{
|
|
1468
1576
|
prepareWriteHeader(OP_CLOSE, 2);
|
|
1469
1577
|
|
|
1470
|
-
// Write closing reason
|
|
1471
|
-
|
|
1578
|
+
// Write closing reason. memcpy avoids the alignment UB of a direct uint16_t* store.
|
|
1579
|
+
const uint16_t reason = htons(static_cast<uint16_t>(_closingReason));
|
|
1580
|
+
memcpy(_writeBuffer.i, &reason, sizeof(reason));
|
|
1472
1581
|
if (!_incoming)
|
|
1473
1582
|
{
|
|
1474
1583
|
*_writeBuffer.i++ ^= _writeMask[0];
|
|
@@ -1688,7 +1797,9 @@ IceInternal::WSTransceiver::prepareWriteHeader(uint8_t opCode, IceInternal::Buff
|
|
|
1688
1797
|
// Use an extra 16 bits to encode the payload length.
|
|
1689
1798
|
//
|
|
1690
1799
|
*_writeBuffer.i++ = byte{126};
|
|
1691
|
-
|
|
1800
|
+
// memcpy avoids the alignment UB of a direct uint16_t* store.
|
|
1801
|
+
const uint16_t length = htons(static_cast<uint16_t>(payloadLength));
|
|
1802
|
+
memcpy(_writeBuffer.i, &length, sizeof(length));
|
|
1692
1803
|
_writeBuffer.i += 2;
|
|
1693
1804
|
}
|
|
1694
1805
|
else if (payloadLength > USHRT_MAX)
|
|
@@ -10,16 +10,26 @@
|
|
|
10
10
|
#include "ProtocolInstance.h"
|
|
11
11
|
#include "Transceiver.h"
|
|
12
12
|
|
|
13
|
+
#include <set>
|
|
14
|
+
#include <string>
|
|
15
|
+
#include <string_view>
|
|
16
|
+
|
|
13
17
|
namespace IceInternal
|
|
14
18
|
{
|
|
15
19
|
class ConnectorI;
|
|
16
20
|
class AcceptorI;
|
|
17
21
|
|
|
22
|
+
// Canonicalize an origin string: lowercase scheme and host, omit the default port (80 for http, 443 for https).
|
|
23
|
+
// A single trailing slash is tolerated. Throws std::invalid_argument if the input is not a syntactically valid
|
|
24
|
+
// origin per RFC 6454 -- "scheme://host[:port]" with no path beyond a trailing slash, no query, fragment, or
|
|
25
|
+
// userinfo.
|
|
26
|
+
std::string canonicalizeOrigin(std::string_view origin);
|
|
27
|
+
|
|
18
28
|
class WSTransceiver final : public Transceiver
|
|
19
29
|
{
|
|
20
30
|
public:
|
|
21
31
|
WSTransceiver(ProtocolInstancePtr, TransceiverPtr, std::string, std::string);
|
|
22
|
-
WSTransceiver(ProtocolInstancePtr, TransceiverPtr);
|
|
32
|
+
WSTransceiver(ProtocolInstancePtr, TransceiverPtr, std::set<std::string> allowedOrigins);
|
|
23
33
|
~WSTransceiver();
|
|
24
34
|
|
|
25
35
|
NativeInfoPtr getNativeInfo() final;
|
|
@@ -66,6 +76,7 @@ namespace IceInternal
|
|
|
66
76
|
const TransceiverPtr _delegate;
|
|
67
77
|
const std::string _host;
|
|
68
78
|
const std::string _resource;
|
|
79
|
+
const std::set<std::string> _allowedOrigins;
|
|
69
80
|
const bool _incoming;
|
|
70
81
|
|
|
71
82
|
enum State
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'BuiltinSequences.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Context.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'EndpointTypes.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Identity.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Locator.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'LocatorRegistry.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Metrics.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
# if ICE_INT_VERSION % 100 >= 50
|
|
34
34
|
# error Beta header file detected
|
|
35
35
|
# endif
|
|
36
|
-
# if ICE_INT_VERSION % 100 <
|
|
36
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
37
37
|
# error Ice patch level mismatch!
|
|
38
38
|
# endif
|
|
39
39
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'OperationMode.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Process.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
# if ICE_INT_VERSION % 100 >= 50
|
|
34
34
|
# error Beta header file detected
|
|
35
35
|
# endif
|
|
36
|
-
# if ICE_INT_VERSION % 100 <
|
|
36
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
37
37
|
# error Ice patch level mismatch!
|
|
38
38
|
# endif
|
|
39
39
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'PropertiesAdmin.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
# if ICE_INT_VERSION % 100 >= 50
|
|
34
34
|
# error Beta header file detected
|
|
35
35
|
# endif
|
|
36
|
-
# if ICE_INT_VERSION % 100 <
|
|
36
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
37
37
|
# error Ice patch level mismatch!
|
|
38
38
|
# endif
|
|
39
39
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'PropertyDict.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'RemoteLogger.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
# if ICE_INT_VERSION % 100 >= 50
|
|
34
34
|
# error Beta header file detected
|
|
35
35
|
# endif
|
|
36
|
-
# if ICE_INT_VERSION % 100 <
|
|
36
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
37
37
|
# error Ice patch level mismatch!
|
|
38
38
|
# endif
|
|
39
39
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'ReplyStatus.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -64,6 +64,8 @@ Ice::operator<<(std::ostream& os, ReplyStatus value)
|
|
|
64
64
|
return os << "InvalidData";
|
|
65
65
|
case ReplyStatus::Unauthorized:
|
|
66
66
|
return os << "Unauthorized";
|
|
67
|
+
case ReplyStatus::NotSupported:
|
|
68
|
+
return os << "NotSupported";
|
|
67
69
|
default:
|
|
68
70
|
return os << static_cast<std::int32_t>(value);
|
|
69
71
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Router.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
# if ICE_INT_VERSION % 100 >= 50
|
|
34
34
|
# error Beta header file detected
|
|
35
35
|
# endif
|
|
36
|
-
# if ICE_INT_VERSION % 100 <
|
|
36
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
37
37
|
# error Ice patch level mismatch!
|
|
38
38
|
# endif
|
|
39
39
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'SliceChecksumDict.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
# if ICE_INT_VERSION % 100 >= 50
|
|
34
34
|
# error Beta header file detected
|
|
35
35
|
# endif
|
|
36
|
-
# if ICE_INT_VERSION % 100 <
|
|
36
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
37
37
|
# error Ice patch level mismatch!
|
|
38
38
|
# endif
|
|
39
39
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Version.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#ifndef ICE_API_EXPORTS
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# if ICE_INT_VERSION % 100 >= 50
|
|
35
35
|
# error Beta header file detected
|
|
36
36
|
# endif
|
|
37
|
-
# if ICE_INT_VERSION % 100 <
|
|
37
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
38
38
|
# error Ice patch level mismatch!
|
|
39
39
|
# endif
|
|
40
40
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Lookup.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#define ICE_BUILDING_GENERATED_CODE
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
# if ICE_INT_VERSION % 100 >= 50
|
|
31
31
|
# error Beta header file detected
|
|
32
32
|
# endif
|
|
33
|
-
# if ICE_INT_VERSION % 100 <
|
|
33
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
34
34
|
# error Ice patch level mismatch!
|
|
35
35
|
# endif
|
|
36
36
|
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) ZeroC, Inc.
|
|
2
2
|
|
|
3
|
-
// slice2cpp version 3.8.
|
|
3
|
+
// slice2cpp version 3.8.2
|
|
4
4
|
// <auto-generated>Generated from Slice file 'Lookup.ice'.</auto-generated>
|
|
5
5
|
|
|
6
6
|
#define ICE_BUILDING_GENERATED_CODE
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
# if ICE_INT_VERSION % 100 >= 50
|
|
31
31
|
# error Beta header file detected
|
|
32
32
|
# endif
|
|
33
|
-
# if ICE_INT_VERSION % 100 <
|
|
33
|
+
# if ICE_INT_VERSION % 100 < 2
|
|
34
34
|
# error Ice patch level mismatch!
|
|
35
35
|
# endif
|
|
36
36
|
#endif
|