hostname flag to serve command
verokarhu committed
Aug 6, 2014 at 20:10 UTC
e4941069effd36eeef39155bf6b43e697cbac290
1 file changed
+4
-1
cmd/ipfs/serve.go
+4
-1
@@ -19,6 +19,7 @@ var cmdIpfsServe = &commander.Command{
19
20
func init() {
21
cmdIpfsServe.Flag.Uint("port", 80, "Port number")
22
+ cmdIpfsServe.Flag.String("hostname", "localhost", "Hostname")
23
}
24
25
func serveCmd(c *commander.Command, _ []string) error {
@@ -27,12 +28,14 @@ func serveCmd(c *commander.Command, _ []string) error {
28
return errors.New("invalid port number")
29
}
30
31
+ hostname := c.Flag.Lookup("hostname").Value.Get().(string)
32
+
33
n, err := localNode()
34
if err != nil {
35
return err
36
}
37
35
- address := "127.0.0.1" + ":" + strconv.FormatUint(uint64(port), 10)
38
+ address := hostname + ":" + strconv.FormatUint(uint64(port), 10)
39
fmt.Printf("Serving on %s\n", address)
40
41
return h.Serve(address, n)