package bootstrap import ( "cryptic-net/nebula" "fmt" "net" ) // NebulaHost describes the nebula configuration of a Host which is relevant for // other hosts to know. type NebulaHost struct { CertPEM string `yaml:"cert_pem"` PublicAddr string `yaml:"public_addr,omitempty"` } // GarageHost describes a single garage instance in the GarageHost. type GarageHostInstance struct { ID string `yaml:"id"` RPCPort int `yaml:"rpc_port"` S3APIPort int `yaml:"s3_api_port"` } // GarageHost describes the garage configuration of a Host which is relevant for // other hosts to know. type GarageHost struct { Instances []GarageHostInstance `yaml:"instances"` } // Host consolidates all information about a single host from the bootstrap // file. type Host struct { Name string `yaml:"name"` Nebula NebulaHost `yaml:"nebula"` Garage *GarageHost `yaml:"garage,omitempty"` } // IP returns the IP address encoded in the Host's nebula certificate, or panics // if there is an error. func (h Host) IP() net.IP { ip, err := nebula.IPFromHostCertPEM(h.Nebula.CertPEM) if err != nil { panic(fmt.Errorf("could not parse IP out of cert for host %q: %w", h.Name, err)) } return ip }