mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
x.websockets: new websockets module on top of x.net (#6189)
This commit is contained in:
@ -6,6 +6,8 @@ module openssl
|
||||
// the next flag is harmless, since it will still use the
|
||||
// (older) system openssl.
|
||||
#flag linux -I/usr/local/include/openssl -L/usr/local/lib
|
||||
#flag windows -l libssl -l libcrypto
|
||||
|
||||
#flag -l ssl -l crypto
|
||||
// MacPorts
|
||||
#flag darwin -I/opt/local/include
|
||||
@ -40,6 +42,7 @@ fn C.SSL_set_fd() int
|
||||
fn C.SSL_connect() int
|
||||
fn C.SSL_set_cipher_list() int
|
||||
fn C.SSL_get_peer_certificate() int
|
||||
fn C.SSL_get_error() int
|
||||
fn C.SSL_get_verify_result() int
|
||||
fn C.SSL_set_tlsext_host_name() int
|
||||
fn C.SSL_shutdown()
|
||||
@ -52,6 +55,7 @@ fn C.SSLv23_client_method() &C.SSL_METHOD
|
||||
fn C.TLSv1_2_method() voidptr
|
||||
|
||||
fn init() {
|
||||
C.SSL_load_error_strings()
|
||||
C.SSL_library_init()
|
||||
}
|
||||
|
||||
|
27
vlib/net/openssl/openssl.v
Normal file
27
vlib/net/openssl/openssl.v
Normal file
@ -0,0 +1,27 @@
|
||||
module openssl
|
||||
|
||||
// ssl_error returns non error ssl code or error if unrecoverable and we should panic
|
||||
pub fn ssl_error(ret int, ssl voidptr) ?SSLError {
|
||||
res := C.SSL_get_error(ssl, ret)
|
||||
match SSLError(res) {
|
||||
.ssl_error_syscall { return error_with_code('unrecoverable syscall ($res)', res) }
|
||||
.ssl_error_ssl { return error_with_code('unrecoverable ssl protocol error ($res)',
|
||||
res) }
|
||||
else { return res }
|
||||
}
|
||||
}
|
||||
|
||||
pub enum SSLError {
|
||||
ssl_error_none = 0 //SSL_ERROR_NONE
|
||||
ssl_error_ssl = 1 //SSL_ERROR_SSL
|
||||
ssl_error_want_read = 2 //SSL_ERROR_WANT_READ
|
||||
ssl_error_want_write = 3 //SSL_ERROR_WANT_WRITE
|
||||
ssl_error_want_x509_lookup = 4 //SSL_ERROR_WANT_X509_LOOKUP
|
||||
ssl_error_syscall = 5 //SSL_ERROR_SYSCALL
|
||||
ssl_error_zero_return = 6 //SSL_ERROR_ZERO_RETURN
|
||||
ssl_error_want_connect = 7 //SSL_ERROR_WANT_CONNECT
|
||||
ssl_error_want_accept = 8 //SSL_ERROR_WANT_ACCEPT
|
||||
ssl_error_want_async = 9 //SSL_ERROR_WANT_ASYNC
|
||||
ssl_error_want_async_job = 10 //SSL_ERROR_WANT_ASYNC_JOB
|
||||
ssl_error_want_early = 11 //SSL_ERROR_WANT_EARLY
|
||||
}
|
Reference in New Issue
Block a user