baka-dns

command module
v0.0.0-...-2de874f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 12 Imported by: 0

README

Baka-DNS

Noah Kraft,Zhang CSCI4211,01/02/20

General

Baka-DNS is a simple DNS written in Go. This was made for CSCI4211 but I may expand it in the future (and remove ws).

DNS queries can be made via a POST to :9888 or through websockets on :9889.

Compilation

Go may not be in the path in some systems (CSE), make sure you add it:

module add soft/go

1 ) Install modules:

go get

2a) To compile and run use:

go run main.go

2b) To just compile use:

go build main.go

3 ) Run pre-compiled:

./main

Ctrl + c to kill the server.

If you want to also have a local cache, run ./run.sh in order to start the Redis server. This is not required but it will have to query the remote dns for each query to it. Sometimes the CSE-Lab machines won't allow you to run the script, I don't know what the issue is

If redis-server is already present or you have your own install, run it with:

./redis-server redis.conf

Description

Upon a connection with text, (websocket needs a newline) it will spawn a goroutine that parses the string into a valid hostname. This hostname will be searched for in the redis cache, if found it will return the cached ip. If not in redis it will send a DNS request to (by default) 1.1.1.1 for authoritative resolution. If no ip is found it returns an error, if one ip is found it will return that ip, if multiple ip are found it spawns one goroutine for each and pings once via spawning the ping function in another goroutine. If all pings fail(or take > 1 sec) it will return the first ip as best-hope for the user to resolve, otherwise it will return the optimal ping-base ip. The resolved ip will then be cached in redis with a timeout set to the ttl as given by the authoritative resolution.

The exact same DNS function is used for both POST and WS connections.

Detailed output is written to console during operation and each dns query response is logged into the dns-server-log.csv.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL