Skip to content

Commit

Permalink
Use native go xxhash
Browse files Browse the repository at this point in the history
  • Loading branch information
ruffrey committed Oct 25, 2021
1 parent 4a6ff51 commit a28e2d6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
7 changes: 3 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
4 changes: 2 additions & 2 deletions protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/cespare/xxhash"
"github.com/OneOfOne/xxhash"
"log"
"math"
"strings"
Expand Down Expand Up @@ -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...)
Expand Down

0 comments on commit a28e2d6

Please sign in to comment.