summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorsimponic <simponic@hatecomputers.club>2024-03-28 16:58:07 -0400
committersimponic <simponic@hatecomputers.club>2024-03-28 16:58:07 -0400
commit60fc4ebb599d82f5c7ddaca52f8aba74f0876381 (patch)
treeabe1eebb6154453cfa67812d7dfc982d758931a0 /main.go
parentdee173cc63d3b51d47c1a321096a4963fe458075 (diff)
downloadhatecomputers.club-60fc4ebb599d82f5c7ddaca52f8aba74f0876381.tar.gz
hatecomputers.club-60fc4ebb599d82f5c7ddaca52f8aba74f0876381.zip
internal recursive dns server (#2)
Co-authored-by: Lizzy Hunt <lizzy.hunt@usu.edu> Reviewed-on: https://git.hatecomputers.club/hatecomputers/hatecomputers.club/pulls/2
Diffstat (limited to 'main.go')
-rw-r--r--main.go28
1 files changed, 23 insertions, 5 deletions
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
}