1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-01 02:30:39 +08:00

hostname flag to serve command

This commit is contained in:
verokarhu
2014-08-06 20:10:24 +03:00
parent 8831427c82
commit e4941069ef

View File

@ -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)