Skip to content

Commit

Permalink
daemon: allow setting listen addr
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jul 8, 2019
1 parent cdca2ff commit f9b5343
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 1 addition & 3 deletions cli/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var netPeers = &cli.Command{
},
}


var netConnect = &cli.Command{
Name: "connect",
Usage: "Connect to a peer",
Expand All @@ -57,7 +56,6 @@ var netConnect = &cli.Command{
},
}


// parseAddresses is a function that takes in a slice of string peer addresses
// (multiaddr + peerid) and returns a slice of properly constructed peers
func parseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) {
Expand Down Expand Up @@ -133,4 +131,4 @@ func resolveAddresses(ctx context.Context, addrs []string) ([]ma.Multiaddr, erro
}

return maddrs, nil
}
}
8 changes: 7 additions & 1 deletion daemon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
var Cmd = &cli.Command{
Name: "daemon",
Usage: "Start a lotus daemon process",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "api",
Value: ":1234",
},
},
Action: func(cctx *cli.Context) error {
ctx := context.Background()

Expand All @@ -26,6 +32,6 @@ var Cmd = &cli.Command{
return err
}

return serveRPC(api)
return serveRPC(api, cctx.String("api"))
},
}
4 changes: 2 additions & 2 deletions daemon/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
)

func serveRPC(api api.API) error {
func serveRPC(api api.API, addr string) error {
rpcServer := jsonrpc.NewServer()
rpcServer.Register("Filecoin", api)
http.Handle("/rpc/v0", rpcServer)
return http.ListenAndServe(":1234", http.DefaultServeMux)
return http.ListenAndServe(addr, http.DefaultServeMux)
}

0 comments on commit f9b5343

Please sign in to comment.