aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Oppiliappan <x@icyphox.sh>2021-08-06 17:42:25 +0530
committerAnirudh Oppiliappan <x@icyphox.sh>2021-08-06 17:42:25 +0530
commitf2531467f400563a56c2192b34815d07b97ed9ed (patch)
treeace58e6f49526daa1d30bc3c4b657ad5bbf2e689
parentdc8a0c756b67221088b8f77567cd1da89a30ba83 (diff)
downloadfsrv-f2531467f400563a56c2192b34815d07b97ed9ed.tar.gz
Listen on 0.0.0.0
-rw-r--r--main.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/main.go b/main.go
index 997c242..29d6b8f 100644
--- a/main.go
+++ b/main.go
@@ -14,7 +14,7 @@ import (
14 14
15type settings struct { 15type settings struct {
16 url string 16 url string
17 port string 17 addr string
18 namelen int 18 namelen int
19 key string 19 key string
20 storepath string 20 storepath string
@@ -40,7 +40,7 @@ func (s *settings) uploadFile(w http.ResponseWriter, r *http.Request) {
40 log.Printf("incorrect key: %+v", key) 40 log.Printf("incorrect key: %+v", key)
41 return 41 return
42 } 42 }
43 r.ParseMultipartForm(10 << 20) 43 r.ParseMultipartForm(20 << 20)
44 file, handler, err := r.FormFile("file") 44 file, handler, err := r.FormFile("file")
45 if err != nil { 45 if err != nil {
46 log.Println(err) 46 log.Println(err)
@@ -71,7 +71,7 @@ func (s *settings) uploadFile(w http.ResponseWriter, r *http.Request) {
71 71
72func (s *settings) readSettings() { 72func (s *settings) readSettings() {
73 flag.StringVar(&s.url, "url", "localhost", "url for fsrv to serve files") 73 flag.StringVar(&s.url, "url", "localhost", "url for fsrv to serve files")
74 flag.StringVar(&s.port, "port", "9393", "port to listen on") 74 flag.StringVar(&s.addr, "addr", "0.0.0.0:9393", "address to listen on")
75 flag.StringVar(&s.storepath, "storepath", "uploads", "path to store uploaded files") 75 flag.StringVar(&s.storepath, "storepath", "uploads", "path to store uploaded files")
76 flag.IntVar(&s.namelen, "namelen", 5, "length of random filename") 76 flag.IntVar(&s.namelen, "namelen", 5, "length of random filename")
77 flag.StringVar(&s.key, "key", "secret", "secret key; generate this yourself") 77 flag.StringVar(&s.key, "key", "secret", "secret key; generate this yourself")
@@ -87,6 +87,6 @@ func main() {
87 87
88 http.HandleFunc("/", st.uploadFile) 88 http.HandleFunc("/", st.uploadFile)
89 89
90 log.Println("listening on " + st.port) 90 log.Println("listening on " + st.addr)
91 http.ListenAndServe(":"+st.port, nil) 91 http.ListenAndServe(st.addr, nil)
92} 92}