Skip to content

Commit

Permalink
refactor: remove legacy package (#72)
Browse files Browse the repository at this point in the history
This commit deletes the legacy implementation that was still around
under vpn/.

Practically all the functionality has been moved to the public
pkg/tunnel package, which contains the public API now.

The test binary can now be found in the same path as before,
cmd/minivpn, although the cli flags have changed. Behavior-wise,
however, there are bits that I have not still ported (gvisor-based tun
device). They will be ported on a per-need basis, but at least we're
cleaning up the tree of the unused codebase for now.

I am also bumping go.mod and go.sum, minivpn now requires go 1.20.
  • Loading branch information
ainghazal authored Apr 15, 2024
1 parent 41e4e0b commit d8b6eb5
Show file tree
Hide file tree
Showing 54 changed files with 139 additions and 11,511 deletions.
66 changes: 0 additions & 66 deletions .github/workflows/build-refactor.yml

This file was deleted.

38 changes: 30 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
name: build
# this action is covering internal/ tree with go1.20

on:
push:
branches:
- main
- 'main'
pull_request:
branches:
- main
- 'main'

jobs:
short-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: Run short tests
run: go test --short -cover ./vpn
run: go test --short -cover ./internal/...

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint with revive action, from pre-built image
uses: docker://morphy/revive-action:v2
with:
path: "internal/..."

gosec:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run Gosec security scanner
uses: securego/gosec@master
with:
Expand All @@ -35,10 +45,22 @@ jobs:
coverage-threshold:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: Ensure coverage threshold
run: make test-coverage-threshold

integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: run integration tests
run: go run ./tests/integration

37 changes: 7 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ build-rel:
@GOOS=windows go build ${FLAGS} -o minivpn.exe

build-race:
@go build -race

build-ping:
@go build -v ./cmd/vpnping

build-ndt7:
@go build -o ndt7 ./cmd/ndt7
@go build -race ./cmd/minivpn

bootstrap:
@./scripts/bootstrap-provider ${PROVIDER}
Expand All @@ -45,18 +39,14 @@ test-combined-coverage:
scripts/go-coverage-check.sh ./coverage/profile.out ${COVERAGE_THRESHOLD}

test-coverage-threshold:
go test --short -coverprofile=cov-threshold.out ./vpn
./scripts/go-coverage-check.sh cov-threshold.out ${COVERAGE_THRESHOLD}

test-coverage-threshold-refactor:
go test --short -coverprofile=cov-threshold-refactor.out ./internal/...
./scripts/go-coverage-check.sh cov-threshold-refactor.out ${COVERAGE_THRESHOLD}

test-short:
go test -race -short -v ./...

test-ping:
./minivpn -c data/${PROVIDER}/config -t ${TARGET} -n ${COUNT} ping
./minivpn -c data/${PROVIDER}/config -ping

integration-server:
# this needs the container from https://github.com/ainghazal/docker-openvpn
Expand All @@ -66,20 +56,14 @@ test-fetch-config:
rm -rf data/tests
mkdir -p data/tests && curl 172.17.0.2:8080/ > data/tests/config

test-ping-local:
# run the integration-server first
./minivpn -c data/tests/config -t 172.17.0.1 -n ${COUNT} ping

test-local: test-fetch-config test-ping-local

qa:
@# all the steps at once
cd tests/integration && ./run-server.sh &
sleep 5 # 5secs should be enough, increase this if not.
@rm -rf data/tests
@mkdir -p data/tests && curl 172.17.0.2:8080/ > data/tests/config
@sleep 1
./minivpn -c data/tests/config -t 172.17.0.1 -n ${COUNT} ping
./minivpn -c data/tests/config -ping
@docker stop ovpn1

integration:
Expand All @@ -88,17 +72,6 @@ integration:
filternet-qa:
cd tests/qa && ./run-filternet.sh remote-block-all

coverage:
go test -coverprofile=coverage.out ./vpn
go tool cover -html=coverage.out

coverage-ping:
go test -coverprofile=coverage-ping.out ./extras/ping
go tool cover -html=coverage-ping.out

proxy:
./minivpn -c data/${PROVIDER}/config proxy

backup-data:
@tar cvzf ../data-vpn-`date +'%F'`.tar.gz

Expand All @@ -122,5 +95,9 @@ go-sec:
go-revive:
revive internal/...

install-linters:
go install github.com/mgechev/revive@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest

clean:
@rm -f coverage.out
29 changes: 0 additions & 29 deletions extras/example_pinger_test.go

This file was deleted.

134 changes: 0 additions & 134 deletions extras/ndt7.go

This file was deleted.

Loading

0 comments on commit d8b6eb5

Please sign in to comment.