-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from 9seconds/go1.19
- Loading branch information
Showing
91 changed files
with
675 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
// Antireplay package has cache implementations that are effective | ||
// against replay attacks. | ||
// Antireplay package has cache implementations that are effective against | ||
// replay attacks. | ||
// | ||
// To understand more about replay attacks, please read documentation | ||
// for mtglib.AntiReplayCache interface. This package has a list of some | ||
// To understand more about replay attacks, please read documentation for | ||
// [mtglib.AntiReplayCache] interface. This package has a list of some | ||
// implementations of this interface. | ||
package antireplay | ||
|
||
const ( | ||
// DefaultStableBloomFilterMaxSize is a recommended byte size for a | ||
// stable bloom filter. | ||
// DefaultStableBloomFilterMaxSize is a recommended byte size for a stable | ||
// bloom filter. | ||
DefaultStableBloomFilterMaxSize = 1024 * 1024 // 1MiB | ||
|
||
// DefaultStableBloomFilterErrorRate is a recommended default error | ||
// rate for a stable bloom filter. | ||
// DefaultStableBloomFilterErrorRate is a recommended default error rate for a | ||
// stable bloom filter. | ||
DefaultStableBloomFilterErrorRate = 0.001 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha256" | ||
"encoding/base64" | ||
"encoding/binary" | ||
"fmt" | ||
"io" | ||
"runtime/debug" | ||
"sort" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
var version = "dev" // has to be set by ldflags | ||
|
||
const ( | ||
buildInfoModuleStart byte = iota | ||
buildInfoModuleFinish | ||
buildInfoModuleDelimeter | ||
) | ||
|
||
func getVersion() string { | ||
buildInfo, ok := debug.ReadBuildInfo() | ||
if !ok { | ||
return version | ||
} | ||
|
||
date := time.Now() | ||
commit := "" | ||
goVersion := buildInfo.GoVersion | ||
dirtySuffix := "" | ||
|
||
for _, setting := range buildInfo.Settings { | ||
switch setting.Key { | ||
case "vcs.time": | ||
date, _ = time.Parse(time.RFC3339, setting.Value) | ||
case "vcs.revision": | ||
commit = setting.Value | ||
case "vcs.modified": | ||
if dirty, _ := strconv.ParseBool(setting.Value); dirty { | ||
dirtySuffix = " [dirty]" | ||
} | ||
} | ||
} | ||
|
||
hasher := sha256.New() | ||
|
||
checksumModule := func(mod *debug.Module) { | ||
hasher.Write([]byte{buildInfoModuleStart}) | ||
|
||
io.WriteString(hasher, mod.Path) //nolint: errcheck | ||
hasher.Write([]byte{buildInfoModuleDelimeter}) | ||
|
||
io.WriteString(hasher, mod.Version) //nolint: errcheck | ||
hasher.Write([]byte{buildInfoModuleDelimeter}) | ||
|
||
io.WriteString(hasher, mod.Sum) //nolint: errcheck | ||
|
||
hasher.Write([]byte{buildInfoModuleFinish}) | ||
} | ||
|
||
io.WriteString(hasher, buildInfo.Path) //nolint: errcheck | ||
|
||
binary.Write(hasher, binary.LittleEndian, uint64(1+len(buildInfo.Deps))) //nolint: errcheck | ||
|
||
sort.Slice(buildInfo.Deps, func(i, j int) bool { | ||
return buildInfo.Deps[i].Path > buildInfo.Deps[j].Path | ||
}) | ||
|
||
checksumModule(&buildInfo.Main) | ||
|
||
for _, module := range buildInfo.Deps { | ||
checksumModule(module) | ||
} | ||
|
||
return fmt.Sprintf("%s (%s: %s on %s%s, modules checksum %s)", | ||
version, | ||
goVersion, | ||
date.Format(time.RFC3339), | ||
commit, | ||
dirtySuffix, | ||
base64.StdEncoding.EncodeToString(hasher.Sum(nil))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.