From 02b9d5fb82c4bede07a4a169effc57d16fb95056 Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Mon, 2 Nov 2020 10:00:33 +0100 Subject: [PATCH] start using the bindings --- quicp2p.nim | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/quicp2p.nim b/quicp2p.nim index d6ce673..550136f 100644 --- a/quicp2p.nim +++ b/quicp2p.nim @@ -1,26 +1,29 @@ -{.passL: "-l quicly -l picotls-core -l picotls-openssl".} +{.passL: "-l quicly -l picotls-core -l picotls-openssl -l crypto".} import quicly/quicly +import quicly/defaults import picotls/picotls import picotls/openssl +proc onStreamOpen(self: ptr quicly_stream_open_t, stream: ptr quicly_stream_t): + cint {.cdecl.} = + echo "onStreamOpen!" + proc main() = + # callbacks + var streamOpen = quicly_stream_open_t(cb: onStreamOpen) + + var signCertificates: ptls_openssl_sign_certificate_t + var tlsCtx = ptls_context_t(randomBytes: ptlsOpensslRandomBytes, + getTime: addr ptlsGetTime, + keyExchanges: ptlsOpensslKeyExchanges, + cipherSuites: ptlsOpensslCipherSuites) + quiclyAmendPtlsContext(addr tlsCtx) + var ctx = quiclySpecContext + ctx.tls = addr tlsCtx + ctx.stream_open = addr streamOpen + # TODO: ptls_load_certificates echo "hello world" -#type -# PtlsGetTime {.pure, final.} = pointer -# -# PtlsContext {.importc: "struct ptls_context_t", pure, final, -# header: "picotls.h".} = object -# random_bytes: proc(buf: pointer, len: csize_t) {.cdecl.} -# get_time: ptr PtlsGetTime -# key_exchanges: ptr ptr PtlsKeyExchangeAlgorithm -# cipher_suites: ptr ptr PtlsCipherSuite -# certificates: -# -# -# proc -# -# -#proc main() = -# ptlsContext = +when isMainModule: + main()