commit 26284fff03e868bd3d9b7fcd8b4b4eb2b3210716
parent 937154cfaa0f15041f5808132fb6b4a314ad5b53
Author: Matsuda Kenji <info@mtkn.jp>
Date: Fri, 27 Oct 2023 11:43:33 +0900
add address and port options
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/cmd/diskfs/main.go b/cmd/diskfs/main.go
@@ -1,4 +1,4 @@
-// Disk exports the file system on the disk.
+// Diskfs exports the file system on the disk.
// By default it listens to 127.0.0.1:5640.
// You can change the address and port number with -a and -p flags.
package main
diff --git a/cmd/iofs/main.go b/cmd/iofs/main.go
@@ -1,4 +1,6 @@
-// Disk exports the file system on the disk.
+// Iofs exports the file system on the disk.
+// By default it listens to 127.0.0.1:5640.
+// You can change the address and port number with -a and -p flags.
package main
import (
@@ -14,16 +16,18 @@ import (
)
var dFlag = flag.Bool("D", false, "Prints chatty message to the stderr.")
+var aFlag = flag.String("a", "127.0.0.1", "Address the server listens to.")
+var pFlag = flag.Int("p", 5640, "Port number the server listens to.")
func main() {
flag.Parse()
if flag.NArg() != 1 {
- fmt.Fprintf(os.Stderr, "usage: %s [-D] <root>\n", os.Args[0])
+ fmt.Fprintf(os.Stderr, "usage: %s [-D] [-a <addr>] [-p <port>] <root>\n", os.Args[0])
os.Exit(1)
}
- listener, err := net.Listen("tcp", "127.0.0.1:5640")
+ listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", *aFlag, *pFlag))
if err != nil {
log.Fatalf("listen tcp: %v", err)
}