A simple Golang REST API for DNS queries.
- NOTE: Port
8080
or the one specified inmain.go
must be available.
- Install Golang if you want to run the API on your host machine.
- Install Golang dependencies if you want to run the API on your host machine. If you wish to run the API in a Docker container, you can skip this step.
go get -u github.com/gorilla/mux
go get -u github.com/google/go-cmp/cmp
go get -u github.com/HauptJ/Golang-API-DNS/MXLookup
go get -u github.com/HauptJ/Golang-API-DNS/AddrLookup
go get -u github.com/HauptJ/Golang-API-DNS/CNAMELookup
go get -u github.com/HauptJ/Golang-API-DNS/HostLookup
- To run on host system
go build main.go
./main
or.\main.exe
To Build and Run:
NOTE 1: Port 8880 or the one specified in docker-compose.yml and main.go must be available.
NOTE 2: On Windows 10 Pro or greater? You can use Chocolatey to install Docker Desktop for Windows and everything else listed below.
Install Docker and Docker Compose.
Docker
Chocolatey for Windows
Docker Compose
Chocolatey for Windows
Build and Run the container:
docker-compose build
docker-compose up
To stop
docker-compose down
- TYPE: GET
- Returns the list of MX records for the specified host
/mx/{host}
- Example:
/mx/hauptj.com
- Returns:
[
{
"Host": "string",
"Pref": int
},
...
]
- Example:
[
{
"Host": "aspmx.l.google.com.",
"Pref": 10
},
{
"Host": "alt1.aspmx.l.google.com.",
"Pref": 20
},
{
"Host": "alt2.aspmx.l.google.com.",
"Pref": 30
},
{
"Host": "alt3.aspmx.l.google.com.",
"Pref": 40
},
{
"Host": "alt4.aspmx.l.google.com.",
"Pref": 50
}
]
- TYPE: GET
- Returns a the hostname assigned to an IP address
/addr/{host}
- Example:
/addr/1.1.1.1
- Returns: [ "string" ]
- Example:
[
"one.one.one.one."
]
- TYPE: GET
- Returns the cname record for the specified host
- Example:
/cname/research.swtch.com
- Returns:
string
- Example:
"ghs.google.com."
- TYPE: GET
- Returns the A and AAAA records for a given host
- Example:
/host/localhost
- Returns:
[
"string",
"string"
]
- Example:
[
"::1",
"127.0.0.1"
]
TODO:
- Fix Rest endpoint test for MX endpoint.
- Implement Rest endpoint tests for the other endpoints.
- Implement, IP, NX, SRV, and TXT endpoints.
- Swagger Docs