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
a7d1fd42
Commit
a7d1fd42
authored
Nov 18, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating daemon addr output
parent
458afe3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
20 deletions
+26
-20
cmd/ipfs/daemon.go
cmd/ipfs/daemon.go
+25
-19
test/lib/test-lib.sh
test/lib/test-lib.sh
+1
-1
No files found.
cmd/ipfs/daemon.go
View file @
a7d1fd42
...
...
@@ -21,6 +21,8 @@ const (
mountKwd
=
"mount"
ipfsMountKwd
=
"mount-ipfs"
ipnsMountKwd
=
"mount-ipns"
// apiAddrKwd = "address-api"
// swarmAddrKwd = "address-swarm"
)
var
daemonCmd
=
&
cmds
.
Command
{
...
...
@@ -40,6 +42,10 @@ the daemon.
cmds
.
BoolOption
(
mountKwd
,
"Mounts IPFS to the filesystem"
),
cmds
.
StringOption
(
ipfsMountKwd
,
"Path to the mountpoint for IPFS (if using --mount)"
),
cmds
.
StringOption
(
ipnsMountKwd
,
"Path to the mountpoint for IPNS (if using --mount)"
),
// TODO: add way to override addresses. tricky part: updating the config if also --init.
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
// cmds.StringOption(swarmAddrKwd, "Address for the swarm socket (overrides config)"),
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{},
Run
:
daemonFunc
,
...
...
@@ -86,19 +92,16 @@ func daemonFunc(req cmds.Request) (interface{}, error) {
}
defer
lock
.
Close
()
// make sure we construct online node.
// OK!!! Now we're ready to construct the node.
// make sure we construct an online node.
ctx
.
Online
=
true
node
,
err
:=
ctx
.
GetNode
()
if
err
!=
nil
{
return
nil
,
err
}
addr
,
err
:=
ma
.
NewMultiaddr
(
cfg
.
Addresses
.
API
)
if
err
!=
nil
{
return
nil
,
err
}
_
,
host
,
err
:=
manet
.
DialArgs
(
addr
)
// verify api address is valid multiaddr
apiMaddr
,
err
:=
ma
.
NewMultiaddr
(
cfg
.
Addresses
.
API
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -131,6 +134,17 @@ func daemonFunc(req cmds.Request) (interface{}, error) {
}
}
return
nil
,
listenAndServeAPI
(
node
,
req
,
apiMaddr
)
}
func
listenAndServeAPI
(
node
*
core
.
IpfsNode
,
req
cmds
.
Request
,
addr
ma
.
Multiaddr
)
error
{
_
,
host
,
err
:=
manet
.
DialArgs
(
addr
)
if
err
!=
nil
{
return
err
}
server
:=
manners
.
NewServer
()
mux
:=
http
.
NewServeMux
()
cmdHandler
:=
cmdsHttp
.
NewHandler
(
*
req
.
Context
(),
commands
.
Root
)
mux
.
Handle
(
cmdsHttp
.
ApiPath
+
"/"
,
cmdHandler
)
...
...
@@ -138,15 +152,6 @@ func daemonFunc(req cmds.Request) (interface{}, error) {
ifpsHandler
:=
&
ipfsHandler
{
node
}
mux
.
Handle
(
"/ipfs/"
,
ifpsHandler
)
err
=
listenAndServe
(
node
,
mux
,
host
)
return
nil
,
err
}
func
listenAndServe
(
node
*
core
.
IpfsNode
,
mux
*
http
.
ServeMux
,
host
string
)
error
{
fmt
.
Printf
(
"API server listening on '%s'
\n
"
,
host
)
s
:=
manners
.
NewServer
()
done
:=
make
(
chan
struct
{},
1
)
defer
func
()
{
done
<-
struct
{}{}
...
...
@@ -160,11 +165,12 @@ func listenAndServe(node *core.IpfsNode, mux *http.ServeMux, host string) error
return
}
log
.
Info
(
"terminating daemon at %s..."
,
host
)
s
.
Shutdown
<-
true
log
.
Info
(
"terminating daemon at %s..."
,
addr
)
s
erver
.
Shutdown
<-
true
}()
if
err
:=
s
.
ListenAndServe
(
host
,
mux
);
err
!=
nil
{
fmt
.
Printf
(
"daemon listening on %s
\n
"
,
addr
)
if
err
:=
server
.
ListenAndServe
(
host
,
mux
);
err
!=
nil
{
return
err
}
...
...
test/lib/test-lib.sh
View file @
a7d1fd42
...
...
@@ -58,7 +58,7 @@ test_launch_ipfs_mount() {
test_expect_success FUSE
"'ipfs daemon' output looks good"
'
IPFS_PID=$! &&
echo "
API server
listening on
'
\'
'
127.0.0.1
:5001'
\'
'
" >expected &&
echo "
daemon
listening on
/ip4/
127.0.0.1
/tcp/5001
" >expected &&
test_cmp_repeat_10_sec expected actual
'
...
...
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