mirror of
https://github.com/tendermint/tendermint.git
synced 2026-04-28 03:16:58 +00:00
add 'provider' field to the infrastructure data file to disable ip range check
This commit is contained in:
@@ -11,6 +11,11 @@ import (
|
||||
// infrastructure that is to be used for running a testnet.
|
||||
type InfrastructureData struct {
|
||||
|
||||
// Provider is the name of infrastructure provider backing the testnet.
|
||||
// For example, 'docker' if it is running locally in a docker network or
|
||||
// 'digital-ocean', 'aws', 'google', etc. if it is from a cloud provider.
|
||||
Provider string `json:"provider"`
|
||||
|
||||
// Instances is a map of all of the machine instances on which to run
|
||||
// processes for a testnet.
|
||||
// The key of the map is the name of the instance, which each must correspond
|
||||
@@ -25,9 +30,9 @@ type InstanceData struct {
|
||||
}
|
||||
|
||||
func NewDockerInfrastructureData(m Manifest) (InfrastructureData, error) {
|
||||
netAddress := networkIPv4
|
||||
netAddress := dockerIPv4CIDR
|
||||
if m.IPv6 {
|
||||
netAddress = networkIPv6
|
||||
netAddress = dockerIPv6CIDR
|
||||
}
|
||||
_, ipNet, err := net.ParseCIDR(netAddress)
|
||||
if err != nil {
|
||||
@@ -35,6 +40,7 @@ func NewDockerInfrastructureData(m Manifest) (InfrastructureData, error) {
|
||||
}
|
||||
ipGen := newIPGenerator(ipNet)
|
||||
ifd := InfrastructureData{
|
||||
Provider: "docker",
|
||||
Instances: make(map[string]InstanceData),
|
||||
}
|
||||
for name := range m.Nodes {
|
||||
|
||||
@@ -21,8 +21,11 @@ import (
|
||||
const (
|
||||
randomSeed int64 = 2308084734268
|
||||
proxyPortFirst uint32 = 5701
|
||||
networkIPv4 = "10.186.73.0/24"
|
||||
networkIPv6 = "fd80:b10c::/48"
|
||||
dockerIPv4CIDR = "10.186.73.0/24"
|
||||
dockerIPv6CIDR = "fd80:b10c::/48"
|
||||
|
||||
globalIPv4CIDR = "0.0.0.0/0"
|
||||
globalIPv6CIDR = "0:0::/0"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -108,9 +111,20 @@ func LoadTestnet(file string, ifd InfrastructureData) (*Testnet, error) {
|
||||
dir := strings.TrimSuffix(file, filepath.Ext(file))
|
||||
|
||||
// Set up resource generators. These must be deterministic.
|
||||
netAddress := networkIPv4
|
||||
if manifest.IPv6 {
|
||||
netAddress = networkIPv6
|
||||
var netAddress string
|
||||
switch ifd.Provider {
|
||||
case "docker":
|
||||
netAddress = dockerIPv4CIDR
|
||||
if manifest.IPv6 {
|
||||
netAddress = dockerIPv6CIDR
|
||||
}
|
||||
default:
|
||||
// TODO(williambanfield): add list of CIDR blocks to the infrastructure
|
||||
// data struct to allow tighter validation of IP addresses.
|
||||
netAddress = globalIPv4CIDR
|
||||
if manifest.IPv6 {
|
||||
netAddress = globalIPv6CIDR
|
||||
}
|
||||
}
|
||||
_, ipNet, err := net.ParseCIDR(netAddress)
|
||||
if err != nil {
|
||||
|
||||
@@ -69,7 +69,6 @@ func NewCLI() *CLI {
|
||||
return errors.New("'--infrastructure-data' must be set when using the 'digital-ocean' infrastructure-type")
|
||||
}
|
||||
ifd, err = e2e.InfrastructureDataFromFile(p)
|
||||
// TODO(williambanfield): add a section that implements the 'digital-ocean' infrastructure-type
|
||||
default:
|
||||
return fmt.Errorf("unknown infrastructure type '%s'", t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user