From a28e2d64e12d3cefda4671b9d158406b1dc1a1d0 Mon Sep 17 00:00:00 2001 From: ruffrey Date: Mon, 25 Oct 2021 11:36:13 -0700 Subject: [PATCH] Use native go xxhash --- .github/workflows/release.yml | 4 ++++ build-all.sh | 4 ++-- go.mod | 6 +++--- go.sum | 7 +++---- protocol/protocol.go | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bcd1e3..98627da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + - name: Setup go + uses: actions/setup-go@v2 + with: + go-version: 1.17 - name: build artifacts run: make build-all - name: Create Release diff --git a/build-all.sh b/build-all.sh index afabd0a..9f3d15b 100755 --- a/build-all.sh +++ b/build-all.sh @@ -14,7 +14,7 @@ mkdir out/ for GOOS in $PLATFORMS; do for GOARCH in $ARCHITECTURES; do echo $GOOS $GOARCH - GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="${LDFLAGS}" -o "out/dracula-cli_${GOOS}-${GOARCH}-${VERSION}" cli/main.go - GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="${LDFLAGS}" -o "out/dracula-server_${GOOS}-${GOARCH}-${VERSION}" cmd/main.go + CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="${LDFLAGS}" -o "out/dracula-cli_${GOOS}-${GOARCH}-${VERSION}" cli/main.go + CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="${LDFLAGS}" -o "out/dracula-server_${GOOS}-${GOARCH}-${VERSION}" cmd/main.go done done diff --git a/go.mod b/go.mod index cd5fbe5..2900a2f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/mailsac/dracula go 1.16 require ( - github.com/cespare/xxhash v1.1.0 // indirect - github.com/emirpasic/gods v1.12.0 // indirect - github.com/stretchr/testify v1.7.0 // indirect + github.com/OneOfOne/xxhash v1.2.8 + github.com/emirpasic/gods v1.12.0 + github.com/stretchr/testify v1.7.0 ) diff --git a/go.sum b/go.sum index 3097af1..81078c7 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,15 @@ -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= +github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/protocol/protocol.go b/protocol/protocol.go index 513b00f..afded1e 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -4,7 +4,7 @@ import ( "encoding/binary" "errors" "fmt" - "github.com/cespare/xxhash" + "github.com/OneOfOne/xxhash" "log" "math" "strings" @@ -190,7 +190,7 @@ func (p *Packet) Bytes() ([]byte, error) { // HashPacket returns an 8 byte slice func HashPacket(p *Packet, preSharedKey []byte) []byte { - hasher := xxhash.New() + hasher := xxhash.New64() // omit the spaces and hash the Message ID, Namespace, and DataValue bytesToHash := append(preSharedKey, p.MessageIDBytes...) bytesToHash = append(bytesToHash, p.Namespace...)