diff --git a/main.go b/main.go index b5596cf..3af8274 100644 --- a/main.go +++ b/main.go @@ -28,13 +28,14 @@ func init() { flag.StringVar(&certificatePath, "certificatePath", "", "capsule certificate path") flag.StringVar(&fileSrvHost, "fileSrvHost", "", "file push server host") flag.StringVar(&fileSrvPort, "fileSrvPort", "", "file push server port") + flag.Parse() } func main() { certificates := &certificate.Store{} certificates.Register(hostname) if err := certificates.Load(certificatePath); err != nil { - log.Fatal(err) + panic(err) } mux := &gemini.Mux{} @@ -74,7 +75,11 @@ func renderIndex(lang string, w gemini.ResponseWriter) { summery := GetSummery() fmt.Println(summery) tree := TSummery{} - json.Unmarshal([]byte(summery), &tree) + err = json.Unmarshal([]byte(summery), &tree) + if err != nil { + w.WriteHeader(gemini.StatusTemporaryFailure, "Internal server error") + return + } fmt.Println(tree) categories := "" diff --git a/text_server.go b/text_server.go index 61f692e..edd0e10 100644 --- a/text_server.go +++ b/text_server.go @@ -7,7 +7,7 @@ import ( ) func GetSummery() string { - conn, err := net.Dial("tcp", "127.0.0.1:8301") + conn, err := net.Dial("tcp", fileSrvHost+":"+fileSrvPort) if err != nil { panic(err.Error()) }