mirror of
https://github.com/jwhited/wgsd.git
synced 2025-01-18 13:59:34 +08:00
setup github actions
This commit is contained in:
parent
49e376d95c
commit
6c78ee4e64
17
.github/workflows/lint.yml
vendored
Normal file
17
.github/workflows/lint.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: golangci-lint
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
jobs:
|
||||
lint:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: v1.29
|
22
.github/workflows/test.yml
vendored
Normal file
22
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: test
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.14.x, 1.15.x]
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Test
|
||||
run: go test -v -race ./...
|
22
.golangci.yml
Normal file
22
.golangci.yml
Normal file
@ -0,0 +1,22 @@
|
||||
run:
|
||||
timeout: 5m
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- varcheck
|
||||
- gofmt
|
||||
disable-all: true
|
||||
|
||||
linters-settings:
|
||||
gofmt:
|
||||
# simplify code: gofmt with `-s` option, true by default
|
||||
simplify: false
|
23
wgsd_test.go
23
wgsd_test.go
@ -1,7 +1,6 @@
|
||||
package wgsd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base32"
|
||||
"fmt"
|
||||
@ -26,14 +25,6 @@ func (m *mockClient) Device(d string) (*wgtypes.Device, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func base32EqualsPubKey(t *testing.T, b32 string, pubKey wgtypes.Key) bool {
|
||||
got, err := base32.StdEncoding.DecodeString(strings.ToUpper(b32))
|
||||
if err != nil {
|
||||
t.Fatalf("error decoding base32 string: %v", err)
|
||||
}
|
||||
return bytes.Equal(pubKey[:], got)
|
||||
}
|
||||
|
||||
func TestWGSD(t *testing.T) {
|
||||
key1 := [32]byte{}
|
||||
key1[0] = 1
|
||||
@ -65,7 +56,7 @@ func TestWGSD(t *testing.T) {
|
||||
}
|
||||
|
||||
testCases := []test.Case{
|
||||
test.Case{
|
||||
{
|
||||
Qname: "_wireguard._udp.example.com.",
|
||||
Qtype: dns.TypePTR,
|
||||
Rcode: dns.RcodeSuccess,
|
||||
@ -74,7 +65,7 @@ func TestWGSD(t *testing.T) {
|
||||
test.PTR(fmt.Sprintf("_wireguard._udp.example.com. 0 IN PTR %s._wireguard._udp.example.com.", peer2b32)),
|
||||
},
|
||||
},
|
||||
test.Case{
|
||||
{
|
||||
Qname: fmt.Sprintf("%s._wireguard._udp.example.com.", peer1b32),
|
||||
Qtype: dns.TypeSRV,
|
||||
Rcode: dns.RcodeSuccess,
|
||||
@ -85,7 +76,7 @@ func TestWGSD(t *testing.T) {
|
||||
test.A(fmt.Sprintf("%s.example.com. 0 IN A %s", peer1b32, peer1.Endpoint.IP.String())),
|
||||
},
|
||||
},
|
||||
test.Case{
|
||||
{
|
||||
Qname: fmt.Sprintf("%s._wireguard._udp.example.com.", peer2b32),
|
||||
Qtype: dns.TypeSRV,
|
||||
Rcode: dns.RcodeSuccess,
|
||||
@ -96,7 +87,7 @@ func TestWGSD(t *testing.T) {
|
||||
test.AAAA(fmt.Sprintf("%s.example.com. 0 IN AAAA %s", peer2b32, peer2.Endpoint.IP.String())),
|
||||
},
|
||||
},
|
||||
test.Case{
|
||||
{
|
||||
Qname: fmt.Sprintf("%s.example.com.", peer1b32),
|
||||
Qtype: dns.TypeA,
|
||||
Rcode: dns.RcodeSuccess,
|
||||
@ -104,7 +95,7 @@ func TestWGSD(t *testing.T) {
|
||||
test.A(fmt.Sprintf("%s.example.com. 0 IN A %s", peer1b32, peer1.Endpoint.IP.String())),
|
||||
},
|
||||
},
|
||||
test.Case{
|
||||
{
|
||||
Qname: fmt.Sprintf("%s.example.com.", peer2b32),
|
||||
Qtype: dns.TypeAAAA,
|
||||
Rcode: dns.RcodeSuccess,
|
||||
@ -112,7 +103,7 @@ func TestWGSD(t *testing.T) {
|
||||
test.AAAA(fmt.Sprintf("%s.example.com. 0 IN AAAA %s", peer2b32, peer2.Endpoint.IP.String())),
|
||||
},
|
||||
},
|
||||
test.Case{
|
||||
{
|
||||
Qname: "nxdomain.example.com.",
|
||||
Qtype: dns.TypeAAAA,
|
||||
Rcode: dns.RcodeNameError,
|
||||
@ -120,7 +111,7 @@ func TestWGSD(t *testing.T) {
|
||||
test.SOA(soa("example.com.").String()),
|
||||
},
|
||||
},
|
||||
test.Case{
|
||||
{
|
||||
Qname: "servfail.notexample.com.",
|
||||
Qtype: dns.TypeAAAA,
|
||||
Rcode: dns.RcodeServerFailure,
|
||||
|
Loading…
x
Reference in New Issue
Block a user