From c639bddaebf4f636d1c8f7a19a74b258bb4b7a56 Mon Sep 17 00:00:00 2001 From: m5r Date: Tue, 12 Dec 2023 23:05:57 +0100 Subject: [PATCH] serve wildcard certificate files --- http/server.go | 15 +++++++++++++++ main.go | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 http/server.go diff --git a/http/server.go b/http/server.go new file mode 100644 index 0000000..2857e65 --- /dev/null +++ b/http/server.go @@ -0,0 +1,15 @@ +package http + +import ( + "net/http" +) + +func ServeCertificate() { + http.HandleFunc("/server.key", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "/certs/server.key") + }) + http.HandleFunc("/server.pem", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "/certs/server.pem") + }) + http.ListenAndServe(":9229", nil) +} diff --git a/main.go b/main.go index a495d97..3c02533 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "time" "local-ip.sh/certs" + "local-ip.sh/http" "local-ip.sh/xip" ) @@ -15,7 +16,7 @@ const ( ) func main() { - var port = flag.Int("port", 53, "port the DNS server should bind to") + port := flag.Int("port", 53, "port the DNS server should bind to") flag.Parse() n := xip.NewXip(zone, strings.Split(nameservers, ","), *port) @@ -34,5 +35,7 @@ func main() { } }() + go http.ServeCertificate() + n.StartServer() }