diff --git a/.drone.yml b/.drone.yml index c5d91e0..008d4a0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,8 +1,14 @@ +--- kind: pipeline type: docker name: default steps: + - name: format + image: golang:1.15 + commands: + - bash -c "gofmt -l . | wc -l | cmp -s <(echo 0) || (gofmt -l . && exit 1)" + - name: install image: golang:1.15 environment: @@ -47,4 +53,10 @@ steps: volumes: - name: cache - temp: {} + temp: { } + +--- +kind: signature +hmac: 8c21312bcfbaa9b7d2d3c31b1a5c13b54b4ecd1da853aa66a8ed11d72154fcca + +... diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5cde1f0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2020 Jake Hillion + +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. + diff --git a/config/config.go b/config/config.go index 0f8f06a..163eb48 100644 --- a/config/config.go +++ b/config/config.go @@ -12,12 +12,12 @@ type Configuration struct { type Host struct { InterfaceName string - Crypto string `validate:"required,oneof=None Blake2s"` + Crypto string `validate:"required,oneof=None Blake2s"` SharedKey string `validate:"required_if=Crypto Blake2s"` } type Peer struct { - Method string `validate:"oneof=TCP UDP"` + Method string `validate:"oneof=TCP UDP"` LocalHost string `validate:"omitempty,ip"` LocalPort uint `validate:"max=65535"` @@ -25,7 +25,7 @@ type Peer struct { RemoteHost string `validate:"required_with=RemotePort,omitempty,fqdn|ip"` RemotePort uint `validate:"required_with=RemoteHost,omitempty,max=65535"` - Congestion string `validate:"oneof=NewReno None"` + Congestion string `validate:"required_unless=Method TCP,omitempty,oneof=NewReno None"` KeepAlive uint Timeout uint diff --git a/udp/congestion/newreno.go b/udp/congestion/newreno.go index 31fce00..2cf8681 100644 --- a/udp/congestion/newreno.go +++ b/udp/congestion/newreno.go @@ -17,8 +17,8 @@ type NewReno struct { keepalive chan bool outboundTimes, inboundTimes map[uint32]time.Time - outboundTimesLock sync.Mutex - inboundTimesLock sync.RWMutex + outboundTimesLock sync.Mutex + inboundTimesLock sync.RWMutex ack, lastAck uint32 nack, lastNack uint32 @@ -34,7 +34,7 @@ type NewReno struct { lastSent time.Time hasAcked bool - acksToSend utils.Uint32Heap + acksToSend utils.Uint32Heap acksToSendLock sync.Mutex } diff --git a/udp/packet_test.go b/udp/packet_test.go index e1ded3d..6ffc04c 100644 --- a/udp/packet_test.go +++ b/udp/packet_test.go @@ -33,7 +33,7 @@ func TestUnmarshalPacket(t *testing.T) { data: proxy.SimplePacket(testContent), } testMarshalled := testPacket.Marshal() - + t.Run("Length", func(t *testing.T) { p, err := UnmarshalPacket(testMarshalled) @@ -47,7 +47,7 @@ func TestUnmarshalPacket(t *testing.T) { require.Nil(t, err) assert.Equal(t, p.Contents(), testContent) }) - + t.Run("Header", func(t *testing.T) { p, err := UnmarshalPacket(testMarshalled) require.Nil(t, err)