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
bc0769e3
Commit
bc0769e3
authored
Oct 02, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipfs + ipns mounts with flags + config
parent
068c0375
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
44 deletions
+60
-44
cmd/ipfs/init.go
cmd/ipfs/init.go
+6
-0
cmd/ipfs/mount_unix.go
cmd/ipfs/mount_unix.go
+47
-44
config/config.go
config/config.go
+7
-0
No files found.
cmd/ipfs/init.go
View file @
bc0769e3
...
...
@@ -92,6 +92,12 @@ func initCmd(c *commander.Command, inp []string) error {
API
:
"/ip4/127.0.0.1/tcp/5001"
,
}
// setup the node mount points.
cfg
.
Mounts
=
config
.
Mounts
{
IPFS
:
"/ipfs"
,
IPNS
:
"/ipns"
,
}
nbits
,
ok
:=
c
.
Flag
.
Lookup
(
"b"
)
.
Value
.
Get
()
.
(
int
)
if
!
ok
{
return
errors
.
New
(
"failed to get bits flag"
)
...
...
cmd/ipfs/mount_unix.go
View file @
bc0769e3
...
...
@@ -3,14 +3,12 @@
package
main
import
(
"errors"
"fmt"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
"github.com/jbenet/go-ipfs/
daemon
"
core
"github.com/jbenet/go-ipfs/
core
"
ipns
"github.com/jbenet/go-ipfs/fuse/ipns"
rofs
"github.com/jbenet/go-ipfs/fuse/readonly"
)
...
...
@@ -30,59 +28,64 @@ var cmdIpfsMount = &commander.Command{
}
func
init
()
{
cmdIpfsMount
.
Flag
.
String
(
"f"
,
""
,
"specify a mountpoint for ipfs"
)
cmdIpfsMount
.
Flag
.
String
(
"n"
,
""
,
"specify a mountpoint for ipns"
)
cmdIpfsMount
.
Flag
.
String
(
"f"
,
"/ipfs"
,
"specify a mountpoint for ipfs"
)
}
func
mountCmd
(
c
*
commander
.
Command
,
inp
[]
string
)
error
{
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
fmt
.
Println
(
"Couldnt get config dir"
)
return
err
}
n
,
err
:=
localNode
(
conf
,
true
)
cc
,
err
:=
setupCmdContext
(
c
,
true
)
if
err
!=
nil
{
fmt
.
Println
(
"Local node creation failed."
)
return
err
}
defer
cc
.
daemon
.
Close
()
// launch the API RPC endpoint.
if
n
.
Config
.
Addresses
.
API
==
""
{
return
errors
.
New
(
"no config.RPCAddress endpoint supplied"
)
// update fsdir with flag.
fsdir
:=
cc
.
node
.
Config
.
Mounts
.
IPFS
if
val
,
ok
:=
c
.
Flag
.
Lookup
(
"f"
)
.
Value
.
Get
()
.
(
string
);
ok
&&
val
!=
""
{
fsdir
=
val
}
fsdone
:=
mountIpfs
(
cc
.
node
,
fsdir
)
maddr
,
err
:=
ma
.
NewMultiaddr
(
n
.
Config
.
Addresses
.
API
)
if
err
!=
nil
{
return
err
// get default mount points
nsdir
:=
cc
.
node
.
Config
.
Mounts
.
IPNS
if
val
,
ok
:=
c
.
Flag
.
Lookup
(
"n"
)
.
Value
.
Get
()
.
(
string
);
ok
&&
val
!=
""
{
nsdir
=
val
}
nsdone
:=
mountIpns
(
cc
.
node
,
nsdir
,
fsdir
)
dl
,
err
:=
daemon
.
NewDaemonListener
(
n
,
maddr
,
conf
)
if
err
!=
nil
{
fmt
.
Println
(
"Failed to create daemon listener."
)
return
err
}
go
dl
.
Listen
()
defer
dl
.
Close
()
mp
:=
c
.
Flag
.
Lookup
(
"f"
)
.
Value
.
Get
()
.
(
string
)
fmt
.
Printf
(
"Mounting at %s
\n
"
,
mp
)
var
ipnsDone
chan
struct
{}
ns
,
ok
:=
c
.
Flag
.
Lookup
(
"n"
)
.
Value
.
Get
()
.
(
string
)
if
ok
&&
ns
!=
""
{
ipnsDone
=
make
(
chan
struct
{})
go
func
()
{
err
=
ipns
.
Mount
(
n
,
ns
,
mp
)
if
err
!=
nil
{
fmt
.
Printf
(
"Error mounting ipns: %s
\n
"
,
err
)
}
ipnsDone
<-
struct
{}{}
}()
}
// wait till mounts are done.
err1
:=
<-
fsdone
err2
:=
<-
nsdone
err
=
rofs
.
Mount
(
n
,
mp
)
if
ipnsDone
!=
nil
{
<-
ipnsDone
if
err1
!=
nil
{
return
err1
}
return
err
return
err2
}
func
mountIpfs
(
node
*
core
.
IpfsNode
,
fsdir
string
)
<-
chan
error
{
done
:=
make
(
chan
error
)
fmt
.
Printf
(
"mounting ipfs at %s
\n
"
,
fsdir
)
go
func
()
{
err
:=
rofs
.
Mount
(
node
,
fsdir
)
done
<-
err
close
(
done
)
}()
return
done
}
func
mountIpns
(
node
*
core
.
IpfsNode
,
nsdir
,
fsdir
string
)
<-
chan
error
{
done
:=
make
(
chan
error
)
fmt
.
Printf
(
"mounting ipns at %s
\n
"
,
nsdir
)
go
func
()
{
err
:=
ipns
.
Mount
(
node
,
nsdir
,
fsdir
)
done
<-
err
close
(
done
)
}()
return
done
}
config/config.go
View file @
bc0769e3
...
...
@@ -29,6 +29,12 @@ type Addresses struct {
API
string
// address for the local API (RPC)
}
// Mounts stores the (string) mount points
type
Mounts
struct
{
IPFS
string
IPNS
string
}
// BootstrapPeer is a peer used to bootstrap the network.
type
BootstrapPeer
struct
{
Address
string
...
...
@@ -40,6 +46,7 @@ type Config struct {
Identity
Identity
// local node's peer identity
Datastore
Datastore
// local node's storage
Addresses
Addresses
// local node's addresses
Mounts
Mounts
// local node's mount points
Bootstrap
[]
*
BootstrapPeer
// local nodes's bootstrap peers
}
...
...
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