diff --git a/go.mod b/go.mod index e8876115..36f8e7dd 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ -module resty.dev/v3 +module github.com/digitalmint/resty/v4 -go 1.21 +go 1.23.0 -require golang.org/x/net v0.33.0 +toolchain go1.24.5 + +require golang.org/x/net v0.42.0 diff --git a/go.sum b/go.sum index 16660ab5..4af2a26b 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= +golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= diff --git a/resty.go b/resty.go index 677b6463..581bd2e0 100644 --- a/resty.go +++ b/resty.go @@ -4,7 +4,7 @@ // SPDX-License-Identifier: MIT // Package resty provides Simple HTTP, REST, and SSE client library for Go. -package resty // import "resty.dev/v3" +package resty import ( "math" diff --git a/util.go b/util.go index a981a349..8999d3ec 100644 --- a/util.go +++ b/util.go @@ -7,8 +7,8 @@ package resty import ( "bytes" - "crypto/md5" "crypto/rand" + "crypto/sha256" "encoding/binary" "encoding/hex" "errors" @@ -403,13 +403,12 @@ var osHostname = os.Hostname // readMachineID generates and returns a machine id. // If this function fails to get the hostname it will cause a runtime error. func readMachineID() []byte { - var sum [3]byte - id := sum[:] + const idSize = 3 + id := make([]byte, idSize) if hostname, err := osHostname(); err == nil { - hw := md5.New() - _, _ = hw.Write([]byte(hostname)) - copy(id, hw.Sum(nil)) + hash := sha256.Sum256([]byte(hostname)) + copy(id, hash[:idSize]) return id } @@ -417,7 +416,5 @@ func readMachineID() []byte { return id } - // To initialize package unexported variable 'machineID'. - // This panic would happen at program startup, so no worries at runtime panic. panic(errors.New("resty - guid: unable to get hostname and random bytes")) }