rrda

REST API allowing to perform DNS queries over HTTP
Log | Files | Refs | README | LICENSE

commit a34f6b864e8a56554c001bf462ed911c0fc8df30
parent 0f44a3b869f7d2a5c7d96ab9e7b0ba1cb7ab9cf4
Author: Frederic Cambus <fred@statdns.com>
Date:   Tue, 22 Nov 2016 22:16:27 +0100

Add support for FastCGI mode

Diffstat:
Mrrda.go | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/rrda.go b/rrda.go @@ -22,7 +22,9 @@ import ( "github.com/miekg/dns" "golang.org/x/net/idna" "io" + "net" "net/http" + "net/http/fcgi" "os" "strings" ) @@ -164,6 +166,7 @@ func ptr(w http.ResponseWriter, r *http.Request) { func main() { header := "-------------------------------------------------------------------------------\n RRDA (RRDA REST DNS API) 1.02 (c) by Frederic Cambus 2012-2016\n-------------------------------------------------------------------------------" + fastcgi := flag.Bool("fastcgi", false, "Enable FastCGI mode") host := flag.String("host", "127.0.0.1", "Set the server host") port := flag.String("port", "8080", "Set the server port") @@ -182,8 +185,17 @@ func main() { m.Get("/:server/x/:ip", http.HandlerFunc(ptr)) m.Get("/:server/:domain/:querytype", http.HandlerFunc(query)) - if err := http.ListenAndServe(*host+":"+*port, m); err != nil { - fmt.Println("\nERROR :", err) - os.Exit(1) + if *fastcgi { + listener, _ := net.Listen("tcp", *host+":"+*port) + + if err := fcgi.Serve(listener, m); err != nil { + fmt.Println("\nERROR :", err) + os.Exit(1) + } + } else { + if err := http.ListenAndServe(*host+":"+*port, m); err != nil { + fmt.Println("\nERROR :", err) + os.Exit(1) + } } }