diff options
author | Janos Guljas <janos@resenje.org> | 2018-02-23 01:50:47 +0800 |
---|---|---|
committer | Janos Guljas <janos@resenje.org> | 2018-02-23 01:51:34 +0800 |
commit | 6a9730edaa3c398ef1e9fe084f9b16de4d3ef78e (patch) | |
tree | 442ae3e5d75fa5418b362474754d319a7fdfa8f0 /cmd | |
parent | a3a07350dcef0ba39829a20d8ddba4bd3463d293 (diff) | |
parent | 221486a29109803286c1448426d6180ef5024cf0 (diff) | |
download | go-tangerine-6a9730edaa3c398ef1e9fe084f9b16de4d3ef78e.tar.gz go-tangerine-6a9730edaa3c398ef1e9fe084f9b16de4d3ef78e.tar.zst go-tangerine-6a9730edaa3c398ef1e9fe084f9b16de4d3ef78e.zip |
swarm, cmd/swarm: Merge branch 'master' into multiple-ens-endpoints
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/bootnode/main.go | 7 | ||||
-rw-r--r-- | cmd/ethkey/inspect.go | 16 | ||||
-rw-r--r-- | cmd/ethkey/message_test.go | 2 | ||||
-rw-r--r-- | cmd/ethkey/run_test.go | 2 | ||||
-rw-r--r-- | cmd/evm/json_logger.go | 14 | ||||
-rw-r--r-- | cmd/faucet/faucet.go | 9 | ||||
-rw-r--r-- | cmd/geth/chaincmd.go | 3 | ||||
-rw-r--r-- | cmd/geth/consolecmd.go | 3 | ||||
-rw-r--r-- | cmd/geth/main.go | 1 | ||||
-rw-r--r-- | cmd/geth/usage.go | 1 | ||||
-rw-r--r-- | cmd/p2psim/main.go | 16 | ||||
-rw-r--r-- | cmd/puppeth/module_dashboard.go | 78 | ||||
-rw-r--r-- | cmd/puppeth/module_faucet.go | 8 | ||||
-rw-r--r-- | cmd/puppeth/module_node.go | 54 | ||||
-rw-r--r-- | cmd/puppeth/wizard.go | 3 | ||||
-rw-r--r-- | cmd/puppeth/wizard_explorer.go | 2 | ||||
-rw-r--r-- | cmd/puppeth/wizard_faucet.go | 8 | ||||
-rw-r--r-- | cmd/puppeth/wizard_intro.go | 7 | ||||
-rw-r--r-- | cmd/puppeth/wizard_netstats.go | 14 | ||||
-rw-r--r-- | cmd/puppeth/wizard_node.go | 10 | ||||
-rw-r--r-- | cmd/puppeth/wizard_wallet.go | 2 | ||||
-rw-r--r-- | cmd/swarm/run_test.go | 2 | ||||
-rw-r--r-- | cmd/swarm/upload_test.go | 2 | ||||
-rw-r--r-- | cmd/utils/cmd.go | 5 | ||||
-rw-r--r-- | cmd/utils/flags.go | 7 | ||||
-rw-r--r-- | cmd/wnode/main.go | 61 |
26 files changed, 198 insertions, 139 deletions
diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go index ecfc6fc24..2e93cc04d 100644 --- a/cmd/bootnode/main.go +++ b/cmd/bootnode/main.go @@ -122,7 +122,12 @@ func main() { utils.Fatalf("%v", err) } } else { - if _, err := discover.ListenUDP(nodeKey, conn, realaddr, nil, "", restrictList); err != nil { + cfg := discover.Config{ + PrivateKey: nodeKey, + AnnounceAddr: realaddr, + NetRestrict: restrictList, + } + if _, err := discover.ListenUDP(conn, cfg); err != nil { utils.Fatalf("%v", err) } } diff --git a/cmd/ethkey/inspect.go b/cmd/ethkey/inspect.go index 219a5460b..dbf5afc0c 100644 --- a/cmd/ethkey/inspect.go +++ b/cmd/ethkey/inspect.go @@ -1,3 +1,19 @@ +// Copyright 2017 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 ( diff --git a/cmd/ethkey/message_test.go b/cmd/ethkey/message_test.go index fb16f03d0..39352b1d2 100644 --- a/cmd/ethkey/message_test.go +++ b/cmd/ethkey/message_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 The go-ethereum Authors +// Copyright 2018 The go-ethereum Authors // This file is part of go-ethereum. // // go-ethereum is free software: you can redistribute it and/or modify diff --git a/cmd/ethkey/run_test.go b/cmd/ethkey/run_test.go index 8ce4fe5cd..6006f6b5b 100644 --- a/cmd/ethkey/run_test.go +++ b/cmd/ethkey/run_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 The go-ethereum Authors +// Copyright 2018 The go-ethereum Authors // This file is part of go-ethereum. // // go-ethereum is free software: you can redistribute it and/or modify diff --git a/cmd/evm/json_logger.go b/cmd/evm/json_logger.go index 47daf7dbb..0e7a91189 100644 --- a/cmd/evm/json_logger.go +++ b/cmd/evm/json_logger.go @@ -1,18 +1,18 @@ // Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. +// This file is part of go-ethereum. // -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by +// 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. // -// The go-ethereum library is distributed in the hope that it will be useful, +// 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 Lesser General Public License for more details. +// GNU General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. +// 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 diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 99527f9d1..095668c86 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -686,8 +686,6 @@ func authTwitter(url string) (string, string, common.Address, error) { if len(parts) < 4 || parts[len(parts)-2] != "status" { return "", "", common.Address{}, errors.New("Invalid Twitter status URL") } - username := parts[len(parts)-3] - // Twitter's API isn't really friendly with direct links. Still, we don't // want to do ask read permissions from users, so just load the public posts and // scrape it for the Ethereum address and profile URL. @@ -697,6 +695,13 @@ func authTwitter(url string) (string, string, common.Address, error) { } defer res.Body.Close() + // Resolve the username from the final redirect, no intermediate junk + parts = strings.Split(res.Request.URL.String(), "/") + if len(parts) < 4 || parts[len(parts)-2] != "status" { + return "", "", common.Address{}, errors.New("Invalid Twitter status URL") + } + username := parts[len(parts)-3] + body, err := ioutil.ReadAll(res.Body) if err != nil { return "", "", common.Address{}, err diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 35bf576e1..85d0c3aca 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -67,6 +67,9 @@ It expects the genesis file as argument.`, utils.DataDirFlag, utils.CacheFlag, utils.LightModeFlag, + utils.GCModeFlag, + utils.CacheDatabaseFlag, + utils.CacheGCFlag, }, Category: "BLOCKCHAIN COMMANDS", Description: ` diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 9d5cc38a1..7eca4d59f 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -22,6 +22,7 @@ import ( "os/signal" "path/filepath" "strings" + "syscall" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/console" @@ -207,7 +208,7 @@ func ephemeralConsole(ctx *cli.Context) error { } // Wait for pending callbacks, but stop for Ctrl-C. abort := make(chan os.Signal, 1) - signal.Notify(abort, os.Interrupt) + signal.Notify(abort, syscall.SIGINT, syscall.SIGTERM) go func() { <-abort diff --git a/cmd/geth/main.go b/cmd/geth/main.go index cb8d63bf7..a82e5c89c 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -114,6 +114,7 @@ var ( utils.VMEnableDebugFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, + utils.RPCVirtualHostsFlag, utils.EthStatsURLFlag, utils.MetricsEnabledFlag, utils.FakePoWFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index a2bcaff02..a1558c233 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -156,6 +156,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.IPCDisabledFlag, utils.IPCPathFlag, utils.RPCCORSDomainFlag, + utils.RPCVirtualHostsFlag, utils.JSpathFlag, utils.ExecFlag, utils.PreloadJSFlag, diff --git a/cmd/p2psim/main.go b/cmd/p2psim/main.go index 56b74d135..0c8ed038d 100644 --- a/cmd/p2psim/main.go +++ b/cmd/p2psim/main.go @@ -1,3 +1,19 @@ +// Copyright 2017 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/>. + // p2psim provides a command-line client for a simulation HTTP API. // // Here is an example of creating a 2 node network with the first node diff --git a/cmd/puppeth/module_dashboard.go b/cmd/puppeth/module_dashboard.go index 1092c4c88..1cb2d4549 100644 --- a/cmd/puppeth/module_dashboard.go +++ b/cmd/puppeth/module_dashboard.go @@ -117,7 +117,7 @@ var dashboardContent = ` <br/> <p>To run an archive node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with: <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre> - <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=1024 --syncmode=full{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre> + <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=1024 --syncmode=full{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFlat}}</pre> </p> <br/> <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p> @@ -136,7 +136,7 @@ var dashboardContent = ` <br/> <p>To run a full node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with: <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre> - <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=512{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre> + <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=512{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFlat}}</pre> </p> <br/> <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p> @@ -158,7 +158,7 @@ var dashboardContent = ` <br/> <p>To run a light node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with: <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre> - <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre> + <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFlat}}</pre> </p> <br/> <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p> @@ -177,7 +177,7 @@ var dashboardContent = ` <br/> <p>To run an embedded node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with: <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre> - <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=16 --ethash.cachesinmem=1 --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre> + <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=16 --ethash.cachesinmem=1 --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFlat}}</pre> </p> <br/> <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p> @@ -208,7 +208,7 @@ var dashboardContent = ` <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre> </p> <p>With your local chain initialized, you can start the Ethereum Wallet: - <pre>ethereumwallet --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre> + <pre>ethereumwallet --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFlat}}</pre> <p> <br/> <p>You can download the Ethereum Wallet from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p> @@ -229,7 +229,7 @@ var dashboardContent = ` <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre> </p> <p>With your local chain initialized, you can start Mist: - <pre>mist --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre> + <pre>mist --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFlat}}</pre> <p> <br/> <p>You can download the Mist browser from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p> @@ -261,7 +261,7 @@ var dashboardContent = ` <p>Inside your Java code you can now import the geth archive and connect to Ethereum: <pre>import org.ethereum.geth.*;</pre> <pre> -Enodes bootnodes = new Enodes();{{range .BootnodesLight}} +Enodes bootnodes = new Enodes();{{range .Bootnodes}} bootnodes.append(new Enode("{{.}}"));{{end}} NodeConfig config = new NodeConfig(); @@ -294,7 +294,7 @@ node.start(); <pre> var error: NSError? -let bootnodes = GethNewEnodesEmpty(){{range .BootnodesLight}} +let bootnodes = GethNewEnodesEmpty(){{range .Bootnodes}} bootnodes?.append(GethNewEnode("{{.}}", &error)){{end}} let config = GethNewNodeConfig() @@ -595,44 +595,42 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da statsLogin = "" } indexfile := new(bytes.Buffer) - bootCpp := make([]string, len(conf.bootFull)) - for i, boot := range conf.bootFull { + bootCpp := make([]string, len(conf.bootnodes)) + for i, boot := range conf.bootnodes { bootCpp[i] = "required:" + strings.TrimPrefix(boot, "enode://") } - bootHarmony := make([]string, len(conf.bootFull)) - for i, boot := range conf.bootFull { + bootHarmony := make([]string, len(conf.bootnodes)) + for i, boot := range conf.bootnodes { bootHarmony[i] = fmt.Sprintf("-Dpeer.active.%d.url=%s", i, boot) } - bootPython := make([]string, len(conf.bootFull)) - for i, boot := range conf.bootFull { + bootPython := make([]string, len(conf.bootnodes)) + for i, boot := range conf.bootnodes { bootPython[i] = "'" + boot + "'" } template.Must(template.New("").Parse(dashboardContent)).Execute(indexfile, map[string]interface{}{ - "Network": network, - "NetworkID": conf.Genesis.Config.ChainId, - "NetworkTitle": strings.Title(network), - "EthstatsPage": config.ethstats, - "ExplorerPage": config.explorer, - "WalletPage": config.wallet, - "FaucetPage": config.faucet, - "GethGenesis": network + ".json", - "BootnodesFull": conf.bootFull, - "BootnodesLight": conf.bootLight, - "BootnodesFullFlat": strings.Join(conf.bootFull, ","), - "BootnodesLightFlat": strings.Join(conf.bootLight, ","), - "Ethstats": statsLogin, - "Ethash": conf.Genesis.Config.Ethash != nil, - "CppGenesis": network + "-cpp.json", - "CppBootnodes": strings.Join(bootCpp, " "), - "HarmonyGenesis": network + "-harmony.json", - "HarmonyBootnodes": strings.Join(bootHarmony, " "), - "ParityGenesis": network + "-parity.json", - "PythonGenesis": network + "-python.json", - "PythonBootnodes": strings.Join(bootPython, ","), - "Homestead": conf.Genesis.Config.HomesteadBlock, - "Tangerine": conf.Genesis.Config.EIP150Block, - "Spurious": conf.Genesis.Config.EIP155Block, - "Byzantium": conf.Genesis.Config.ByzantiumBlock, + "Network": network, + "NetworkID": conf.Genesis.Config.ChainId, + "NetworkTitle": strings.Title(network), + "EthstatsPage": config.ethstats, + "ExplorerPage": config.explorer, + "WalletPage": config.wallet, + "FaucetPage": config.faucet, + "GethGenesis": network + ".json", + "Bootnodes": conf.bootnodes, + "BootnodesFlat": strings.Join(conf.bootnodes, ","), + "Ethstats": statsLogin, + "Ethash": conf.Genesis.Config.Ethash != nil, + "CppGenesis": network + "-cpp.json", + "CppBootnodes": strings.Join(bootCpp, " "), + "HarmonyGenesis": network + "-harmony.json", + "HarmonyBootnodes": strings.Join(bootHarmony, " "), + "ParityGenesis": network + "-parity.json", + "PythonGenesis": network + "-python.json", + "PythonBootnodes": strings.Join(bootPython, ","), + "Homestead": conf.Genesis.Config.HomesteadBlock, + "Tangerine": conf.Genesis.Config.EIP150Block, + "Spurious": conf.Genesis.Config.EIP155Block, + "Byzantium": conf.Genesis.Config.ByzantiumBlock, }) files[filepath.Join(workdir, "index.html")] = indexfile.Bytes() @@ -651,7 +649,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da harmonySpecJSON, _ := conf.Genesis.MarshalJSON() files[filepath.Join(workdir, network+"-harmony.json")] = harmonySpecJSON - paritySpec, err := newParityChainSpec(network, conf.Genesis, conf.bootFull) + paritySpec, err := newParityChainSpec(network, conf.Genesis, conf.bootnodes) if err != nil { return nil, err } diff --git a/cmd/puppeth/module_faucet.go b/cmd/puppeth/module_faucet.go index 92b4cb286..976bf04d0 100644 --- a/cmd/puppeth/module_faucet.go +++ b/cmd/puppeth/module_faucet.go @@ -93,7 +93,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config "NetworkID": config.node.network, "Bootnodes": strings.Join(bootnodes, ","), "Ethstats": config.node.ethstats, - "EthPort": config.node.portFull, + "EthPort": config.node.port, "CaptchaToken": config.captchaToken, "CaptchaSecret": config.captchaSecret, "FaucetName": strings.Title(network), @@ -110,7 +110,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config "Datadir": config.node.datadir, "VHost": config.host, "ApiPort": config.port, - "EthPort": config.node.portFull, + "EthPort": config.node.port, "EthName": config.node.ethstats[:strings.Index(config.node.ethstats, ":")], "CaptchaToken": config.captchaToken, "CaptchaSecret": config.captchaSecret, @@ -158,7 +158,7 @@ func (info *faucetInfos) Report() map[string]string { report := map[string]string{ "Website address": info.host, "Website listener port": strconv.Itoa(info.port), - "Ethereum listener port": strconv.Itoa(info.node.portFull), + "Ethereum listener port": strconv.Itoa(info.node.port), "Funding amount (base tier)": fmt.Sprintf("%d Ethers", info.amount), "Funding cooldown (base tier)": fmt.Sprintf("%d mins", info.minutes), "Funding tiers": strconv.Itoa(info.tiers), @@ -228,7 +228,7 @@ func checkFaucet(client *sshClient, network string) (*faucetInfos, error) { return &faucetInfos{ node: &nodeInfos{ datadir: infos.volumes["/root/.faucet"], - portFull: infos.portmap[infos.envvars["ETH_PORT"]+"/tcp"], + port: infos.portmap[infos.envvars["ETH_PORT"]+"/tcp"], ethstats: infos.envvars["ETH_NAME"], keyJSON: keyJSON, keyPass: keyPass, diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go index 69cb19c34..2609fd976 100644 --- a/cmd/puppeth/module_node.go +++ b/cmd/puppeth/module_node.go @@ -42,7 +42,7 @@ ADD genesis.json /genesis.json RUN \ echo 'geth --cache 512 init /genesis.json' > geth.sh && \{{if .Unlock}} echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}} - echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine --minerthreads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh + echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .Bootnodes}}--bootnodes {{.Bootnodes}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine --minerthreads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh ENTRYPOINT ["/bin/sh", "geth.sh"] ` @@ -56,15 +56,13 @@ services: build: . image: {{.Network}}/{{.Type}} ports: - - "{{.FullPort}}:{{.FullPort}}" - - "{{.FullPort}}:{{.FullPort}}/udp"{{if .Light}} - - "{{.LightPort}}:{{.LightPort}}/udp"{{end}} + - "{{.Port}}:{{.Port}}" + - "{{.Port}}:{{.Port}}/udp" volumes: - {{.Datadir}}:/root/.ethereum{{if .Ethashdir}} - {{.Ethashdir}}:/root/.ethash{{end}} environment: - - FULL_PORT={{.FullPort}}/tcp - - LIGHT_PORT={{.LightPort}}/udp + - PORT={{.Port}}/tcp - TOTAL_PEERS={{.TotalPeers}} - LIGHT_PEERS={{.LightPeers}} - STATS_NAME={{.Ethstats}} @@ -82,12 +80,11 @@ services: // deployNode deploys a new Ethereum node container to a remote machine via SSH, // docker and docker-compose. If an instance with the specified network name // already exists there, it will be overwritten! -func deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos, nocache bool) ([]byte, error) { +func deployNode(client *sshClient, network string, bootnodes []string, config *nodeInfos, nocache bool) ([]byte, error) { kind := "sealnode" if config.keyJSON == "" && config.etherbase == "" { kind = "bootnode" - bootv4 = make([]string, 0) - bootv5 = make([]string, 0) + bootnodes = make([]string, 0) } // Generate the content to upload to the server workdir := fmt.Sprintf("%d", rand.Int63()) @@ -100,11 +97,10 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf dockerfile := new(bytes.Buffer) template.Must(template.New("").Parse(nodeDockerfile)).Execute(dockerfile, map[string]interface{}{ "NetworkID": config.network, - "Port": config.portFull, + "Port": config.port, "Peers": config.peersTotal, "LightFlag": lightFlag, - "BootV4": strings.Join(bootv4, ","), - "BootV5": strings.Join(bootv5, ","), + "Bootnodes": strings.Join(bootnodes, ","), "Ethstats": config.ethstats, "Etherbase": config.etherbase, "GasTarget": uint64(1000000 * config.gasTarget), @@ -119,10 +115,9 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf "Datadir": config.datadir, "Ethashdir": config.ethashdir, "Network": network, - "FullPort": config.portFull, + "Port": config.port, "TotalPeers": config.peersTotal, "Light": config.peersLight > 0, - "LightPort": config.portFull + 1, "LightPeers": config.peersLight, "Ethstats": config.ethstats[:strings.Index(config.ethstats, ":")], "Etherbase": config.etherbase, @@ -157,10 +152,8 @@ type nodeInfos struct { datadir string ethashdir string ethstats string - portFull int - portLight int - enodeFull string - enodeLight string + port int + enode string peersTotal int peersLight int etherbase string @@ -174,15 +167,11 @@ type nodeInfos struct { // most - but not all - fields for reporting to the user. func (info *nodeInfos) Report() map[string]string { report := map[string]string{ - "Data directory": info.datadir, - "Listener port (full nodes)": strconv.Itoa(info.portFull), - "Peer count (all total)": strconv.Itoa(info.peersTotal), - "Peer count (light nodes)": strconv.Itoa(info.peersLight), - "Ethstats username": info.ethstats, - } - if info.peersLight > 0 { - // Light server enabled - report["Listener port (light nodes)"] = strconv.Itoa(info.portLight) + "Data directory": info.datadir, + "Listener port": strconv.Itoa(info.port), + "Peer count (all total)": strconv.Itoa(info.peersTotal), + "Peer count (light nodes)": strconv.Itoa(info.peersLight), + "Ethstats username": info.ethstats, } if info.gasTarget > 0 { // Miner or signer node @@ -250,7 +239,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error) keyPass = string(bytes.TrimSpace(out)) } // Run a sanity check to see if the devp2p is reachable - port := infos.portmap[infos.envvars["FULL_PORT"]] + port := infos.portmap[infos.envvars["PORT"]] if err = checkPort(client.server, port); err != nil { log.Warn(fmt.Sprintf("%s devp2p port seems unreachable", strings.Title(kind)), "server", client.server, "port", port, "err", err) } @@ -259,8 +248,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error) genesis: genesis, datadir: infos.volumes["/root/.ethereum"], ethashdir: infos.volumes["/root/.ethash"], - portFull: infos.portmap[infos.envvars["FULL_PORT"]], - portLight: infos.portmap[infos.envvars["LIGHT_PORT"]], + port: port, peersTotal: totalPeers, peersLight: lightPeers, ethstats: infos.envvars["STATS_NAME"], @@ -270,9 +258,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error) gasTarget: gasTarget, gasPrice: gasPrice, } - stats.enodeFull = fmt.Sprintf("enode://%s@%s:%d", id, client.address, stats.portFull) - if stats.portLight != 0 { - stats.enodeLight = fmt.Sprintf("enode://%s@%s:%d?discport=%d", id, client.address, stats.portFull, stats.portLight) - } + stats.enode = fmt.Sprintf("enode://%s@%s:%d", id, client.address, stats.port) + return stats, nil } diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index 2e2b4644c..b88a61de7 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -40,8 +40,7 @@ import ( // between sessions. type config struct { path string // File containing the configuration values - bootFull []string // Bootnodes to always connect to by full nodes - bootLight []string // Bootnodes to always connect to by light nodes + bootnodes []string // Bootnodes to always connect to by all nodes ethstats string // Ethstats settings to cache for node deploys Genesis *core.Genesis `json:"genesis,omitempty"` // Genesis block to cache for node deploys diff --git a/cmd/puppeth/wizard_explorer.go b/cmd/puppeth/wizard_explorer.go index 10ef72f78..413511c1c 100644 --- a/cmd/puppeth/wizard_explorer.go +++ b/cmd/puppeth/wizard_explorer.go @@ -55,7 +55,7 @@ func (w *wizard) deployExplorer() { } existed := err == nil - chainspec, err := newParityChainSpec(w.network, w.conf.Genesis, w.conf.bootFull) + chainspec, err := newParityChainSpec(w.network, w.conf.Genesis, w.conf.bootnodes) if err != nil { log.Error("Failed to create chain spec for explorer", "err", err) return diff --git a/cmd/puppeth/wizard_faucet.go b/cmd/puppeth/wizard_faucet.go index 191575b16..9a429bc96 100644 --- a/cmd/puppeth/wizard_faucet.go +++ b/cmd/puppeth/wizard_faucet.go @@ -38,7 +38,7 @@ func (w *wizard) deployFaucet() { infos, err := checkFaucet(client, w.network) if err != nil { infos = &faucetInfos{ - node: &nodeInfos{portFull: 30303, peersTotal: 25}, + node: &nodeInfos{port: 30303, peersTotal: 25}, port: 80, host: client.server, amount: 1, @@ -113,8 +113,8 @@ func (w *wizard) deployFaucet() { } // Figure out which port to listen on fmt.Println() - fmt.Printf("Which TCP/UDP port should the light client listen on? (default = %d)\n", infos.node.portFull) - infos.node.portFull = w.readDefaultInt(infos.node.portFull) + fmt.Printf("Which TCP/UDP port should the light client listen on? (default = %d)\n", infos.node.port) + infos.node.port = w.readDefaultInt(infos.node.port) // Set a proper name to report on the stats page fmt.Println() @@ -168,7 +168,7 @@ func (w *wizard) deployFaucet() { fmt.Printf("Should the faucet be built from scratch (y/n)? (default = no)\n") nocache = w.readDefaultString("n") != "n" } - if out, err := deployFaucet(client, w.network, w.conf.bootLight, infos, nocache); err != nil { + if out, err := deployFaucet(client, w.network, w.conf.bootnodes, infos, nocache); err != nil { log.Error("Failed to deploy faucet container", "err", err) if len(out) > 0 { fmt.Printf("%s\n", out) diff --git a/cmd/puppeth/wizard_intro.go b/cmd/puppeth/wizard_intro.go index 84998afc9..60aa0f7ff 100644 --- a/cmd/puppeth/wizard_intro.go +++ b/cmd/puppeth/wizard_intro.go @@ -59,15 +59,16 @@ func (w *wizard) run() { fmt.Println() // Make sure we have a good network name to work with fmt.Println() + // Docker accepts hyphens in image names, but doesn't like it for container names if w.network == "" { - fmt.Println("Please specify a network name to administer (no spaces, please)") + fmt.Println("Please specify a network name to administer (no spaces or hyphens, please)") for { w.network = w.readString() - if !strings.Contains(w.network, " ") { + if !strings.Contains(w.network, " ") && !strings.Contains(w.network, "-") { fmt.Printf("\nSweet, you can set this via --network=%s next time!\n\n", w.network) break } - log.Error("I also like to live dangerously, still no spaces") + log.Error("I also like to live dangerously, still no spaces or hyphens") } } log.Info("Administering Ethereum network", "name", w.network) diff --git a/cmd/puppeth/wizard_netstats.go b/cmd/puppeth/wizard_netstats.go index e19180bb1..90bf7ae3c 100644 --- a/cmd/puppeth/wizard_netstats.go +++ b/cmd/puppeth/wizard_netstats.go @@ -37,8 +37,7 @@ func (w *wizard) networkStats() { } // Clear out some previous configs to refill from current scan w.conf.ethstats = "" - w.conf.bootFull = w.conf.bootFull[:0] - w.conf.bootLight = w.conf.bootLight[:0] + w.conf.bootnodes = w.conf.bootnodes[:0] // Iterate over all the specified hosts and check their status var pend sync.WaitGroup @@ -76,8 +75,7 @@ func (w *wizard) gatherStats(server string, pubkey []byte, client *sshClient) *s var ( genesis string ethstats string - bootFull []string - bootLight []string + bootnodes []string ) // Ensure a valid SSH connection to the remote server logger := log.New("server", server) @@ -123,10 +121,7 @@ func (w *wizard) gatherStats(server string, pubkey []byte, client *sshClient) *s stat.services["bootnode"] = infos.Report() genesis = string(infos.genesis) - bootFull = append(bootFull, infos.enodeFull) - if infos.enodeLight != "" { - bootLight = append(bootLight, infos.enodeLight) - } + bootnodes = append(bootnodes, infos.enode) } logger.Debug("Checking for sealnode availability") if infos, err := checkNode(client, w.network, false); err != nil { @@ -184,8 +179,7 @@ func (w *wizard) gatherStats(server string, pubkey []byte, client *sshClient) *s if ethstats != "" { w.conf.ethstats = ethstats } - w.conf.bootFull = append(w.conf.bootFull, bootFull...) - w.conf.bootLight = append(w.conf.bootLight, bootLight...) + w.conf.bootnodes = append(w.conf.bootnodes, bootnodes...) return stat } diff --git a/cmd/puppeth/wizard_node.go b/cmd/puppeth/wizard_node.go index 097e2e41a..a60948bc6 100644 --- a/cmd/puppeth/wizard_node.go +++ b/cmd/puppeth/wizard_node.go @@ -48,9 +48,9 @@ func (w *wizard) deployNode(boot bool) { infos, err := checkNode(client, w.network, boot) if err != nil { if boot { - infos = &nodeInfos{portFull: 30303, peersTotal: 512, peersLight: 256} + infos = &nodeInfos{port: 30303, peersTotal: 512, peersLight: 256} } else { - infos = &nodeInfos{portFull: 30303, peersTotal: 50, peersLight: 0, gasTarget: 4.7, gasPrice: 18} + infos = &nodeInfos{port: 30303, peersTotal: 50, peersLight: 0, gasTarget: 4.7, gasPrice: 18} } } existed := err == nil @@ -79,8 +79,8 @@ func (w *wizard) deployNode(boot bool) { } // Figure out which port to listen on fmt.Println() - fmt.Printf("Which TCP/UDP port to listen on? (default = %d)\n", infos.portFull) - infos.portFull = w.readDefaultInt(infos.portFull) + fmt.Printf("Which TCP/UDP port to listen on? (default = %d)\n", infos.port) + infos.port = w.readDefaultInt(infos.port) // Figure out how many peers to allow (different based on node type) fmt.Println() @@ -163,7 +163,7 @@ func (w *wizard) deployNode(boot bool) { fmt.Printf("Should the node be built from scratch (y/n)? (default = no)\n") nocache = w.readDefaultString("n") != "n" } - if out, err := deployNode(client, w.network, w.conf.bootFull, w.conf.bootLight, infos, nocache); err != nil { + if out, err := deployNode(client, w.network, w.conf.bootnodes, infos, nocache); err != nil { log.Error("Failed to deploy Ethereum node container", "err", err) if len(out) > 0 { fmt.Printf("%s\n", out) diff --git a/cmd/puppeth/wizard_wallet.go b/cmd/puppeth/wizard_wallet.go index 7c3896a17..933cd9ae5 100644 --- a/cmd/puppeth/wizard_wallet.go +++ b/cmd/puppeth/wizard_wallet.go @@ -98,7 +98,7 @@ func (w *wizard) deployWallet() { fmt.Printf("Should the wallet be built from scratch (y/n)? (default = no)\n") nocache = w.readDefaultString("n") != "n" } - if out, err := deployWallet(client, w.network, w.conf.bootFull, infos, nocache); err != nil { + if out, err := deployWallet(client, w.network, w.conf.bootnodes, infos, nocache); err != nil { log.Error("Failed to deploy wallet container", "err", err) if len(out) > 0 { fmt.Printf("%s\n", out) diff --git a/cmd/swarm/run_test.go b/cmd/swarm/run_test.go index ed1502868..594cfa55c 100644 --- a/cmd/swarm/run_test.go +++ b/cmd/swarm/run_test.go @@ -1,4 +1,4 @@ -// Copyright 2016 The go-ethereum Authors +// Copyright 2017 The go-ethereum Authors // This file is part of go-ethereum. // // go-ethereum is free software: you can redistribute it and/or modify diff --git a/cmd/swarm/upload_test.go b/cmd/swarm/upload_test.go index 5656186e1..df7fc216a 100644 --- a/cmd/swarm/upload_test.go +++ b/cmd/swarm/upload_test.go @@ -1,4 +1,4 @@ -// Copyright 2016 The go-ethereum Authors +// Copyright 2017 The go-ethereum Authors // This file is part of go-ethereum. // // go-ethereum is free software: you can redistribute it and/or modify diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 53cdf7861..186d18d8f 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -25,6 +25,7 @@ import ( "os/signal" "runtime" "strings" + "syscall" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" @@ -64,7 +65,7 @@ func StartNode(stack *node.Node) { } go func() { sigc := make(chan os.Signal, 1) - signal.Notify(sigc, os.Interrupt) + signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM) defer signal.Stop(sigc) <-sigc log.Info("Got interrupt, shutting down...") @@ -85,7 +86,7 @@ func ImportChain(chain *core.BlockChain, fn string) error { // If a signal is received, the import will stop at the next batch. interrupt := make(chan os.Signal, 1) stop := make(chan struct{}) - signal.Notify(interrupt, os.Interrupt) + signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) defer signal.Stop(interrupt) defer close(interrupt) go func() { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2a2909ff2..5fd5013f0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -397,6 +397,11 @@ var ( Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", Value: "", } + RPCVirtualHostsFlag = cli.StringFlag{ + Name: "rpcvhosts", + Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", + Value: "localhost", + } RPCApiFlag = cli.StringFlag{ Name: "rpcapi", Usage: "API's offered over the HTTP-RPC interface", @@ -690,6 +695,8 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) { if ctx.GlobalIsSet(RPCApiFlag.Name) { cfg.HTTPModules = splitAndTrim(ctx.GlobalString(RPCApiFlag.Name)) } + + cfg.HTTPVirtualHosts = splitAndTrim(ctx.GlobalString(RPCVirtualHostsFlag.Name)) } // setWS creates the WebSocket RPC listener interface string from the set diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go index e69b57d69..971b1c0ab 100644 --- a/cmd/wnode/main.go +++ b/cmd/wnode/main.go @@ -43,7 +43,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/whisper/mailserver" - whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" + whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" "golang.org/x/crypto/pbkdf2" ) @@ -61,15 +61,17 @@ var ( // encryption var ( - symKey []byte - pub *ecdsa.PublicKey - asymKey *ecdsa.PrivateKey - nodeid *ecdsa.PrivateKey - topic whisper.TopicType - asymKeyID string - filterID string - symPass string - msPassword string + symKey []byte + pub *ecdsa.PublicKey + asymKey *ecdsa.PrivateKey + nodeid *ecdsa.PrivateKey + topic whisper.TopicType + + asymKeyID string + asymFilterID string + symFilterID string + symPass string + msPassword string ) // cmd arguments @@ -263,7 +265,7 @@ func initialize() { Config: p2p.Config{ PrivateKey: nodeid, MaxPeers: maxPeers, - Name: common.MakeName("wnode", "5.0"), + Name: common.MakeName("wnode", "6.0"), Protocols: shh.Protocols(), ListenAddr: *argIP, NAT: nat.Any(), @@ -363,13 +365,22 @@ func configureNode() { } } - filter := whisper.Filter{ + symFilter := whisper.Filter{ KeySym: symKey, + Topics: [][]byte{topic[:]}, + AllowP2P: p2pAccept, + } + symFilterID, err = shh.Subscribe(&symFilter) + if err != nil { + utils.Fatalf("Failed to install filter: %s", err) + } + + asymFilter := whisper.Filter{ KeyAsym: asymKey, Topics: [][]byte{topic[:]}, AllowP2P: p2pAccept, } - filterID, err = shh.Subscribe(&filter) + asymFilterID, err = shh.Subscribe(&asymFilter) if err != nil { utils.Fatalf("Failed to install filter: %s", err) } @@ -522,9 +533,14 @@ func sendMsg(payload []byte) common.Hash { } func messageLoop() { - f := shh.GetFilter(filterID) - if f == nil { - utils.Fatalf("filter is not installed") + sf := shh.GetFilter(symFilterID) + if sf == nil { + utils.Fatalf("symmetric filter is not installed") + } + + af := shh.GetFilter(asymFilterID) + if af == nil { + utils.Fatalf("asymmetric filter is not installed") } ticker := time.NewTicker(time.Millisecond * 50) @@ -532,7 +548,16 @@ func messageLoop() { for { select { case <-ticker.C: - messages := f.Retrieve() + messages := sf.Retrieve() + for _, msg := range messages { + if *fileExMode || len(msg.Payload) > 2048 { + writeMessageToFile(*argSaveDir, msg) + } else { + printMessageInfo(msg) + } + } + + messages = af.Retrieve() for _, msg := range messages { if *fileExMode || len(msg.Payload) > 2048 { writeMessageToFile(*argSaveDir, msg) @@ -631,7 +656,7 @@ func requestExpiredMessagesLoop() { params.PoW = *argServerPoW params.Payload = data params.KeySym = key - params.Src = nodeid + params.Src = asymKey params.WorkTime = 5 msg, err := whisper.NewSentMessage(¶ms) |