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 ( import (
"encoding/hex" "encoding/hex"
"encoding/json"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@@ -119,6 +120,7 @@ func main() {
stat := proxy.NewStats(*serverName, *portToShow, *secret) stat := proxy.NewStats(*serverName, *portToShow, *secret)
go stat.Serve(*statsIP, *statsPort) go stat.Serve(*statsIP, *statsPort)
printURLs(stat.URLs)
srv := proxy.NewServer(*bindIP, int(*bindPort), secretBytes, logger, srv := proxy.NewServer(*bindIP, int(*bindPort), secretBytes, logger,
*readTimeout, *writeTimeout, *preferIPv6, stat) *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) { func usage(msg string) {
io.WriteString(os.Stderr, msg+"\n") io.WriteString(os.Stderr, msg+"\n")
os.Exit(1) os.Exit(1)