Commit 86455b81 authored by Brian Tiger Chow's avatar Brian Tiger Chow

feat(config) add GCR config section

parent eeae42b5
......@@ -24,6 +24,7 @@ type Config struct {
Bootstrap []string // local nodes's bootstrap peer addresses
Tour Tour // local node's tour position
Gateway Gateway // local node's gateway server options
GCR GCR // local node's routing servers (if GCR enabled)
Log Log
}
......
package config
import "github.com/jbenet/go-ipfs/util/ipfsaddr"
// TODO replace with final servers before merge
type GCR struct {
Servers []string
}
var DefaultGCRServers = []string{
"/ip4/104.236.70.34/tcp/4001/QmaWJw5mcWkCThPtC7hVq28e3WbwLHnWF8HbMNJrRDybE4",
"/ip4/128.199.72.111/tcp/4001/Qmd2cSiZUt7vhiuTmqBB7XWbkuFR8KMLiEuQssjyNXyaZT",
}
func initGCR() (*GCR, error) {
// TODO perform validation
return &GCR{
Servers: DefaultGCRServers,
}, nil
}
func (gcr *GCR) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) {
var addrs []ipfsaddr.IPFSAddr
for _, server := range gcr.Servers {
addr, err := ipfsaddr.ParseString(server)
if err != nil {
return nil, err
}
addrs = append(addrs, addr)
}
return addrs, nil
}
......@@ -26,6 +26,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
return nil, err
}
gcr, err := initGCR()
if err != nil {
return nil, err
}
conf := &Config{
// setup the node's default addresses.
......@@ -40,6 +45,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
},
Bootstrap: BootstrapPeerStrings(bootstrapPeers),
GCR: *gcr,
Datastore: *ds,
Identity: identity,
Log: Log{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment