@cryptotaxi247 / kubo / commits / df1e24d84

go-ipfs-config: feat(config) add GCR config section

Brian Tiger Chow committed Feb 2, 2015 at 01:39 UTC df1e24d846a3ac8a32a646b1856698a6d0f725dd
3 files changed +40
config/config.go
+1
@@ -24,6 +24,7 @@ type Config struct {
24 Bootstrap []string // local nodes's bootstrap peer addresses
25 Tour Tour // local node's tour position
26 Gateway Gateway // local node's gateway server options
27 + GCR GCR // local node's routing servers (if GCR enabled)
28 Log Log
29 }
30
config/gcr_servers.go new
+33
@@ -0,0 +1,33 @@
1 +package config
2 +
3 +import "github.com/jbenet/go-ipfs/util/ipfsaddr"
4 +
5 +// TODO replace with final servers before merge
6 +
7 +type GCR struct {
8 + Servers []string
9 +}
10 +
11 +var DefaultGCRServers = []string{
12 + "/ip4/104.236.70.34/tcp/4001/QmaWJw5mcWkCThPtC7hVq28e3WbwLHnWF8HbMNJrRDybE4",
13 + "/ip4/128.199.72.111/tcp/4001/Qmd2cSiZUt7vhiuTmqBB7XWbkuFR8KMLiEuQssjyNXyaZT",
14 +}
15 +
16 +func initGCR() (*GCR, error) {
17 + // TODO perform validation
18 + return &GCR{
19 + Servers: DefaultGCRServers,
20 + }, nil
21 +}
22 +
23 +func (gcr *GCR) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) {
24 + var addrs []ipfsaddr.IPFSAddr
25 + for _, server := range gcr.Servers {
26 + addr, err := ipfsaddr.ParseString(server)
27 + if err != nil {
28 + return nil, err
29 + }
30 + addrs = append(addrs, addr)
31 + }
32 + return addrs, nil
33 +}
config/init.go
+6
@@ -26,6 +26,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
26 return nil, err
27 }
28
29 + gcr, err := initGCR()
30 + if err != nil {
31 + return nil, err
32 + }
33 +
34 conf := &Config{
35
36 // setup the node's default addresses.
@@ -40,6 +45,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
45 },
46
47 Bootstrap: BootstrapPeerStrings(bootstrapPeers),
48 + GCR: *gcr,
49 Datastore: *ds,
50 Identity: identity,
51 Log: Log{