2016-11-30 05:34:24 -06:00
|
|
|
// Copyright 2016 The go-ethereum Authors
|
|
|
|
// This file is part of go-ethereum.
|
|
|
|
//
|
|
|
|
// go-ethereum is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// go-ethereum is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
|
|
|
|
2022-09-23 07:08:25 -05:00
|
|
|
"github.com/ethereum/go-ethereum/internal/version"
|
2022-06-27 11:22:36 -05:00
|
|
|
"github.com/urfave/cli/v2"
|
2016-11-30 05:34:24 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-06-27 11:22:36 -05:00
|
|
|
VersionCheckUrlFlag = &cli.StringFlag{
|
2020-12-04 08:01:47 -06:00
|
|
|
Name: "check.url",
|
|
|
|
Usage: "URL to use when checking vulnerabilities",
|
|
|
|
Value: "https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json",
|
|
|
|
}
|
2022-06-27 11:22:36 -05:00
|
|
|
VersionCheckVersionFlag = &cli.StringFlag{
|
2020-12-04 08:01:47 -06:00
|
|
|
Name: "check.version",
|
|
|
|
Usage: "Version to check",
|
2022-09-23 07:08:25 -05:00
|
|
|
Value: version.ClientName(clientIdentifier),
|
2020-12-04 08:01:47 -06:00
|
|
|
}
|
2022-06-27 11:22:36 -05:00
|
|
|
versionCommand = &cli.Command{
|
2022-09-23 07:08:25 -05:00
|
|
|
Action: printVersion,
|
2016-11-30 05:34:24 -06:00
|
|
|
Name: "version",
|
|
|
|
Usage: "Print version numbers",
|
|
|
|
ArgsUsage: " ",
|
|
|
|
Description: `
|
|
|
|
The output of this command is supposed to be machine-readable.
|
2020-12-04 08:01:47 -06:00
|
|
|
`,
|
|
|
|
}
|
2022-06-27 11:22:36 -05:00
|
|
|
versionCheckCommand = &cli.Command{
|
|
|
|
Action: versionCheck,
|
2020-12-04 08:01:47 -06:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
VersionCheckUrlFlag,
|
|
|
|
VersionCheckVersionFlag,
|
|
|
|
},
|
|
|
|
Name: "version-check",
|
2022-06-27 11:22:36 -05:00
|
|
|
Usage: "Checks (online) for known Geth security vulnerabilities",
|
2020-12-04 08:01:47 -06:00
|
|
|
ArgsUsage: "<versionstring (optional)>",
|
|
|
|
Description: `
|
|
|
|
The version-check command fetches vulnerability-information from https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json,
|
|
|
|
and displays information about any security vulnerabilities that affect the currently executing version.
|
2016-11-30 05:34:24 -06:00
|
|
|
`,
|
|
|
|
}
|
2022-06-27 11:22:36 -05:00
|
|
|
licenseCommand = &cli.Command{
|
|
|
|
Action: license,
|
2016-11-30 05:34:24 -06:00
|
|
|
Name: "license",
|
|
|
|
Usage: "Display license information",
|
|
|
|
ArgsUsage: " ",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-09-23 07:08:25 -05:00
|
|
|
func printVersion(ctx *cli.Context) error {
|
|
|
|
git, _ := version.VCS()
|
|
|
|
|
2016-11-30 05:34:24 -06:00
|
|
|
fmt.Println(strings.Title(clientIdentifier))
|
2024-10-20 11:28:39 -05:00
|
|
|
fmt.Println("Version:", version.WithMeta)
|
2022-09-23 07:08:25 -05:00
|
|
|
if git.Commit != "" {
|
|
|
|
fmt.Println("Git Commit:", git.Commit)
|
2016-11-30 05:34:24 -06:00
|
|
|
}
|
2022-09-23 07:08:25 -05:00
|
|
|
if git.Date != "" {
|
|
|
|
fmt.Println("Git Commit Date:", git.Date)
|
2019-05-08 08:44:28 -05:00
|
|
|
}
|
2017-04-05 14:51:01 -05:00
|
|
|
fmt.Println("Architecture:", runtime.GOARCH)
|
2016-11-30 05:34:24 -06:00
|
|
|
fmt.Println("Go Version:", runtime.Version())
|
2017-04-05 14:51:01 -05:00
|
|
|
fmt.Println("Operating System:", runtime.GOOS)
|
2016-11-30 05:34:24 -06:00
|
|
|
fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
|
|
|
|
fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func license(_ *cli.Context) error {
|
|
|
|
fmt.Println(`Geth is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Geth is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2018-01-02 05:48:19 -06:00
|
|
|
along with geth. If not, see <http://www.gnu.org/licenses/>.`)
|
2016-11-30 05:34:24 -06:00
|
|
|
return nil
|
|
|
|
}
|