mirror of
https://github.com/yggdrasil-network/yggdrasil-go
synced 2024-11-09 23:20:26 +03:00
Imprint build name and version number if available
This commit is contained in:
parent
4bc009d845
commit
8e784438c7
5
build
5
build
@ -14,10 +14,11 @@ go get -d -v yggdrasil
|
||||
for file in *.go ; do
|
||||
echo "Building: $file"
|
||||
#go build $@ $file
|
||||
IMPRINT="-X yggdrasil.buildName=$(sh contrib/semver/name.sh) -X yggdrasil.buildVersion=$(sh contrib/semver/version.sh)"
|
||||
if [ $DEBUG ]; then
|
||||
go build -tags debug -v $file
|
||||
go build -ldflags="$IMPRINT" -tags debug -v $file
|
||||
else
|
||||
go build -ldflags="-s -w" -v $file
|
||||
go build -ldflags="$IMPRINT -s -w" -v $file
|
||||
fi
|
||||
if [ $UPX ]; then
|
||||
upx --brute ${file%.go}
|
||||
|
@ -12,6 +12,9 @@ import (
|
||||
"yggdrasil/defaults"
|
||||
)
|
||||
|
||||
var buildName string
|
||||
var buildVersion string
|
||||
|
||||
// The Core object represents the Yggdrasil node. You should create a Core
|
||||
// object for each Yggdrasil node you plan to run.
|
||||
type Core struct {
|
||||
@ -59,6 +62,24 @@ func (c *Core) init(bpub *boxPubKey,
|
||||
c.tun.init(c)
|
||||
}
|
||||
|
||||
// Get the current build name. This is usually injected if built from git,
|
||||
// or returns "unknown" otherwise.
|
||||
func GetBuildName() string {
|
||||
if buildName == "" {
|
||||
return "unknown"
|
||||
}
|
||||
return buildName
|
||||
}
|
||||
|
||||
// Get the current build version. This is usually injected if built from git,
|
||||
// or returns "unknown" otherwise.
|
||||
func GetBuildVersion() string {
|
||||
if buildVersion == "" {
|
||||
return "unknown"
|
||||
}
|
||||
return buildVersion
|
||||
}
|
||||
|
||||
// Starts up Yggdrasil using the provided NodeConfig, and outputs debug logging
|
||||
// through the provided log.Logger. The started stack will include TCP and UDP
|
||||
// sockets, a multicast discovery socket, an admin socket, router, switch and
|
||||
|
@ -100,10 +100,15 @@ func main() {
|
||||
normaliseconf := flag.Bool("normaliseconf", false, "use in combination with either -useconf or -useconffile, outputs your configuration normalised")
|
||||
confjson := flag.Bool("json", false, "print configuration from -genconf or -normaliseconf as JSON instead of HJSON")
|
||||
autoconf := flag.Bool("autoconf", false, "automatic mode (dynamic IP, peer with IPv6 neighbors)")
|
||||
version := flag.Bool("version", false, "prints the version of this build")
|
||||
flag.Parse()
|
||||
|
||||
var cfg *nodeConfig
|
||||
switch {
|
||||
case *version:
|
||||
fmt.Println("Build name:", yggdrasil.GetBuildName())
|
||||
fmt.Println("Build version:", yggdrasil.GetBuildVersion())
|
||||
os.Exit(0)
|
||||
case *autoconf:
|
||||
// Use an autoconf-generated config, this will give us random keys and
|
||||
// port numbers, and will use an automatically selected TUN/TAP interface.
|
||||
|
Loading…
Reference in New Issue
Block a user