github.com/calmw/ethereum@v0.1.1/cmd/geth/misccmd.go (about)

     1  // Copyright 2016 The go-ethereum Authors
     2  // This file is part of go-ethereum.
     3  //
     4  // go-ethereum is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // go-ethereum is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU General Public License
    15  // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package main
    18  
    19  import (
    20  	"fmt"
    21  	"os"
    22  	"runtime"
    23  	"strings"
    24  
    25  	"github.com/calmw/ethereum/internal/version"
    26  	"github.com/calmw/ethereum/params"
    27  	"github.com/urfave/cli/v2"
    28  )
    29  
    30  var (
    31  	VersionCheckUrlFlag = &cli.StringFlag{
    32  		Name:  "check.url",
    33  		Usage: "URL to use when checking vulnerabilities",
    34  		Value: "https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json",
    35  	}
    36  	VersionCheckVersionFlag = &cli.StringFlag{
    37  		Name:  "check.version",
    38  		Usage: "Version to check",
    39  		Value: version.ClientName(clientIdentifier),
    40  	}
    41  	versionCommand = &cli.Command{
    42  		Action:    printVersion,
    43  		Name:      "version",
    44  		Usage:     "Print version numbers",
    45  		ArgsUsage: " ",
    46  		Description: `
    47  The output of this command is supposed to be machine-readable.
    48  `,
    49  	}
    50  	versionCheckCommand = &cli.Command{
    51  		Action: versionCheck,
    52  		Flags: []cli.Flag{
    53  			VersionCheckUrlFlag,
    54  			VersionCheckVersionFlag,
    55  		},
    56  		Name:      "version-check",
    57  		Usage:     "Checks (online) for known Geth security vulnerabilities",
    58  		ArgsUsage: "<versionstring (optional)>",
    59  		Description: `
    60  The version-check command fetches vulnerability-information from https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json, 
    61  and displays information about any security vulnerabilities that affect the currently executing version.
    62  `,
    63  	}
    64  	licenseCommand = &cli.Command{
    65  		Action:    license,
    66  		Name:      "license",
    67  		Usage:     "Display license information",
    68  		ArgsUsage: " ",
    69  	}
    70  )
    71  
    72  func printVersion(ctx *cli.Context) error {
    73  	git, _ := version.VCS()
    74  
    75  	fmt.Println(strings.Title(clientIdentifier))
    76  	fmt.Println("Version:", params.VersionWithMeta)
    77  	if git.Commit != "" {
    78  		fmt.Println("Git Commit:", git.Commit)
    79  	}
    80  	if git.Date != "" {
    81  		fmt.Println("Git Commit Date:", git.Date)
    82  	}
    83  	fmt.Println("Architecture:", runtime.GOARCH)
    84  	fmt.Println("Go Version:", runtime.Version())
    85  	fmt.Println("Operating System:", runtime.GOOS)
    86  	fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
    87  	fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
    88  	return nil
    89  }
    90  
    91  func license(_ *cli.Context) error {
    92  	fmt.Println(`Geth is free software: you can redistribute it and/or modify
    93  it under the terms of the GNU General Public License as published by
    94  the Free Software Foundation, either version 3 of the License, or
    95  (at your option) any later version.
    96  
    97  Geth is distributed in the hope that it will be useful,
    98  but WITHOUT ANY WARRANTY; without even the implied warranty of
    99  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   100  GNU General Public License for more details.
   101  
   102  You should have received a copy of the GNU General Public License
   103  along with geth. If not, see <http://www.gnu.org/licenses/>.`)
   104  	return nil
   105  }