mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net.mbedtls: make compile with -prod
This commit is contained in:
parent
9d9785cc05
commit
cc47c78f39
@ -4,8 +4,9 @@
|
|||||||
in addition to `[skip]`. This allows having custom behavior for different serialization methods.
|
in addition to `[skip]`. This allows having custom behavior for different serialization methods.
|
||||||
- ORM: fixed a foreign key bug that could result in an extra insert.
|
- ORM: fixed a foreign key bug that could result in an extra insert.
|
||||||
- Generic functions as function parameters are now supported: `fn f[T](x T, i int, f_ Fn[T]) T { `.
|
- Generic functions as function parameters are now supported: `fn f[T](x T, i int, f_ Fn[T]) T { `.
|
||||||
- Enum values now can have attributes.
|
- Enum values now can have attributes.
|
||||||
- json: Enum value string serialization supports `[json:'alias']` to change its string values.
|
- json: Enum value string serialization supports `[json:'alias']` to change its string values.
|
||||||
|
- Functions can now return fixed size arrays.
|
||||||
|
|
||||||
## V 0.3.4
|
## V 0.3.4
|
||||||
|
|
||||||
@ -142,12 +143,12 @@ Final steps in making the Option type a first class type:
|
|||||||
a T
|
a T
|
||||||
b U
|
b U
|
||||||
}
|
}
|
||||||
|
|
||||||
foo := Foo{
|
foo := Foo{
|
||||||
a: 2
|
a: 2
|
||||||
b: 'x'
|
b: 'x'
|
||||||
}
|
}
|
||||||
|
|
||||||
println(foo)
|
println(foo)
|
||||||
```
|
```
|
||||||
- unsafe: dereferencing nil references is no longer allowed in the following case:
|
- unsafe: dereferencing nil references is no longer allowed in the following case:
|
||||||
|
@ -12,14 +12,15 @@ fn init() {
|
|||||||
$if trace_ssl ? {
|
$if trace_ssl ? {
|
||||||
eprintln(@METHOD)
|
eprintln(@METHOD)
|
||||||
}
|
}
|
||||||
C.mbedtls_ctr_drbg_init(&mbedtls.ctr_drbg)
|
unsafe { // Unsafe is needed for taking an address of const
|
||||||
C.mbedtls_entropy_init(&mbedtls.entropy)
|
C.mbedtls_ctr_drbg_init(&mbedtls.ctr_drbg)
|
||||||
|
C.mbedtls_entropy_init(&mbedtls.entropy)
|
||||||
ret := C.mbedtls_ctr_drbg_seed(&mbedtls.ctr_drbg, C.mbedtls_entropy_func, &mbedtls.entropy,
|
ret := C.mbedtls_ctr_drbg_seed(&mbedtls.ctr_drbg, C.mbedtls_entropy_func, &mbedtls.entropy,
|
||||||
0, 0)
|
0, 0)
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
C.mbedtls_ctr_drbg_free(&mbedtls.ctr_drbg)
|
C.mbedtls_ctr_drbg_free(&mbedtls.ctr_drbg)
|
||||||
panic('Failed to seed ssl context: ${ret}')
|
panic('Failed to seed ssl context: ${ret}')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +111,9 @@ fn (mut s SSLConn) init() ! {
|
|||||||
return error_with_code('Failed to set SSL configuration', ret)
|
return error_with_code('Failed to set SSL configuration', ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
C.mbedtls_ssl_conf_rng(&s.conf, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg)
|
unsafe {
|
||||||
|
C.mbedtls_ssl_conf_rng(&s.conf, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg)
|
||||||
|
}
|
||||||
|
|
||||||
if s.config.verify != '' || s.config.cert != '' || s.config.cert_key != '' {
|
if s.config.verify != '' || s.config.cert != '' || s.config.cert_key != '' {
|
||||||
s.certs = &SSLCerts{}
|
s.certs = &SSLCerts{}
|
||||||
@ -127,8 +130,10 @@ fn (mut s SSLConn) init() ! {
|
|||||||
ret = C.mbedtls_x509_crt_parse(&s.certs.client_cert, s.config.cert.str, s.config.cert.len)
|
ret = C.mbedtls_x509_crt_parse(&s.certs.client_cert, s.config.cert.str, s.config.cert.len)
|
||||||
}
|
}
|
||||||
if s.config.cert_key != '' {
|
if s.config.cert_key != '' {
|
||||||
ret = C.mbedtls_pk_parse_key(&s.certs.client_key, s.config.cert_key.str, s.config.cert_key.len,
|
unsafe {
|
||||||
0, 0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg)
|
ret = C.mbedtls_pk_parse_key(&s.certs.client_key, s.config.cert_key.str,
|
||||||
|
s.config.cert_key.len, 0, 0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if s.config.verify != '' {
|
if s.config.verify != '' {
|
||||||
@ -138,8 +143,10 @@ fn (mut s SSLConn) init() ! {
|
|||||||
ret = C.mbedtls_x509_crt_parse_file(&s.certs.client_cert, &char(s.config.cert.str))
|
ret = C.mbedtls_x509_crt_parse_file(&s.certs.client_cert, &char(s.config.cert.str))
|
||||||
}
|
}
|
||||||
if s.config.cert_key != '' {
|
if s.config.cert_key != '' {
|
||||||
ret = C.mbedtls_pk_parse_keyfile(&s.certs.client_key, &char(s.config.cert_key.str),
|
unsafe {
|
||||||
0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg)
|
ret = C.mbedtls_pk_parse_keyfile(&s.certs.client_key, &char(s.config.cert_key.str),
|
||||||
|
0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user