Skip to content

Commit

Permalink
Display exe path on startup so users know where to find log files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Bergesen committed Sep 7, 2024
1 parent 2453ed3 commit 871d2ee
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/fs"
"net"
"os"
"path/filepath"
"strings"

"github.com/nicholasbergesen/dns/dns"
Expand All @@ -21,6 +22,13 @@ var logger = log.Log{FileName: "dns-{date}.log", ShowIncConsole: true}

func main() {
logger.FormatDate()
ex, err := os.Executable()
if err != nil {
panic(err)
}
exPath := filepath.Dir(ex)
logger.Write("Running from %s\n", exPath)

udpAddr, err := net.ResolveUDPAddr("udp", "0.0.0.0"+PORT)
if err != nil {
logger.Write("Failed to resolve UDP address: %v", err)
Expand Down Expand Up @@ -184,12 +192,12 @@ func LoadBlockedUrls() []string {
logger.Write("Items loaded from block.txt\n")
for {
line, _, err := reader.ReadLine()
logger.Write("%s\n", line)

if err != nil || line == nil {
break
}

logger.Write(" - %s\n", line)
lines = append(lines, string(line))
}
return lines
Expand Down

0 comments on commit 871d2ee

Please sign in to comment.