增加局域网内部自签名使用方式
This commit is contained in:
+12
-3
@@ -18,6 +18,8 @@ var staticFiles embed.FS
|
||||
|
||||
func main() {
|
||||
port := flag.Int("port", 8080, "server port")
|
||||
certFile := flag.String("cert", "", "TLS certificate file (enables HTTPS)")
|
||||
keyFile := flag.String("key", "", "TLS key file (enables HTTPS)")
|
||||
flag.Parse()
|
||||
|
||||
distFS, err := fs.Sub(staticFiles, "static/dist")
|
||||
@@ -48,9 +50,16 @@ func main() {
|
||||
os.Exit(0)
|
||||
}()
|
||||
|
||||
log.Printf("ncmdump-web (WASM mode) starting on :%d", *port)
|
||||
addr := fmt.Sprintf(":%d", *port)
|
||||
if err := http.ListenAndServe(addr, mux); err != nil {
|
||||
log.Fatalf("server error: %v", err)
|
||||
if *certFile != "" && *keyFile != "" {
|
||||
log.Printf("ncmdump-web (WASM mode) starting on https://localhost:%d", *port)
|
||||
if err := http.ListenAndServeTLS(addr, *certFile, *keyFile, mux); err != nil {
|
||||
log.Fatalf("server error: %v", err)
|
||||
}
|
||||
} else {
|
||||
log.Printf("ncmdump-web (WASM mode) starting on http://localhost:%d", *port)
|
||||
if err := http.ListenAndServe(addr, mux); err != nil {
|
||||
log.Fatalf("server error: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user