Update Arlib

This commit is contained in:
Alcaro
2016-12-20 02:10:51 +01:00
parent 9908250790
commit b56197317f
88 changed files with 25526 additions and 4386 deletions

View File

@@ -27,7 +27,7 @@ public:
SSL* ssl;
//bool nonblock;
static socketssl_impl* create(socket* parent, const char * domain, bool permissive)
static socketssl_impl* create(socket* parent, cstring domain, bool permissive)
{
if (!parent) return NULL;
@@ -35,6 +35,7 @@ public:
ret->sock = parent;
ret->fd = parent->get_fd();
ret->ssl = SSL_new(ctx);
SSL_set_tlsext_host_name(ret->ssl, (const char*)domain);
//ret->nonblock = false;
SSL_set_fd(ret->ssl, ret->fd);
//TODO: set fd to nonblock
@@ -62,7 +63,7 @@ public:
bool ok = (SSL_connect(ret->ssl)==1);
#if OPENSSL_VERSION_NUMBER < 0x10002000 // < 1.0.2
if (ok && !validate_hostname(domain, SSL_get_peer_certificate(ret->ssl)))
if (ok && !permissive && !validate_hostname(domain, SSL_get_peer_certificate(ret->ssl)))
{
ok=false;
}
@@ -71,7 +72,7 @@ public:
if (!ok)
{
delete ret;
return 0;
return NULL;
}
return ret;
}
@@ -88,14 +89,14 @@ public:
}
//only supports nonblocking
int recv(uint8_t* data, unsigned int len, bool block = false)
int recv(arrayvieww<uint8_t> data, bool block = false)
{
return fixret(SSL_read(ssl, data, len));
return fixret(SSL_read(ssl, data.ptr(), data.size()));
}
int sendp(const uint8_t* data, unsigned int len, bool block = true)
int sendp(arrayview<uint8_t> data, bool block = true)
{
return fixret(SSL_write(ssl, data, len));
return fixret(SSL_write(ssl, data.ptr(), data.size()));
}
~socketssl_impl()
@@ -106,7 +107,7 @@ public:
}
};
socketssl* socketssl::create(socket* parent, const char * domain, bool permissive)
socketssl* socketssl::create(socket* parent, cstring domain, bool permissive)
{
initialize();
if (!ctx) return NULL;