Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
80a927f2
Commit
80a927f2
authored
Sep 26, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #121 from jbenet/feat/addrs-in-config
config: rename addresses
parents
671b0956
303ebd89
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
28 deletions
+31
-28
cmd/ipfs/init.go
cmd/ipfs/init.go
+8
-7
cmd/ipfs/mount_unix.go
cmd/ipfs/mount_unix.go
+3
-3
config/config.go
config/config.go
+16
-14
core/core.go
core/core.go
+4
-4
No files found.
cmd/ipfs/init.go
View file @
80a927f2
...
...
@@ -69,12 +69,13 @@ func initCmd(c *commander.Command, inp []string) error {
cfg
.
Datastore
.
Path
=
dspath
cfg
.
Datastore
.
Type
=
"leveldb"
cfg
.
Identity
=
new
(
config
.
Identity
)
// This needs thought
cfg
.
Identity
.
Address
=
"/ip4/127.0.0.1/tcp/5001"
cfg
.
Identity
=
config
.
Identity
{}
// local RPC endpoint
cfg
.
RPCAddress
=
"/ip4/127.0.0.1/tcp/4001"
// setup the node addresses.
cfg
.
Addresses
=
config
.
Addresses
{
Swarm
:
"/ip4/0.0.0.0/tcp/4001"
,
API
:
"/ip4/127.0.0.1/tcp/5001"
,
}
nbits
,
ok
:=
c
.
Flag
.
Lookup
(
"b"
)
.
Value
.
Get
()
.
(
int
)
if
!
ok
{
...
...
@@ -105,8 +106,8 @@ func initCmd(c *commander.Command, inp []string) error {
cfg
.
Identity
.
PeerID
=
id
.
Pretty
()
// Use these hardcoded bootstrap peers for now.
cfg
.
Peers
=
[]
*
config
.
Saved
Peer
{
&
config
.
Saved
Peer
{
cfg
.
Bootstrap
=
[]
*
config
.
Bootstrap
Peer
{
&
config
.
Bootstrap
Peer
{
// mars.i.ipfs.io
PeerID
:
"QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
,
Address
:
"/ip4/104.131.131.82/tcp/4001"
,
...
...
cmd/ipfs/mount_unix.go
View file @
80a927f2
...
...
@@ -44,12 +44,12 @@ func mountCmd(c *commander.Command, inp []string) error {
return
err
}
// launch the RPC endpoint.
if
n
.
Config
.
RPC
Address
==
""
{
// launch the
API
RPC endpoint.
if
n
.
Config
.
Address
es
.
API
==
""
{
return
errors
.
New
(
"no config.RPCAddress endpoint supplied"
)
}
maddr
,
err
:=
ma
.
NewMultiaddr
(
n
.
Config
.
RPC
Address
)
maddr
,
err
:=
ma
.
NewMultiaddr
(
n
.
Config
.
Address
es
.
API
)
if
err
!=
nil
{
return
err
}
...
...
config/config.go
View file @
80a927f2
...
...
@@ -14,7 +14,6 @@ import (
type
Identity
struct
{
PeerID
string
PrivKey
string
Address
string
}
// Datastore tracks the configuration of the datastore.
...
...
@@ -23,30 +22,33 @@ type Datastore struct {
Path
string
}
type
SavedPeer
struct
{
// Addresses stores the (string) multiaddr addresses for the node.
type
Addresses
struct
{
Swarm
string
// address for the swarm network
API
string
// address for the local API (RPC)
}
// BootstrapPeer is a peer used to bootstrap the network.
type
BootstrapPeer
struct
{
Address
string
PeerID
string
// until multiaddr supports ipfs, use another field.
}
// Config is used to load IPFS config files.
type
Config
struct
{
Identity
*
Identity
// local node's peer identity
Datastore
Datastore
// local node's storage
RPC
Address
string
// local node's
RPC
address
Peers
[]
*
Saved
Peer
// local nodes's bootstrap peers
Identity
Identity
// local node's peer identity
Datastore
Datastore
// local node's storage
Address
es
Addresses
// local node's address
es
Bootstrap
[]
*
Bootstrap
Peer
// local nodes's bootstrap peers
}
// DefaultPathRoot is the default parth for the IPFS node's root dir.
const
DefaultPathRoot
=
"~/.go-ipfs"
// DefaultConfigFilePath points to the ipfs node config file.
const
DefaultConfigFilePath
=
DefaultPathRoot
+
"/config"
const
DefaultConfigFile
=
`{
"identity": {},
"datastore": {
"type": "leveldb",
"path": "`
+
DefaultPathRoot
+
`/datastore"
}
}
`
// DecodePrivateKey is a helper to decode the users PrivateKey
func
(
i
*
Identity
)
DecodePrivateKey
(
passphrase
string
)
(
crypto
.
PrivateKey
,
error
)
{
pkb
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
i
.
PrivKey
)
if
err
!=
nil
{
...
...
core/core.go
View file @
80a927f2
...
...
@@ -148,7 +148,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
}
func
initIdentity
(
cfg
*
config
.
Config
)
(
*
peer
.
Peer
,
error
)
{
if
cfg
.
Identity
==
nil
{
if
cfg
.
Identity
.
PeerID
==
""
{
return
nil
,
errors
.
New
(
"Identity was not set in config (was ipfs init run?)"
)
}
...
...
@@ -158,8 +158,8 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
// address is optional
var
addresses
[]
*
ma
.
Multiaddr
if
len
(
cfg
.
Identity
.
Address
)
>
0
{
maddr
,
err
:=
ma
.
NewMultiaddr
(
cfg
.
Identity
.
Address
)
if
len
(
cfg
.
Addresses
.
Swarm
)
>
0
{
maddr
,
err
:=
ma
.
NewMultiaddr
(
cfg
.
Addresses
.
Swarm
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -186,7 +186,7 @@ func initIdentity(cfg *config.Config) (*peer.Peer, error) {
}
func
initConnections
(
ctx
context
.
Context
,
cfg
*
config
.
Config
,
pstore
peer
.
Peerstore
,
route
*
dht
.
IpfsDHT
)
{
for
_
,
p
:=
range
cfg
.
Peers
{
for
_
,
p
:=
range
cfg
.
Bootstrap
{
if
p
.
PeerID
==
""
{
u
.
PErr
(
"error: peer does not include PeerID. %v
\n
"
,
p
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment