Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
bc0769e3
提交
bc0769e3
authored
10月 02, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ipfs + ipns mounts with flags + config
上级
068c0375
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
60 行增加
和
44 行删除
+60
-44
init.go
cmd/ipfs/init.go
+6
-0
mount_unix.go
cmd/ipfs/mount_unix.go
+47
-44
config.go
config/config.go
+7
-0
没有找到文件。
cmd/ipfs/init.go
浏览文件 @
bc0769e3
...
@@ -92,6 +92,12 @@ func initCmd(c *commander.Command, inp []string) error {
...
@@ -92,6 +92,12 @@ func initCmd(c *commander.Command, inp []string) error {
API
:
"/ip4/127.0.0.1/tcp/5001"
,
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
)
nbits
,
ok
:=
c
.
Flag
.
Lookup
(
"b"
)
.
Value
.
Get
()
.
(
int
)
if
!
ok
{
if
!
ok
{
return
errors
.
New
(
"failed to get bits flag"
)
return
errors
.
New
(
"failed to get bits flag"
)
...
...
cmd/ipfs/mount_unix.go
浏览文件 @
bc0769e3
...
@@ -3,14 +3,12 @@
...
@@ -3,14 +3,12 @@
package
main
package
main
import
(
import
(
"errors"
"fmt"
"fmt"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
"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"
ipns
"github.com/jbenet/go-ipfs/fuse/ipns"
rofs
"github.com/jbenet/go-ipfs/fuse/readonly"
rofs
"github.com/jbenet/go-ipfs/fuse/readonly"
)
)
...
@@ -30,59 +28,64 @@ var cmdIpfsMount = &commander.Command{
...
@@ -30,59 +28,64 @@ var cmdIpfsMount = &commander.Command{
}
}
func
init
()
{
func
init
()
{
cmdIpfsMount
.
Flag
.
String
(
"f"
,
""
,
"specify a mountpoint for ipfs"
)
cmdIpfsMount
.
Flag
.
String
(
"n"
,
""
,
"specify a mountpoint for ipns"
)
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
{
func
mountCmd
(
c
*
commander
.
Command
,
inp
[]
string
)
error
{
conf
,
err
:=
getConfigDir
(
c
.
Parent
)
if
err
!=
nil
{
cc
,
err
:=
setupCmdContext
(
c
,
true
)
fmt
.
Println
(
"Couldnt get config dir"
)
return
err
}
n
,
err
:=
localNode
(
conf
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"Local node creation failed."
)
return
err
return
err
}
}
defer
cc
.
daemon
.
Close
()
// launch the API RPC endpoint.
// update fsdir with flag.
if
n
.
Config
.
Addresses
.
API
==
""
{
fsdir
:=
cc
.
node
.
Config
.
Mounts
.
IPFS
return
errors
.
New
(
"no config.RPCAddress endpoint supplied"
)
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
)
// get default mount points
if
err
!=
nil
{
nsdir
:=
cc
.
node
.
Config
.
Mounts
.
IPNS
return
err
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
)
// wait till mounts are done.
if
err
!=
nil
{
err1
:=
<-
fsdone
fmt
.
Println
(
"Failed to create daemon listener."
)
err2
:=
<-
nsdone
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
{}{}
}()
}
err
=
rofs
.
Mount
(
n
,
mp
)
if
err1
!=
nil
{
if
ipnsDone
!=
nil
{
return
err1
<-
ipnsDone
}
}
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
浏览文件 @
bc0769e3
...
@@ -29,6 +29,12 @@ type Addresses struct {
...
@@ -29,6 +29,12 @@ type Addresses struct {
API
string
// address for the local API (RPC)
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.
// BootstrapPeer is a peer used to bootstrap the network.
type
BootstrapPeer
struct
{
type
BootstrapPeer
struct
{
Address
string
Address
string
...
@@ -40,6 +46,7 @@ type Config struct {
...
@@ -40,6 +46,7 @@ type Config struct {
Identity
Identity
// local node's peer identity
Identity
Identity
// local node's peer identity
Datastore
Datastore
// local node's storage
Datastore
Datastore
// local node's storage
Addresses
Addresses
// local node's addresses
Addresses
Addresses
// local node's addresses
Mounts
Mounts
// local node's mount points
Bootstrap
[]
*
BootstrapPeer
// local nodes's bootstrap peers
Bootstrap
[]
*
BootstrapPeer
// local nodes's bootstrap peers
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论