diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 955f16a6b..b93c5f276 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -32,11 +32,12 @@ jobs: - name: Get dependencies if: steps.cache-gomodules.outputs.cache-hit != 'true' - run: | - go get -v -t -d ./... + run: go get -v -t -d ./... - name: Run coverage - run: ./testing/coverage/coverall2 + run: | + chmod u+x ./testing/coverage/coverall.sh + ./testing/coverage/coverall.sh - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9cfacd8ed..f83857c82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -107,6 +107,7 @@ jobs: - name: Build Windows wv2ray if: matrix.goos == 'windows' run: | + echo "::warning ::wv2ray.exe will be removed in v5" go build -v -o build_assets/wv2ray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main cd ./build_assets || exit 1 mv v2ray v2ray.exe diff --git a/release/mutilate/removeVSign.sh b/release/mutilate/removeVSign.sh deleted file mode 100755 index aec2cbe23..000000000 --- a/release/mutilate/removeVSign.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -export VROOT=$(dirname "${BASH_SOURCE[0]}")/../../ - -rm $VROOT/infra/control/verify.go - -sed -i '/VSign/d' $VROOT/go.mod diff --git a/testing/coverage/coverall b/testing/coverage/coverall deleted file mode 100755 index f9ac6db1f..000000000 --- a/testing/coverage/coverall +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -FAIL=0 - -V2RAY_OUT=${PWD}/out/v2ray -export V2RAY_COV=${V2RAY_OUT}/cov -COVERAGE_FILE=${V2RAY_COV}/coverage.txt - -function test_package { - DIR=".$1" - DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',') - DEP=${DEP}$DIR - RND_NAME=$(openssl rand -hex 16) - COV_PROFILE=${V2RAY_COV}/${RND_NAME}.out - go test -tags "json coverage" -coverprofile=${COV_PROFILE} -coverpkg=$DEP $DIR || FAIL=1 -} - -rm -rf ${V2RAY_OUT} -mkdir -p ${V2RAY_COV} -touch ${COVERAGE_FILE} - -TEST_FILES=(./*_test.go) -if [ -f ${TEST_FILES[0]} ]; then - test_package "" -fi - -for DIR in $(find * -type d ! -path "*.git*" ! -path "*vendor*" ! -path "*external*"); do - TEST_FILES=($DIR/*_test.go) - if [ -f ${TEST_FILES[0]} ]; then - test_package "/$DIR" - fi -done - -for OUT_FILE in $(find ${V2RAY_COV} -name "*.out"); do - echo "Merging file ${OUT_FILE}" - cat ${OUT_FILE} | grep -v "mode: set" >> ${COVERAGE_FILE} -done - -COV_SORTED=${V2RAY_COV}/coverallsorted.out -cat ${COVERAGE_FILE} | sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" | grep -vw "vendor" | grep -vw "external" > ${COV_SORTED} -echo "mode: set" | cat - ${COV_SORTED} > ${COVERAGE_FILE} - -if [ "$FAIL" -eq 0 ]; then - echo "Uploading coverage datea to codecov." - #bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} -v || echo "Codecov did not collect coverage reports." -fi - -exit $FAIL diff --git a/testing/coverage/coverall2 b/testing/coverage/coverall.sh similarity index 81% rename from testing/coverage/coverall2 rename to testing/coverage/coverall.sh index 8491ea5b5..d260e0cb5 100755 --- a/testing/coverage/coverall2 +++ b/testing/coverage/coverall.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash COVERAGE_FILE=${PWD}/coverage.txt COV_SORTED=${PWD}/coverallsorted.out @@ -19,8 +19,7 @@ if [ -f "${TEST_FILES[0]}" ]; then test_package "" fi -# shellcheck disable=SC2044 -for DIR in $(find ./* -type d ! -path "*.git*" ! -path "*vendor*" ! -path "*external*"); do +for DIR in $(find ./* -type d ! -path "*.git*"); do TEST_FILES=("$DIR"/*_test.go) if [ -f "${TEST_FILES[0]}" ]; then test_package "/$DIR" @@ -34,7 +33,7 @@ do < "${OUT_FILE}" grep -v "mode: set" >> "$COVERAGE_FILE" done < <(find ./* -name "*.out" -print0) -< "$COVERAGE_FILE" sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" | grep -vw "vendor" | grep -vw "external" > "$COV_SORTED" +< "$COVERAGE_FILE" sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" > "$COV_SORTED" echo "mode: set" | cat - "${COV_SORTED}" > "${COVERAGE_FILE}" -bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload' \ No newline at end of file +bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload' diff --git a/testing/servers/tcp/port.go b/testing/servers/tcp/port.go index cf4729d2c..86e73e7ac 100644 --- a/testing/servers/tcp/port.go +++ b/testing/servers/tcp/port.go @@ -1,16 +1,20 @@ package tcp -import ( - "v2ray.com/core/common" - "v2ray.com/core/common/net" -) +import "v2ray.com/core/common/net" -// PickPort returns an unused TCP port in the system. The port returned is highly likely to be unused, but not guaranteed. +// PickPort returns an unused TCP port of the system. func PickPort() net.Port { - listener, err := net.Listen("tcp4", "127.0.0.1:0") - common.Must(err) + listener := pickPort() defer listener.Close() addr := listener.Addr().(*net.TCPAddr) return net.Port(addr.Port) } + +func pickPort() net.Listener { + listener, err := net.Listen("tcp4", "127.0.0.1:0") + if err != nil { + listener = pickPort() + } + return listener +} diff --git a/testing/servers/udp/port.go b/testing/servers/udp/port.go index 75da5df44..f71b0c96b 100644 --- a/testing/servers/udp/port.go +++ b/testing/servers/udp/port.go @@ -1,19 +1,23 @@ package udp -import ( - "v2ray.com/core/common" - "v2ray.com/core/common/net" -) +import "v2ray.com/core/common/net" -// PickPort returns an unused UDP port in the system. The port returned is highly likely to be unused, but not guaranteed. +// PickPort returns an unused UDP port of the system. func PickPort() net.Port { - conn, err := net.ListenUDP("udp4", &net.UDPAddr{ - IP: net.LocalHostIP.IP(), - Port: 0, - }) - common.Must(err) + conn := pickPort() defer conn.Close() addr := conn.LocalAddr().(*net.UDPAddr) return net.Port(addr.Port) } + +func pickPort() *net.UDPConn { + conn, err := net.ListenUDP("udp4", &net.UDPAddr{ + IP: net.LocalHostIP.IP(), + Port: 0, + }) + if err != nil { + conn = pickPort() + } + return conn +} diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index 9c1c8f310..18471f8a6 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -9,9 +9,9 @@ import ( const ( // For incoming connections. - TCP_FASTOPEN = 23 + TCP_FASTOPEN = 23 // nolint: golint,stylecheck // For out-going connections. - TCP_FASTOPEN_CONNECT = 30 + TCP_FASTOPEN_CONNECT = 30 // nolint: golint,stylecheck ) func bindAddr(fd uintptr, ip []byte, port uint32) error { diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index cb6292bca..f84900892 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -1,11 +1,9 @@ package internet -import ( - "syscall" -) +import "syscall" const ( - TCP_FASTOPEN = 15 + TCP_FASTOPEN = 15 // nolint: golint,stylecheck ) func setTFO(fd syscall.Handle, settings SocketConfig_TCPFastOpenState) error {