mirror of
https://github.com/vacp2p/nim-ngtcp2.git
synced 2026-01-09 21:18:07 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9dbc3ad58 | ||
|
|
0a746cef2e | ||
|
|
0ce4b13b1b | ||
|
|
e7983b6a6e | ||
|
|
6834f4756b |
133
.github/actions/install_nim/action.yml
vendored
Normal file
133
.github/actions/install_nim/action.yml
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
name: Install Nim
|
||||
inputs:
|
||||
os:
|
||||
description: "Operating system to build for"
|
||||
required: true
|
||||
cpu:
|
||||
description: "CPU to build for"
|
||||
default: "amd64"
|
||||
nim_ref:
|
||||
description: "Nim version"
|
||||
default: "version-1-6"
|
||||
shell:
|
||||
description: "Shell to run commands in"
|
||||
default: "bash --noprofile --norc -e -o pipefail"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install build dependencies (Linux i386)
|
||||
shell: ${{ inputs.shell }}
|
||||
if: inputs.os == 'Linux' && inputs.cpu == 'i386'
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update -qq
|
||||
sudo DEBIAN_FRONTEND='noninteractive' apt-get install \
|
||||
--no-install-recommends -yq gcc-multilib g++-multilib \
|
||||
libssl-dev:i386
|
||||
mkdir -p external/bin
|
||||
cat << EOF > external/bin/gcc
|
||||
#!/bin/bash
|
||||
exec $(which gcc) -m32 "\$@"
|
||||
EOF
|
||||
cat << EOF > external/bin/g++
|
||||
#!/bin/bash
|
||||
exec $(which g++) -m32 "\$@"
|
||||
EOF
|
||||
chmod 755 external/bin/gcc external/bin/g++
|
||||
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
|
||||
|
||||
- name: MSYS2 (Windows i386)
|
||||
if: inputs.os == 'Windows' && inputs.cpu == 'i386'
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
path-type: inherit
|
||||
msystem: MINGW32
|
||||
install: >-
|
||||
base-devel
|
||||
git
|
||||
mingw-w64-i686-toolchain
|
||||
|
||||
- name: MSYS2 (Windows amd64)
|
||||
if: inputs.os == 'Windows' && inputs.cpu == 'amd64'
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
path-type: inherit
|
||||
install: >-
|
||||
base-devel
|
||||
git
|
||||
mingw-w64-x86_64-toolchain
|
||||
|
||||
- name: Restore Nim DLLs dependencies (Windows) from cache
|
||||
if: inputs.os == 'Windows'
|
||||
id: windows-dlls-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: external/dlls
|
||||
key: 'dlls'
|
||||
|
||||
- name: Install DLL dependencies (Windows)
|
||||
shell: ${{ inputs.shell }}
|
||||
if: >
|
||||
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
|
||||
inputs.os == 'Windows'
|
||||
run: |
|
||||
mkdir external
|
||||
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
|
||||
7z x external/windeps.zip -oexternal/dlls
|
||||
|
||||
- name: Path to cached dependencies (Windows)
|
||||
shell: ${{ inputs.shell }}
|
||||
if: >
|
||||
inputs.os == 'Windows'
|
||||
run: |
|
||||
echo '${{ github.workspace }}'"/external/dlls" >> $GITHUB_PATH
|
||||
|
||||
- name: Derive environment variables
|
||||
shell: ${{ inputs.shell }}
|
||||
run: |
|
||||
if [[ '${{ inputs.cpu }}' == 'amd64' ]]; then
|
||||
PLATFORM=x64
|
||||
elif [[ '${{ inputs.cpu }}' == 'arm64' ]]; then
|
||||
PLATFORM=arm64
|
||||
else
|
||||
PLATFORM=x86
|
||||
fi
|
||||
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
|
||||
|
||||
ncpu=
|
||||
MAKE_CMD="make"
|
||||
case '${{ inputs.os }}' in
|
||||
'Linux')
|
||||
ncpu=$(nproc)
|
||||
;;
|
||||
'macOS')
|
||||
ncpu=$(sysctl -n hw.ncpu)
|
||||
;;
|
||||
'Windows')
|
||||
ncpu=$NUMBER_OF_PROCESSORS
|
||||
MAKE_CMD="mingw32-make"
|
||||
;;
|
||||
esac
|
||||
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
|
||||
echo "ncpu=$ncpu" >> $GITHUB_ENV
|
||||
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
|
||||
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
|
||||
|
||||
- name: Restore Nim from cache
|
||||
id: nim-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: '${{ github.workspace }}/nim'
|
||||
key: ${{ inputs.os }}-${{ inputs.cpu }}-nim-${{ inputs.nim_ref }}-cache-${{ env.cache_nonce }}
|
||||
|
||||
- name: Build Nim and Nimble
|
||||
shell: ${{ inputs.shell }}
|
||||
if: ${{ steps.nim-cache.outputs.cache-hit != 'true' }}
|
||||
run: |
|
||||
# We don't want partial matches of the cache restored
|
||||
rm -rf nim
|
||||
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
|
||||
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} NIM_COMMIT=${{ inputs.nim_ref }} \
|
||||
QUICK_AND_DIRTY_COMPILER=1 QUICK_AND_DIRTY_NIMBLE=1 CC=gcc \
|
||||
bash build_nim.sh nim csources dist/nimble NimBinaries
|
||||
123
.github/workflows/test.yml
vendored
123
.github/workflows/test.yml
vendored
@@ -1,21 +1,116 @@
|
||||
name: CI
|
||||
name: Continuous Integration
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
merge_group:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 90
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
platform:
|
||||
- os: linux
|
||||
cpu: amd64
|
||||
- os: linux
|
||||
cpu: i386
|
||||
- os: linux-gcc-14
|
||||
cpu: amd64
|
||||
- os: macos
|
||||
cpu: amd64
|
||||
- os: macos-14
|
||||
cpu: arm64
|
||||
- os: windows
|
||||
cpu: amd64
|
||||
nim:
|
||||
- ref: version-1-6
|
||||
memory_management: refc
|
||||
- ref: version-2-0
|
||||
memory_management: refc
|
||||
include:
|
||||
- platform:
|
||||
os: linux
|
||||
builder: ubuntu-22.04
|
||||
shell: bash
|
||||
- platform:
|
||||
os: linux-gcc-14
|
||||
builder: ubuntu-24.04
|
||||
shell: bash
|
||||
- platform:
|
||||
os: macos
|
||||
builder: macos-13
|
||||
shell: bash
|
||||
- platform:
|
||||
os: macos-14
|
||||
builder: macos-14
|
||||
shell: bash
|
||||
- platform:
|
||||
os: windows
|
||||
builder: windows-2022
|
||||
shell: msys2 {0}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ matrix.shell }}
|
||||
|
||||
name: '${{ matrix.platform.os }}-${{ matrix.platform.cpu }} (Nim ${{ matrix.nim.ref }})'
|
||||
runs-on: ${{ matrix.builder }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: iffy/install-nim@v5
|
||||
with:
|
||||
version: 1.6.20
|
||||
- name: Build
|
||||
run: nimble install -y
|
||||
- name: Test
|
||||
run: nimble test -y
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup Nim
|
||||
uses: "./.github/actions/install_nim"
|
||||
with:
|
||||
os: ${{ matrix.platform.os }}
|
||||
cpu: ${{ matrix.platform.cpu }}
|
||||
shell: ${{ matrix.shell }}
|
||||
nim_ref: ${{ matrix.nim.ref }}
|
||||
|
||||
- name: Restore deps from cache
|
||||
id: deps-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: nimbledeps
|
||||
# Using nim.ref as a simple way to differentiate between nimble using the "pkgs" or "pkgs2" directories.
|
||||
# The change happened on Nimble v0.14.0. Also forcing the deps to be reinstalled on each os and cpu.
|
||||
key: nimbledeps-${{ matrix.nim.ref }}-${{ matrix.builder }}-${{ matrix.platform.cpu }}-${{ hashFiles('.pinned') }} # hashFiles returns a different value on windows
|
||||
|
||||
- name: Install deps
|
||||
if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }}
|
||||
run: |
|
||||
nimble install
|
||||
|
||||
- name: Use gcc 14
|
||||
if : ${{ matrix.platform.os == 'linux-gcc-14'}}
|
||||
run: |
|
||||
# Add GCC-14 to alternatives
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 14
|
||||
|
||||
# Set GCC-14 as the default
|
||||
sudo update-alternatives --set gcc /usr/bin/gcc-14
|
||||
|
||||
- name: Install deps (windows)
|
||||
if : ${{ matrix.platform.os == 'windows'}}
|
||||
run: |
|
||||
pacman -S --noconfirm base-devel gcc
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
nim --version
|
||||
nimble --version
|
||||
gcc --version
|
||||
|
||||
NIMFLAGS="${NIMFLAGS} --mm:${{ matrix.nim.memory_management }}"
|
||||
nimble test --styleCheck:off --verbose --debug
|
||||
|
||||
15
.gitignore
vendored
15
.gitignore
vendored
@@ -1,13 +1,2 @@
|
||||
*
|
||||
!*/
|
||||
!*.*
|
||||
|
||||
# ignore all cmake build files, except version.h
|
||||
build/*
|
||||
!build/lib/
|
||||
build/lib/*
|
||||
!build/lib/includes/
|
||||
build/lib/includes/*
|
||||
!build/lib/includes/ngtcp2/
|
||||
build/lib/includes/ngtcp2/*
|
||||
!build/lib/includes/ngtcp2/version.h
|
||||
!libs/
|
||||
!libs/*
|
||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
||||
[submodule "sources"]
|
||||
path = sources
|
||||
url = https://github.com/ngtcp2/ngtcp2.git
|
||||
[submodule "libs/ngtcp2"]
|
||||
path = libs/ngtcp2
|
||||
url = https://github.com/ngtcp2/ngtcp2
|
||||
[submodule "libs/picotls"]
|
||||
path = libs/picotls
|
||||
url = https://github.com/h2o/picotls
|
||||
|
||||
201
LICENSE-APACHEv2
Normal file
201
LICENSE-APACHEv2
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018 Status Research & Development GmbH
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
25
LICENSE-MIT
Normal file
25
LICENSE-MIT
Normal file
@@ -0,0 +1,25 @@
|
||||
nim-ngtcp2 is licensed under the MIT License
|
||||
Copyright (c) 2025 Status Research & Development GmbH
|
||||
-----------------------------------------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Status Research & Development GmbH
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,6 +1,13 @@
|
||||
ngtcp2 for Nim
|
||||
==============
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||

|
||||
<img src="https://img.shields.io/badge/nim-%3E%3D1.2.0-orange.svg?style=flat-square" />
|
||||
|
||||
|
||||
|
||||
Wrapper around the [ngtcp2](https://github.com/ngtcp2/ngtcp2) C library for
|
||||
[Nim](https://nim-lang.org/).
|
||||
|
||||
58
build.sh
58
build.sh
@@ -1,35 +1,39 @@
|
||||
#!/bin/bash
|
||||
root=$(dirname "$0")
|
||||
sources=${root}/libs
|
||||
|
||||
# install nimterop, if not already installed
|
||||
if ! [ -x "$(command -v toast)" ]; then
|
||||
nimble install -y nimterop@2532ce0
|
||||
fi
|
||||
|
||||
# run cmake on ngtcp2 sources
|
||||
cmake -S "${root}/sources" -B "${root}/build"
|
||||
|
||||
# add prelude
|
||||
cat "${root}/prelude.nim" > "${root}/ngtcp2.nim"
|
||||
|
||||
# dividing line
|
||||
echo >> "${root}/ngtcp2.nim"
|
||||
rm -f ngtcp2.nim
|
||||
|
||||
# assemble list of C files to be compiled
|
||||
for file in `ls "${root}/sources/lib"/*.c`; do
|
||||
compile="${compile} --compile=${file}"
|
||||
toCompile=(
|
||||
"${sources}/picotls/picotlsvs/picotls/wintimeofday.c"
|
||||
"${sources}/picotls/lib/pembase64.c"
|
||||
"${sources}/picotls/lib/hpke.c"
|
||||
"${sources}/picotls/lib/picotls.c"
|
||||
"${sources}/picotls/lib/openssl.c"
|
||||
)
|
||||
|
||||
for file in `ls "${sources}/ngtcp2/crypto"/*.c`; do
|
||||
toCompile+=("$file")
|
||||
done
|
||||
for file in `ls "${sources}/ngtcp2/crypto/picotls"/*.c`; do
|
||||
toCompile+=("$file")
|
||||
done
|
||||
for file in `ls "${sources}/ngtcp2/lib"/*.c`; do
|
||||
toCompile+=("$file")
|
||||
done
|
||||
for file in `ls "${root}/build/lib"/*.c`; do
|
||||
toCompile+=("$file")
|
||||
done
|
||||
|
||||
# generate nim wrapper with nimterop
|
||||
toast \
|
||||
$compile \
|
||||
--pnim \
|
||||
--preprocess \
|
||||
--noHeader \
|
||||
--defines=NGTCP2_STATICLIB \
|
||||
--replace=sockaddr=SockAddr,SockAddr_storage=Sockaddr_storage,socklen_t=SockLen \
|
||||
--includeDirs="${root}/sources/lib/includes" \
|
||||
--includeDirs="${root}/build/lib/includes" \
|
||||
"${root}/sources/lib/includes/ngtcp2/ngtcp2.h" >> "${root}/ngtcp2.nim"
|
||||
nim c --maxLoopIterationsVM:100000000 generate_ngtcp2.nim
|
||||
|
||||
sed -i 's/\bpassC\b/passc/g' ngtcp2.nim
|
||||
# add prelude
|
||||
cat "${root}/prelude.nim" > ngtcp2.nim
|
||||
|
||||
for file in "${toCompile[@]}"; do
|
||||
echo "{.compile: \"$file\".}" >> ngtcp2.nim
|
||||
done
|
||||
|
||||
cat tmp_ngtcp2.nim >> ngtcp2.nim
|
||||
rm -f tmp_ngtcp2.nim
|
||||
|
||||
140
build/lib/cred_buffer.c
Normal file
140
build/lib/cred_buffer.c
Normal file
@@ -0,0 +1,140 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "utils/cred_buffer.h"
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
static int cred_buffer_getc(ptls_cred_buffer_t *buf)
|
||||
{
|
||||
return PTLS_CRED_BUFFER_LEFT(buf) > 0 ? buf->base[buf->off++] : -1;
|
||||
}
|
||||
|
||||
static ssize_t fsize(FILE *fp)
|
||||
{
|
||||
long sz;
|
||||
|
||||
if (fseek(fp, 0, SEEK_END) == -1 || (sz = ftell(fp)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rewind(fp);
|
||||
|
||||
return (ssize_t) sz;
|
||||
}
|
||||
|
||||
/* The caller owns 'mem' and must have called ptls_buffer_init prior to
|
||||
* invoking this function */
|
||||
int ptls_cred_buffer_set_from_file(ptls_cred_buffer_t *buf, const char *fname)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
ssize_t sz;
|
||||
char *m = NULL;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
errno_t err = fopen_s(&fp, fname, "r");
|
||||
if (err != 0) {
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
fp = fopen(fname, "r");
|
||||
if (fp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((sz = fsize(fp)) == -1 ||
|
||||
(m = malloc(sz)) == NULL ||
|
||||
fread(m, sz, 1, fp) != 1) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
(void) fclose(fp);
|
||||
|
||||
buf->base = m;
|
||||
buf->len = sz;
|
||||
buf->off = 0;
|
||||
buf->owns_base = 1;
|
||||
|
||||
return 0;
|
||||
err:
|
||||
if (m)
|
||||
free(m);
|
||||
if (fp != NULL)
|
||||
(void) fclose(fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ptls_cred_buffer_set_from_string(ptls_cred_buffer_t *buf, char *s)
|
||||
{
|
||||
buf->base = s;
|
||||
buf->len = strlen(s);
|
||||
buf->off = 0;
|
||||
buf->owns_base = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ptls_cred_buffer_dispose(ptls_cred_buffer_t *buf)
|
||||
{
|
||||
if (buf->owns_base) {
|
||||
if (buf->base) {
|
||||
free(buf->base);
|
||||
buf->base = NULL;
|
||||
}
|
||||
buf->len = buf->off = 0;
|
||||
buf->owns_base = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void ptls_cred_buffer_rewind(ptls_cred_buffer_t *buf)
|
||||
{
|
||||
buf->off = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* z -> nlptr */
|
||||
char *ptls_cred_buffer_gets(char *s, int n, ptls_cred_buffer_t *buf)
|
||||
{
|
||||
char *p = s;
|
||||
char *z;
|
||||
size_t k;
|
||||
int c;
|
||||
|
||||
if (n-- <= 1) {
|
||||
if (n) return NULL;
|
||||
*s = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
while (n) {
|
||||
if (PTLS_CRED_BUFFER_RPOS(buf) != PTLS_CRED_BUFFER_REND(buf)) {
|
||||
z = memchr(PTLS_CRED_BUFFER_RPOS(buf), '\n', PTLS_CRED_BUFFER_LEFT(buf));
|
||||
k = z ? z - PTLS_CRED_BUFFER_RPOS(buf) + 1 : PTLS_CRED_BUFFER_LEFT(buf);
|
||||
k = MIN(k, n);
|
||||
memcpy(p, PTLS_CRED_BUFFER_RPOS(buf), k);
|
||||
buf->off += k;
|
||||
p += k;
|
||||
n -= k;
|
||||
if (z || !n) break;
|
||||
}
|
||||
|
||||
if ((c = cred_buffer_getc(buf)) < 0) {
|
||||
if (p == s || PTLS_CRED_BUFFER_LEFT(buf) > 0) s = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
n--;
|
||||
|
||||
if ((*p++ = c) == '\n') break;
|
||||
}
|
||||
|
||||
if (s) *p = '\0';
|
||||
|
||||
return s;
|
||||
}
|
||||
24
build/lib/includes/utils/cred_buffer.h
Normal file
24
build/lib/includes/utils/cred_buffer.h
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef PTLS_CRED_BUFFER_H
|
||||
#define PTLS_CRED_BUFFER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "picotls.h"
|
||||
|
||||
typedef struct ptls_cred_buffer_s {
|
||||
char *base;
|
||||
size_t len;
|
||||
size_t off;
|
||||
int owns_base;
|
||||
#define PTLS_CRED_BUFFER_RPOS(buf) ((buf)->base + (buf)->off)
|
||||
#define PTLS_CRED_BUFFER_REND(buf) ((buf)->base + (buf)->len)
|
||||
#define PTLS_CRED_BUFFER_LEFT(buf) ((buf)->len - (buf)->off)
|
||||
} ptls_cred_buffer_t;
|
||||
|
||||
int ptls_cred_buffer_set_from_file(ptls_cred_buffer_t *buf, const char *fname);
|
||||
int ptls_cred_buffer_set_from_string(ptls_cred_buffer_t *buf, char *s);
|
||||
void ptls_cred_buffer_dispose(ptls_cred_buffer_t *buf);
|
||||
void ptls_cred_buffer_rewind(ptls_cred_buffer_t *buf);
|
||||
char *ptls_cred_buffer_gets(char *s, int n, ptls_cred_buffer_t *buf);
|
||||
|
||||
#endif /* !PTLS_CRED_BUFFER_H */
|
||||
28
build/lib/includes/utils/pem_utils.h
Normal file
28
build/lib/includes/utils/pem_utils.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Christian Huitema <huitema@huitema.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PTLS_PEM_UTILS
|
||||
#define PTLS_PEM_UTILS
|
||||
|
||||
#include <picotls.h>
|
||||
#include <picotls/openssl.h>
|
||||
#include "cred_buffer.h"
|
||||
|
||||
int ptls_load_certificates_from_memory(ptls_context_t *ctx, ptls_cred_buffer_t *mem);
|
||||
|
||||
int ptls_openssl_init_sign_certificate_with_mem_key(ptls_openssl_sign_certificate_t *self, const void *buf, int len);
|
||||
|
||||
#endif /* PTLS_PEM_UTILS */
|
||||
37
build/lib/includes/wincompat.h
Normal file
37
build/lib/includes/wincompat.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef WINCOMPAT_H
|
||||
#define WINCOMPAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#define ssize_t int
|
||||
#include <Winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#ifndef gettimeofday
|
||||
#define gettimeofday wintimeofday
|
||||
|
||||
#ifndef __attribute__
|
||||
#define __attribute__(X)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
struct tzone {
|
||||
int tz_minuteswest; /* minutes west of Greenwich */
|
||||
int tz_dsttime; /* type of DST correction */
|
||||
};
|
||||
|
||||
int wintimeofday(struct timeval *tv, struct tzone *tz);
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINCOMPAT_H */
|
||||
152
build/lib/pem_utils.c
Normal file
152
build/lib/pem_utils.c
Normal file
@@ -0,0 +1,152 @@
|
||||
#include <stdlib.h>
|
||||
#include <picotls.h>
|
||||
#include <picotls/pembase64.h>
|
||||
#include "utils/pem_utils.h"
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
static int ptls_compare_separator_line(const char *line, const char *begin_or_end, const char *label)
|
||||
{
|
||||
int ret = strncmp(line, "-----", 5);
|
||||
size_t text_index = 5;
|
||||
|
||||
if (ret == 0) {
|
||||
size_t begin_or_end_length = strlen(begin_or_end);
|
||||
ret = strncmp(line + text_index, begin_or_end, begin_or_end_length);
|
||||
text_index += begin_or_end_length;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ret = line[text_index] - ' ';
|
||||
text_index++;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
size_t label_length = strlen(label);
|
||||
ret = strncmp(line + text_index, label, label_length);
|
||||
text_index += label_length;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ret = strncmp(line + text_index, "-----", 5);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Extracted from https://github.com/h2o/picotls/pull/284/
|
||||
// Remove both pem.c/h and cred_buffer.c/h once that PR gets merged
|
||||
static int ptls_get_pem_object_from_memory(ptls_cred_buffer_t *mem, const char *label, ptls_buffer_t *buf)
|
||||
{
|
||||
int ret = PTLS_ERROR_PEM_LABEL_NOT_FOUND;
|
||||
char line[256];
|
||||
ptls_base64_decode_state_t state;
|
||||
|
||||
/* Get the label on a line by itself */
|
||||
while (ptls_cred_buffer_gets(line, 256, mem)) {
|
||||
if (ptls_compare_separator_line(line, "BEGIN", label) == 0) {
|
||||
ret = 0;
|
||||
ptls_base64_decode_init(&state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Get the data in the buffer */
|
||||
while (ret == 0 && ptls_cred_buffer_gets(line, 256, mem)) {
|
||||
if (ptls_compare_separator_line(line, "END", label) == 0) {
|
||||
if (state.status == PTLS_BASE64_DECODE_DONE || (state.status == PTLS_BASE64_DECODE_IN_PROGRESS && state.nbc == 0)) {
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = PTLS_ERROR_INCORRECT_BASE64;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
ret = ptls_base64_decode(line, &state, buf);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ptls_load_pem_objects_from_memory(ptls_cred_buffer_t *mem, const char *label, ptls_iovec_t *list, size_t list_max, size_t *nb_objects)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t count = 0;
|
||||
|
||||
*nb_objects = 0;
|
||||
|
||||
if (ret == 0) {
|
||||
while (count < list_max) {
|
||||
ptls_buffer_t buf;
|
||||
|
||||
ptls_buffer_init(&buf, "", 0);
|
||||
|
||||
ret = ptls_get_pem_object_from_memory(mem, label, &buf);
|
||||
|
||||
if (ret == 0) {
|
||||
if (buf.off > 0 && buf.is_allocated) {
|
||||
list[count].base = buf.base;
|
||||
list[count].len = buf.off;
|
||||
count++;
|
||||
} else {
|
||||
ptls_buffer_dispose(&buf);
|
||||
}
|
||||
} else {
|
||||
ptls_buffer_dispose(&buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == PTLS_ERROR_PEM_LABEL_NOT_FOUND && count > 0) {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
*nb_objects = count;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define PTLS_MAX_CERTS_IN_CONTEXT 16
|
||||
|
||||
int ptls_load_certificates_from_memory(ptls_context_t *ctx, ptls_cred_buffer_t *mem)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ctx->certificates.list = (ptls_iovec_t *)malloc(PTLS_MAX_CERTS_IN_CONTEXT * sizeof(ptls_iovec_t));
|
||||
|
||||
if (ctx->certificates.list == NULL) {
|
||||
ret = PTLS_ERROR_NO_MEMORY;
|
||||
} else {
|
||||
ret = ptls_load_pem_objects_from_memory(mem, "CERTIFICATE", ctx->certificates.list, PTLS_MAX_CERTS_IN_CONTEXT,
|
||||
&ctx->certificates.count);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ptls_openssl_init_sign_certificate_with_mem_key(ptls_openssl_sign_certificate_t *self, const void *buf, int len) {
|
||||
BIO *bio = BIO_new_mem_buf(buf, len);
|
||||
if (bio == NULL) {
|
||||
return 8880;
|
||||
}
|
||||
|
||||
EVP_PKEY *evp_key = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
|
||||
BIO_free(bio);
|
||||
if (evp_key == NULL) {
|
||||
return 8881;
|
||||
}
|
||||
|
||||
// Initialize the certificate signing structure
|
||||
int ret = ptls_openssl_init_sign_certificate(self, evp_key);
|
||||
|
||||
EVP_PKEY_free(evp_key);
|
||||
|
||||
return ret;
|
||||
}
|
||||
16
generate_ngtcp2.nim
Normal file
16
generate_ngtcp2.nim
Normal file
@@ -0,0 +1,16 @@
|
||||
import futhark, strformat
|
||||
from os import parentDir, `/`
|
||||
|
||||
importc:
|
||||
outputPath currentSourcePath.parentDir / "tmp_ngtcp2.nim"
|
||||
path currentSourcePath.parentDir/"libs/ngtcp2/lib/includes"
|
||||
path currentSourcePath.parentDir/"build/lib/includes"
|
||||
path currentSourcePath.parentDir/"libs/ngtcp2/crypto/includes/"
|
||||
path currentSourcePath.parentDir/"libs"/"picotls"/"include"
|
||||
"ngtcp2/ngtcp2.h"
|
||||
"ngtcp2/ngtcp2_crypto.h"
|
||||
"picotls.h"
|
||||
"picotls/openssl.h"
|
||||
"ngtcp2/ngtcp2_crypto_picotls.h"
|
||||
"utils/cred_buffer.h"
|
||||
"utils/pem_utils.h"
|
||||
1
libs/ngtcp2
Submodule
1
libs/ngtcp2
Submodule
Submodule libs/ngtcp2 added at 048cdfd0c2
1
libs/picotls
Submodule
1
libs/picotls
Submodule
Submodule libs/picotls added at bbcdbe6dc3
14191
ngtcp2.nim
14191
ngtcp2.nim
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
packageName = "ngtcp2"
|
||||
version = "0.34.0"
|
||||
version = "0.35.0"
|
||||
author = "Status Research & Development GmbH"
|
||||
description = "Nim wrapper around the ngtcp2 library"
|
||||
license = "MIT"
|
||||
installDirs = @["sources", "build"]
|
||||
installDirs = @["libs", "build"]
|
||||
installFiles = @["ngtcp2.nim"]
|
||||
|
||||
requires "nim >= 1.6.0"
|
||||
|
||||
26
prelude.nim
26
prelude.nim
@@ -6,12 +6,28 @@ import nativesockets
|
||||
|
||||
when defined(windows):
|
||||
{.passl: "-lws2_32".}
|
||||
{.passc: "-D_WINDOWS".}
|
||||
else:
|
||||
{.passC: "-DHAVE_UNISTD_H".}
|
||||
{.passc: "-DHAVE_UNISTD_H".}
|
||||
|
||||
when defined(macosx):
|
||||
{.passl: "-L/opt/homebrew/opt/openssl@3/lib -lcrypto".}
|
||||
{.passc: "-I/opt/homebrew/opt/openssl@3/include".}
|
||||
else:
|
||||
{.passl: "-lcrypto".}
|
||||
|
||||
# C include directories
|
||||
const root = currentSourcePath.parentDir
|
||||
const sourceInclude = root/"sources"/"lib"/"includes"
|
||||
const buildInclude = root/"build"/"lib"/"includes"
|
||||
const libIncludes = root/"build"/"lib"/"includes"
|
||||
const ngtcp2Crypto = root/"libs"/"ngtcp2"/"crypto"
|
||||
const ngtcp2CryptoIncludes = root/"libs"/"ngtcp2"/"crypto"/"includes"
|
||||
const ngtcp2Lib = root/"libs"/"ngtcp2"/"lib"
|
||||
const ngtcp2LibIncludes = root/"libs"/"ngtcp2"/"lib"/"includes"
|
||||
const picotlsInclude = root/"libs"/"picotls"/"include"
|
||||
|
||||
{.passc: fmt"-I{libIncludes}".}
|
||||
{.passc: fmt"-I{ngtcp2Crypto}".}
|
||||
{.passc: fmt"-I{ngtcp2CryptoIncludes}".}
|
||||
{.passc: fmt"-I{ngtcp2Lib}".}
|
||||
{.passc: fmt"-I{ngtcp2LibIncludes}".}
|
||||
{.passc: fmt"-I{picotlsInclude}".}
|
||||
|
||||
{.passc: fmt"-I{sourceInclude} -I{buildInclude}".}
|
||||
|
||||
1
sources
1
sources
Submodule sources deleted from 5f8bd54ad7
@@ -9,3 +9,13 @@ test "default settings":
|
||||
var transport_params: ngtcp2_transport_params
|
||||
ngtcp2_transport_params_default_versioned(NGTCP2_TRANSPORT_PARAMS_V1, addr transport_params)
|
||||
check transport_params.active_connection_id_limit > 0
|
||||
|
||||
test "ptls_instantiation":
|
||||
var ctx: ptls_context_t
|
||||
ctx.random_bytes = ptls_openssl_random_bytes
|
||||
ctx.get_time = addr ptls_get_time
|
||||
ctx.key_exchanges = cast[ptr ptr ptls_key_exchange_algorithm_t](addr ptls_openssl_key_exchanges[0])
|
||||
ctx.cipher_suites = cast[ptr ptr ptls_cipher_suite_t](ptls_openssl_cipher_suites[0])
|
||||
|
||||
var tls: ptr ptls_t = ptls_client_new(addr ctx);
|
||||
check tls != nil
|
||||
|
||||
Reference in New Issue
Block a user