Print URLs on start to stdout

This commit is contained in:
9seconds
2018-05-31 09:54:20 +03:00
parent 5b90e04185
commit 42e5be36bf
+13
View File
@@ -4,6 +4,7 @@ package main
import (
"encoding/hex"
"encoding/json"
"io"
"io/ioutil"
"net/http"
@@ -119,6 +120,7 @@ func main() {
stat := proxy.NewStats(*serverName, *portToShow, *secret)
go stat.Serve(*statsIP, *statsPort)
printURLs(stat.URLs)
srv := proxy.NewServer(*bindIP, int(*bindPort), secretBytes, logger,
*readTimeout, *writeTimeout, *preferIPv6, stat)
@@ -127,6 +129,17 @@ func main() {
}
}
func printURLs(data interface{}) {
encoder := json.NewEncoder(os.Stdout)
encoder.SetEscapeHTML(false)
encoder.SetIndent("", " ")
err := encoder.Encode(data)
if err != nil {
panic(err)
}
}
func usage(msg string) {
io.WriteString(os.Stderr, msg+"\n")
os.Exit(1)