forked from cory/tildefriends
Update to V8 6.0 and fixes for OpenSSL 1.1.0.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3408 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
84c8d74d2a
commit
3b27db2655
22
SConstruct
22
SConstruct
@ -30,6 +30,7 @@ env.Append(CPPPATH=[
|
||||
os.path.join(uv, 'include'),
|
||||
os.path.join(liblmdb, 'libraries', 'liblmdb'),
|
||||
])
|
||||
grouped_libs = []
|
||||
|
||||
objectSuffix = '.obj' if sys.platform == 'win32' else '.o'
|
||||
raspi = platform.machine() == 'armv7l'
|
||||
@ -44,13 +45,17 @@ if raspi:
|
||||
os.path.join(v8, 'out', 'arm.release', 'obj.target', 'third_party', 'icu', 'libicuuc.a'),
|
||||
]
|
||||
else:
|
||||
libs += env.Library('build/bin/v8_libplatform', Glob(os.path.join(v8, 'out', 'obj', 'v8_libplatform', '*' + objectSuffix)))
|
||||
libs += env.Library('build/bin/v8_base', Glob(os.path.join(v8, 'out', 'obj', 'v8_base', '*' + objectSuffix)))
|
||||
libs += env.Library('build/bin/v8_libbase', Glob(os.path.join(v8, 'out', 'obj', 'v8_libbase', '*' + objectSuffix)))
|
||||
libs += env.Library('build/bin/v8_libsampler', Glob(os.path.join(v8, 'out', 'obj', 'v8_libsampler', '*' + objectSuffix)))
|
||||
libs += env.Library('build/bin/v8_nosnapshot', Glob(os.path.join(v8, 'out', 'obj', 'v8_nosnapshot', '*' + objectSuffix)))
|
||||
libs += env.Library('build/bin/icui18n', Glob(os.path.join(v8, 'out', 'obj', 'third_party', 'icu', 'icui18n', '*' + objectSuffix)))
|
||||
libs += env.Library('build/bin/icuuc', Glob(os.path.join(v8, 'out', 'obj', 'third_party', 'icu', 'icuuc', '*' + objectSuffix)))
|
||||
grouped_libs += ['-Wl,--start-group']
|
||||
grouped_libs += [env.Library('build/bin/v8_libplatform', Glob(os.path.join(v8, 'out', 'obj', 'v8_libplatform', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/v8_base', Glob(os.path.join(v8, 'out', 'obj', 'v8_base', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/v8_builtins_setup', Glob(os.path.join(v8, 'out', 'obj', 'v8_builtins_setup', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/v8_libbase', Glob(os.path.join(v8, 'out', 'obj', 'v8_libbase', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/v8_builtins_generators', Glob(os.path.join(v8, 'out', 'obj', 'v8_builtins_generators', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/v8_libsampler', Glob(os.path.join(v8, 'out', 'obj', 'v8_libsampler', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/v8_nosnapshot', Glob(os.path.join(v8, 'out', 'obj', 'v8_nosnapshot', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/icui18n', Glob(os.path.join(v8, 'out', 'obj', 'third_party', 'icu', 'icui18n', '*' + objectSuffix)))]
|
||||
grouped_libs += [env.Library('build/bin/icuuc', Glob(os.path.join(v8, 'out', 'obj', 'third_party', 'icu', 'icuuc', '*' + objectSuffix)))]
|
||||
grouped_libs += ['-Wl,--end-group']
|
||||
|
||||
if sys.platform == 'win32':
|
||||
env.Append(LIBS=['libuv', 'advapi32', 'winmm', 'wsock32', 'ws2_32', 'psapi', 'iphlpapi', 'userenv', 'user32', 'dbghelp', 'shlwapi'])
|
||||
@ -96,6 +101,9 @@ if sys.platform == 'darwin':
|
||||
env.Append(FRAMEWORKS=['CoreFoundation', 'Security'])
|
||||
elif sys.platform == 'win32':
|
||||
env.Append(LIBS=['Crypt32'])
|
||||
if grouped_libs:
|
||||
env.Append(GROUPED_LIBS = grouped_libs)
|
||||
env.Append(LINKCOM = ' $GROUPED_LIBS')
|
||||
env.Program('tildefriends', source + libs)
|
||||
|
||||
def listAllFiles(root):
|
||||
|
@ -97,7 +97,7 @@ Task::Task() {
|
||||
_loop = uv_loop_new();
|
||||
++_count;
|
||||
v8::Isolate::CreateParams options;
|
||||
options.array_buffer_allocator = &_allocator;
|
||||
options.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
|
||||
_isolate = v8::Isolate::New(options);
|
||||
_isolate->SetData(0, this);
|
||||
_isolate->SetCaptureStackTraceForUncaughtExceptions(true, 16);
|
||||
|
18
src/Task.h
18
src/Task.h
@ -39,23 +39,6 @@ enum MessageType {
|
||||
kGetExports,
|
||||
};
|
||||
|
||||
class NewArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
public:
|
||||
void* Allocate(size_t length) {
|
||||
char* bytes = new char[length];
|
||||
std::memset(bytes, 0, length);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void* AllocateUninitialized(size_t length) {
|
||||
return new char[length];
|
||||
}
|
||||
|
||||
void Free(void* data, size_t length) {
|
||||
delete[] reinterpret_cast<char*>(data);
|
||||
}
|
||||
};
|
||||
|
||||
class Task {
|
||||
public:
|
||||
Task();
|
||||
@ -103,7 +86,6 @@ private:
|
||||
bool _trusted = false;
|
||||
bool _killed = false;
|
||||
std::string _scriptName;
|
||||
NewArrayBufferAllocator _allocator;
|
||||
v8::Isolate* _isolate = 0;
|
||||
|
||||
std::map<promiseid_t, v8::Persistent<v8::Promise::Resolver, v8::CopyablePersistentTraits<v8::Promise::Resolver> > > _promises;
|
||||
|
16
src/Tls.cpp
16
src/Tls.cpp
@ -49,8 +49,11 @@ public:
|
||||
|
||||
private:
|
||||
bool verifyPeerCertificate();
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
bool verifyHostname(X509* certificate, const char* hostname);
|
||||
bool wildcardMatch(const char* pattern, const char* name);
|
||||
#endif
|
||||
|
||||
TlsContext_openssl* _context = 0;
|
||||
BIO* _bioIn = 0;
|
||||
@ -152,6 +155,9 @@ void TlsSession_openssl::startAccept() {
|
||||
void TlsSession_openssl::startConnect() {
|
||||
_direction = kConnect;
|
||||
_ssl = SSL_new(_context->getContext());
|
||||
X509_VERIFY_PARAM* param = SSL_get0_param(_ssl);
|
||||
X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
|
||||
X509_VERIFY_PARAM_set1_host(param, _hostname.c_str(), 0);
|
||||
SSL_set_bio(_ssl, _bioIn, _bioOut);
|
||||
|
||||
SSL_connect(_ssl);
|
||||
@ -233,15 +239,20 @@ bool TlsSession_openssl::verifyPeerCertificate() {
|
||||
if (certificate) {
|
||||
|
||||
if (SSL_get_verify_result(_ssl) == X509_V_OK) {
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
if (verifyHostname(certificate, _hostname.c_str())) {
|
||||
verified = true;
|
||||
}
|
||||
#else
|
||||
verified = true;
|
||||
#endif
|
||||
}
|
||||
X509_free(certificate);
|
||||
}
|
||||
return verified;
|
||||
}
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
bool TlsSession_openssl::wildcardMatch(const char* pattern, const char* name) {
|
||||
while (*pattern && *name) {
|
||||
if (*pattern == '*') {
|
||||
@ -268,7 +279,7 @@ bool TlsSession_openssl::verifyHostname(X509* certificate, const char* hostname)
|
||||
int count = sk_GENERAL_NAME_num(names);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const GENERAL_NAME* check = sk_GENERAL_NAME_value(names, i);
|
||||
const char* name = reinterpret_cast<const char*>(ASN1_STRING_data(check->d.ia5));
|
||||
const char* name = ASN1_STRING_get0_data(check->d.ia5);
|
||||
size_t length = ASN1_STRING_length(check->d.ia5);
|
||||
if (wildcardMatch(std::string(name, length).c_str(), hostname)) {
|
||||
verified = true;
|
||||
@ -284,7 +295,7 @@ bool TlsSession_openssl::verifyHostname(X509* certificate, const char* hostname)
|
||||
if (entry) {
|
||||
ASN1_STRING* asn1 = X509_NAME_ENTRY_get_data(entry);
|
||||
if (asn1) {
|
||||
const char* commonName = reinterpret_cast<const char*>(ASN1_STRING_data(asn1));
|
||||
const char* commonName = ASN1_STRING_get0_data(asn1);
|
||||
if (static_cast<size_t>(ASN1_STRING_length(asn1)) == std::strlen(commonName)) {
|
||||
verified = wildcardMatch(commonName, hostname);
|
||||
}
|
||||
@ -295,6 +306,7 @@ bool TlsSession_openssl::verifyHostname(X509* certificate, const char* hostname)
|
||||
|
||||
return verified;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool TlsSession_openssl::getError(char* buffer, size_t bytes) {
|
||||
unsigned long error = ERR_get_error();
|
||||
|
@ -25,7 +25,7 @@ kUvBranch = 'v1.11.0'
|
||||
kUvWork = 'uv'
|
||||
|
||||
kV8Repository = 'https://github.com/v8/v8.git'
|
||||
kV8Branch = 'branch-heads/5.8'
|
||||
kV8Branch = 'branch-heads/6.0'
|
||||
kV8Work = 'v8'
|
||||
|
||||
kLmdbRepository = 'https://github.com/LMDB/lmdb.git'
|
||||
|
Loading…
Reference in New Issue
Block a user