添加 github.com/pion/dtls 代码

This commit is contained in:
bjdgyc
2021-05-21 19:03:00 +08:00
parent 54a0cb7928
commit 28b5119f50
380 changed files with 16870 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
set -e
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
if [ -f ${SCRIPT_PATH}/.ci.conf ]
then
. ${SCRIPT_PATH}/.ci.conf
fi
#
# DO NOT EDIT THIS
#
EXCLUDED_CONTRIBUTORS+=('John R. Bradley' 'renovate[bot]' 'Renovate Bot' 'Pion Bot')
# If you want to exclude a name from all repositories, send a PR to
# https://github.com/pion/.goassets instead of this repository.
# If you want to exclude a name only from this repository,
# add EXCLUDED_CONTRIBUTORS=('name') to .github/.ci.conf
MISSING_CONTRIBUTORS=()
shouldBeIncluded () {
for i in "${EXCLUDED_CONTRIBUTORS[@]}"
do
if [ "$i" == "$1" ] ; then
return 1
fi
done
return 0
}
IFS=$'\n' #Only split on newline
for contributor in $(git log --format='%aN' | sort -u)
do
if shouldBeIncluded $contributor; then
if ! grep -q "$contributor" "$SCRIPT_PATH/../README.md"; then
MISSING_CONTRIBUTORS+=("$contributor")
fi
fi
done
unset IFS
if [ ${#MISSING_CONTRIBUTORS[@]} -ne 0 ]; then
echo "Please add the following contributors to the README"
for i in "${MISSING_CONTRIBUTORS[@]}"
do
echo "$i"
done
exit 1
fi

11
dtls-2.0.9/.github/hooks/commit-msg.sh vendored Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
#
# DO NOT EDIT THIS FILE DIRECTLY
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
set -e
.github/lint-commit-message.sh $1

12
dtls-2.0.9/.github/hooks/pre-commit.sh vendored Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
#
# DO NOT EDIT THIS FILE DIRECTLY
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# Redirect output to stderr.
exec 1>&2
.github/lint-disallowed-functions-in-library.sh

13
dtls-2.0.9/.github/hooks/pre-push.sh vendored Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
#
# DO NOT EDIT THIS FILE DIRECTLY
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
set -e
.github/assert-contributors.sh
exit 0

16
dtls-2.0.9/.github/install-hooks.sh vendored Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cp "$SCRIPT_PATH/hooks/commit-msg.sh" "$SCRIPT_PATH/../.git/hooks/commit-msg"
cp "$SCRIPT_PATH/hooks/pre-commit.sh" "$SCRIPT_PATH/../.git/hooks/pre-commit"
cp "$SCRIPT_PATH/hooks/pre-push.sh" "$SCRIPT_PATH/../.git/hooks/pre-push"

View File

@@ -0,0 +1,64 @@
#!/usr/bin/env bash
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
set -e
display_commit_message_error() {
cat << EndOfMessage
$1
-------------------------------------------------
The preceding commit message is invalid
it failed '$2' of the following checks
* Separate subject from body with a blank line
* Limit the subject line to 50 characters
* Capitalize the subject line
* Do not end the subject line with a period
* Wrap the body at 72 characters
EndOfMessage
exit 1
}
lint_commit_message() {
if [[ "$(echo "$1" | awk 'NR == 2 {print $1;}' | wc -c)" -ne 1 ]]; then
display_commit_message_error "$1" 'Separate subject from body with a blank line'
fi
if [[ "$(echo "$1" | head -n1 | awk '{print length}')" -gt 50 ]]; then
display_commit_message_error "$1" 'Limit the subject line to 50 characters'
fi
if [[ ! $1 =~ ^[A-Z] ]]; then
display_commit_message_error "$1" 'Capitalize the subject line'
fi
if [[ "$(echo "$1" | awk 'NR == 1 {print substr($0,length($0),1)}')" == "." ]]; then
display_commit_message_error "$1" 'Do not end the subject line with a period'
fi
if [[ "$(echo "$1" | awk '{print length}' | sort -nr | head -1)" -gt 72 ]]; then
display_commit_message_error "$1" 'Wrap the body at 72 characters'
fi
}
if [ "$#" -eq 1 ]; then
if [ ! -f "$1" ]; then
echo "$0 was passed one argument, but was not a valid file"
exit 1
fi
lint_commit_message "$(sed -n '/# Please enter the commit message for your changes. Lines starting/q;p' "$1")"
else
for commit in $(git rev-list --no-merges origin/master..); do
lint_commit_message "$(git log --format="%B" -n 1 $commit)"
done
fi

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
set -e
# Disallow usages of functions that cause the program to exit in the library code
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
if [ -f ${SCRIPT_PATH}/.ci.conf ]
then
. ${SCRIPT_PATH}/.ci.conf
fi
EXCLUDE_DIRECTORIES=${DISALLOWED_FUNCTIONS_EXCLUDED_DIRECTORIES:-"examples"}
DISALLOWED_FUNCTIONS=('os.Exit(' 'panic(' 'Fatal(' 'Fatalf(' 'Fatalln(' 'fmt.Println(' 'fmt.Printf(' 'log.Print(' 'log.Println(' 'log.Printf(')
files=$(
find "$SCRIPT_PATH/.." -name "*.go" \
| grep -v -e '^.*_test.go$' \
| while read file
do
excluded=false
for ex in $EXCLUDE_DIRECTORIES
do
if [[ $file == */$ex/* ]]
then
excluded=true
break
fi
done
$excluded || echo "$file"
done
)
for disallowedFunction in "${DISALLOWED_FUNCTIONS[@]}"
do
if grep -e "$disallowedFunction" $files | grep -v -e 'nolint'; then
echo "$disallowedFunction may only be used in example code"
exit 1
fi
done

24
dtls-2.0.9/.github/lint-filename.sh vendored Normal file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
set -e
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
GO_REGEX="^[a-zA-Z][a-zA-Z0-9_]*\.go$"
find "$SCRIPT_PATH/.." -name "*.go" | while read fullpath; do
filename=$(basename -- "$fullpath")
if ! [[ $filename =~ $GO_REGEX ]]; then
echo "$filename is not a valid filename for Go code, only alpha, numbers and underscores are supported"
exit 1
fi
done

20
dtls-2.0.9/.github/workflows/e2e.yaml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: E2E
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
e2e-test:
name: Test
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: test
run: |
docker build -t pion-dtls-e2e -f e2e/Dockerfile .
docker run -i --rm pion-dtls-e2e

43
dtls-2.0.9/.github/workflows/lint.yaml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Lint
on:
pull_request:
types:
- opened
- edited
- synchronize
jobs:
lint-commit-message:
name: Metadata
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Commit Message
run: .github/lint-commit-message.sh
- name: File names
run: .github/lint-filename.sh
- name: Contributors
run: .github/assert-contributors.sh
- name: Functions
run: .github/lint-disallowed-functions-in-library.sh
lint-go:
name: Go
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.31
args: $GOLANGCI_LINT_EXRA_ARGS

View File

@@ -0,0 +1,33 @@
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
# If this repository should have package specific CI config,
# remove the repository name from .goassets/.github/workflows/assets-sync.yml.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
name: go-mod-fix
on:
push:
branches:
- renovate/*
jobs:
go-mod-fix:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: fix
uses: at-wat/go-sum-fix-action@v0
with:
git_user: Pion Bot
git_email: 59523206+pionbot@users.noreply.github.com
github_token: ${{ secrets.PIONBOT_PRIVATE_KEY }}
commit_style: squash
push: force

139
dtls-2.0.9/.github/workflows/test.yaml vendored Normal file
View File

@@ -0,0 +1,139 @@
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.15", "1.16"]
fail-fast: false
name: Go ${{ matrix.go }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/go/bin
~/.cache
key: ${{ runner.os }}-amd64-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-amd64-go-
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Setup go-acc
run: |
go get github.com/ory/go-acc
git checkout go.mod go.sum
- name: Run test
run: |
go-acc -o cover.out ./... -- \
-bench=. \
-v -race
- uses: codecov/codecov-action@v1
with:
file: ./cover.out
name: codecov-umbrella
fail_ci_if_error: true
flags: go
test-i386:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.15", "1.16"]
fail-fast: false
name: Go i386 ${{ matrix.go }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache
key: ${{ runner.os }}-i386-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-i386-go-
- name: Run test
run: |
mkdir -p $HOME/go/pkg/mod $HOME/.cache
docker run \
-u $(id -u):$(id -g) \
-e "GO111MODULE=on" \
-e "CGO_ENABLED=0" \
-v $GITHUB_WORKSPACE:/go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \
-v $HOME/go/pkg/mod:/go/pkg/mod \
-v $HOME/.cache:/.cache \
-w /go/src/github.com/pion/$(basename $GITHUB_WORKSPACE) \
i386/golang:${{matrix.go}}-alpine \
/usr/local/go/bin/go test \
${TEST_EXTRA_ARGS:-} \
-v ./...
test-wasm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: WASM
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '12.x'
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache
key: ${{ runner.os }}-wasm-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-wasm-go-
- name: Download Go
run: curl -sSfL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C ~ -xzf -
env:
GO_VERSION: 1.16
- name: Set Go Root
run: echo "GOROOT=${HOME}/go" >> $GITHUB_ENV
- name: Set Go Path
run: echo "GOPATH=${HOME}/go" >> $GITHUB_ENV
- name: Set Go Path
run: echo "GO_JS_WASM_EXEC=${GOROOT}/misc/wasm/go_js_wasm_exec" >> $GITHUB_ENV
- name: Insall NPM modules
run: yarn install
- name: Run Tests
run: |
GOOS=js GOARCH=wasm $GOPATH/bin/go test \
-coverprofile=cover.out -covermode=atomic \
-exec="${GO_JS_WASM_EXEC}" \
-v ./...
- uses: codecov/codecov-action@v1
with:
file: ./cover.out
name: codecov-umbrella
fail_ci_if_error: true
flags: wasm

View File

@@ -0,0 +1,37 @@
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
# If this repository should have package specific CI config,
# remove the repository name from .goassets/.github/workflows/assets-sync.yml.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#
name: Go mod tidy
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
Check:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
- name: check
run: |
go mod download
go mod tidy
if ! git diff --exit-code
then
echo "Not go mod tidied"
exit 1
fi