@@ -14,6 +14,9 @@ import (
1414type options struct {
1515 ListenAddress string
1616 Folder string
17+ Certificate string
18+ Key string
19+ HTTPS bool
1720 Verbose bool
1821 Upload bool
1922}
@@ -24,6 +27,9 @@ func main() {
2427 flag .StringVar (& opts .ListenAddress , "listen" , "0.0.0.0:8000" , "Address:Port" )
2528 flag .StringVar (& opts .Folder , "path" , "." , "Folder" )
2629 flag .BoolVar (& opts .Upload , "upload" , false , "Enable upload via PUT" )
30+ flag .BoolVar (& opts .HTTPS , "https" , false , "HTTPS" )
31+ flag .StringVar (& opts .Certificate , "cert" , "" , "Certificate" )
32+ flag .StringVar (& opts .Key , "key" , "" , "Key" )
2733 flag .BoolVar (& opts .Verbose , "v" , false , "Verbose" )
2834
2935 flag .Parse ()
@@ -36,7 +42,14 @@ func main() {
3642 if opts .Upload {
3743 log .Println ("Upload enabled" )
3844 }
39- fmt .Println (http .ListenAndServe (opts .ListenAddress , loglayer (http .FileServer (http .Dir (opts .Folder )))))
45+ if opts .HTTPS {
46+ if opts .Certificate == "" || opts .Key == "" {
47+ log .Fatal ("Certificate or Key file not specified" )
48+ }
49+ fmt .Println (http .ListenAndServeTLS (opts .ListenAddress , opts .Certificate , opts .Key , loglayer (http .FileServer (http .Dir (opts .Folder )))))
50+ } else {
51+ fmt .Println (http .ListenAndServe (opts .ListenAddress , loglayer (http .FileServer (http .Dir (opts .Folder )))))
52+ }
4053}
4154
4255func loglayer (handler http.Handler ) http.Handler {
0 commit comments