From 60fc4ebb599d82f5c7ddaca52f8aba74f0876381 Mon Sep 17 00:00:00 2001 From: simponic Date: Thu, 28 Mar 2024 16:58:07 -0400 Subject: internal recursive dns server (#2) Co-authored-by: Lizzy Hunt Reviewed-on: https://git.hatecomputers.club/hatecomputers/hatecomputers.club/pulls/2 --- main.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 4b92b1b..2991821 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "git.hatecomputers.club/hatecomputers/hatecomputers.club/api" "git.hatecomputers.club/hatecomputers/hatecomputers.club/args" "git.hatecomputers.club/hatecomputers/hatecomputers.club/database" + "git.hatecomputers.club/hatecomputers/hatecomputers.club/dns" "git.hatecomputers.club/hatecomputers/hatecomputers.club/scheduler" "github.com/joho/godotenv" ) @@ -40,10 +41,27 @@ func main() { if argv.Server { server := api.MakeServer(argv, dbConn) - err = server.ListenAndServe() - if err != nil { - log.Fatal(err) - } - log.Println("🚀🚀 server listening on port", argv.Port) + log.Println("🚀🚀 API listening on port", argv.Port) + + go func() { + err = server.ListenAndServe() + if err != nil { + log.Fatal(err) + } + }() } + + if argv.Dns { + server := dns.MakeServer(argv, dbConn) + log.Println("🚀🚀 DNS resolver listening on port", argv.DnsPort) + go func() { + err = server.ListenAndServe() + if err != nil { + log.Fatal(err) + } + }() + } + + runForever := make(chan struct{}) + <-runForever } -- cgit v1.2.3-70-g09d2