better-wapi

command module
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

README

Better WAPI

This project is inteded to serve as a more standardized wrapper around the Wedos API (WAPI).

GitHub GitHub go.mod Go version

It currently offers following functionality:

  • Add DNS record for a specific domain
  • Update DNS record for specific domain
  • Remove DNS record for specific domain
  • List all DNS records for specific domain
  • List a particular DNS record for specific domain

The BetterWAPI project uses RESTful API style and tries to take a more standardized approach, something that the original WAPI is missing entirely. The core functionality remains similar.

For creating and updating records, only operations on A record types are currently supported.

This project is still in active development and far from final release. All features are subject to change (while trying to preserve backward compatibility of course).

Installation

For the API to work, it is first important to whitelist the IP address of the host machine in the WEDOS management dashboard. It is best to have a server with a static IP address assigned and have this address whitelisted (for production environments).

To run the project locally:

git clone https://github.com/Loupeznik/better-wapi.git
cd better-wapi
go get .
cp .env.example .env

Fill the .env file with your credentials.

  • The BW_WAPI_ variables are your WAPI credentials from the WEDOS management dashboard
  • The BW_USER_ variables are credentials to use within your API

Alternatively, it is possible to use environment variables without using the .env file.

Example in Powershell:

$Env:BW_USER_LOGIN = "admin"
$Env:BW_USER_SECRET = "admin"
$Env:BW_WAPI_LOGIN = "admin@example.com"
$Env:BW_WAPI_PASSWORD = "yourpassword"

Finally, to run the API.

go run .

For production workloads, a web server like NGINX is needed, the .env file also needs to be present.

Running in Docker

An option to run the API in Docker is available as well.

Building the image:

docker build -t better-wapi:latest .
docker run -d -p 8083:8000 --env-file .\.env better-wapi:latest

Alternatively, get the image from Dockerhub

docker pull loupeznik/better-wapi
docker run -d -p 8083:8000 --env-file .\.env loupeznik/better-wapi:latest

Documentation

Example usage

List all subdomains
curl --location --request GET 'http://127.0.0.1:8000/api/domain/dzarsky.eu/info' \
--header 'Authorization: Basic aGVsb3U6eWVz'
Update a record
curl --location --request PUT 'http://127.0.0.1:8000/api/domain/dzarsky.eu/record' \
--header 'Authorization: Basic aGVsb3U6eWVz' \
--header 'Content-Type: application/json' \
--data-raw '{
    "subdomain": "*",
    "ip": "123.123.123.123"
}'

The API uses basic auth with the BW_USER credentials set in the .env file.

License

This project is GPL-3.0 licensed.

Created by Dominik Zarsky.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
src
api

Jump to

Keyboard shortcuts

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