diff --git a/README.md b/README.md index 35a1ba4..0c15909 100644 --- a/README.md +++ b/README.md @@ -1 +1,52 @@ +# goaway - DNS request blocker + ![goaway Preview](./resources/preview.png) + +## 🙏 Acknowledgments + +Heavily inspired by [pi-hole](https://github.com/pi-hole/pi-hole). + +## 📦 Installation + +**goaway** supports the following platforms: +- **Operating Systems**: Linux, macOS, and Windows +- **Architectures**: amd64, arm64, and 386 + +> [!NOTE] +> Testing has primarily been conducted on **Linux (amd64)**. +> Functionality on macOS and Windows may vary and is not guaranteed. + +### Install the Latest Version + +To install the latest version of goaway, run the following command: + +```shell +curl https://raw.githubusercontent.com/pommee/goaway/main/installer.sh | sh /dev/stdin +``` +This will install the binary specific to your platform. +The binary is placed in `~/.local/bin`. +If the [installer.sh](https://github.com/pommee/goaway/blob/main/installer.sh) script fails, then binaries can be manually downloaded from [releases](https://github.com/pommee/goaway/releases). + +## 🛠 Usage + +### Starting the Application +To start the servers (dns & web), simply run the following command in your terminal: +```console +$ goaway +``` +> Will display some information once the server is started. + +![started](./resources/started.png) + +### Development + +Environment variables are used for configuration. +| Variable | Default | Info | +| ---------------- | ---------------- | ------------------------------------------------------------------------------------------------ | +| GOAWAY_PORT | 53 | Port used for the DNS server. | +| WEBSITE_PORT | 8080 | Port used for the API server. Also serves the website pages. | +| UPSTREAM_DNS | 8.8.8.8:53 | IP and port the server uses to resolve domain names. | +| BLACKLIST_PATH | ./blacklist.json | File containing all domain names that will be blocked. | +| COUNTER_PATH | ./counter.json | Keeps track of of various statistics. | +| REQUEST_LOG_FILE | ./requests.json | Storage for all requests served. Contains timestamps, domain names and if a request was blocked. | + diff --git a/installer.sh b/installer.sh new file mode 100755 index 0000000..c5ec1f9 --- /dev/null +++ b/installer.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +set -e + +target="" +githubUrl="" +executable_folder=$(eval echo "~/.local/bin") + +get_arch() { + case $(uname -m) in + "x86_64" | "amd64" ) echo "amd64" ;; + "i386" | "i486" | "i586") echo "386" ;; + "aarch64" | "arm64" | "arm") echo "arm64" ;; + "mips64el") echo "mips64el" ;; + "mips64") echo "mips64" ;; + "mips") echo "mips" ;; + *) echo "unknown" ;; + esac +} + +get_os() { + uname -s | tr '[:upper:]' '[:lower:]' +} + +get_latest_release() { + curl --silent "https://api.github.com/repos/pommee/goaway/releases/latest" | + grep '"tag_name":' | + sed -E 's/.*"v([^"]+)".*/\1/' +} + +main() { + os=$(get_os) + arch=$(get_arch) + latest_version=$(get_latest_release) + file_name="goaway_${latest_version}_${os}_${arch}.tar.gz" + downloadFolder="${TMPDIR:-/tmp}" + downloaded_file="${downloadFolder}/${file_name}" + + echo "[1/3] Downloading ${file_name} to ${downloadFolder}" + asset_path=$(curl -sL "https://api.github.com/repos/pommee/goaway/releases" | + grep -o "https://github.com/pommee/goaway/releases/download/v${latest_version}/${file_name}" | + head -n 1) + asset_uri="${githubUrl}${asset_path}" + + if [ -z "$asset_path" ]; then + echo "ERROR: Unable to find a release asset called ${file_name}" + exit 1 + fi + + echo "Downloading from: ${asset_uri}" + rm -f "${downloaded_file}" + curl --fail --location --output "${downloaded_file}" "${asset_uri}" + + mkdir -p "${executable_folder}" + + echo "[2/3] Installing ${file_name} to ${executable_folder}" + tar -xzf "${downloaded_file}" -C "${executable_folder}" + chmod +x "${executable_folder}/goaway" + + echo "[3/3] goaway was installed successfully to ${executable_folder}" + + echo "Manually add the directory to your \$HOME/.bash_profile (or similar):" + echo " export PATH=${executable_folder}:\$PATH" + exit 0 +} + +main diff --git a/resources/started.png b/resources/started.png new file mode 100644 index 0000000..fde5518 Binary files /dev/null and b/resources/started.png differ