From e4941069effd36eeef39155bf6b43e697cbac290 Mon Sep 17 00:00:00 2001
From: verokarhu <andreas.metsala@gmail.com>
Date: Wed, 6 Aug 2014 20:10:24 +0300
Subject: [PATCH] hostname flag to serve command

---
 cmd/ipfs/serve.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cmd/ipfs/serve.go b/cmd/ipfs/serve.go
index c80a4fd8..4815f9e6 100644
--- a/cmd/ipfs/serve.go
+++ b/cmd/ipfs/serve.go
@@ -19,6 +19,7 @@ var cmdIpfsServe = &commander.Command{
 
 func init() {
 	cmdIpfsServe.Flag.Uint("port", 80, "Port number")
+	cmdIpfsServe.Flag.String("hostname", "localhost", "Hostname")
 }
 
 func serveCmd(c *commander.Command, _ []string) error {
@@ -27,12 +28,14 @@ func serveCmd(c *commander.Command, _ []string) error {
 		return errors.New("invalid port number")
 	}
 
+	hostname := c.Flag.Lookup("hostname").Value.Get().(string)
+
 	n, err := localNode()
 	if err != nil {
 		return err
 	}
 
-	address := "127.0.0.1" + ":" + strconv.FormatUint(uint64(port), 10)
+	address := hostname + ":" + strconv.FormatUint(uint64(port), 10)
 	fmt.Printf("Serving on %s\n", address)
 
 	return h.Serve(address, n)
-- 
GitLab