# weebdatahoarder/go-away architecture

> Architecture diagram of the GitHub repository weebdatahoarder/go-away, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/weebdatahoarder/go-away
- Repository: https://github.com/weebdatahoarder/go-away

## Overview

go-away is a self-hosted abuse-detection and rule-enforcement proxy between a site and its clients/upstream. Requests enter its HTTP handler, are evaluated against configurable conditions and rules, and are passed, challenged, or otherwise actioned; challenge state lets later requests proceed after verification. The README also documents network-based matching, multiple challenge types, custom JavaScript/WASM challenges, and customizable challenge pages. The excerpts establish startup, request-data evaluation, state initialization, and challenge action behavior; some deeper routing and integrations are documented but not shown in source excerpts.

Main entry points: [`lib/http.go`](https://github.com/weebdatahoarder/go-away/blob/master/lib/http.go) (HTTP request handler), [`cmd/go-away/main.go`](https://github.com/weebdatahoarder/go-away/blob/master/cmd/go-away/main.go) (Server startup), [`lib/policy/policy.go`](https://github.com/weebdatahoarder/go-away/blob/master/lib/policy/policy.go) (Policy and rules), [`lib/state.go`](https://github.com/weebdatahoarder/go-away/blob/master/lib/state.go) (Policy runtime state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Proxy runtime"]
  node_command["Server startup<br/>[main.go]"]
  node_bind["Listener and TLS<br/>[bind.go]"]
  node_http["HTTP request handler<br/>[http.go]"]
  node_settings["Runtime settings<br/>[settings.go]"]
end

subgraph group_policy["Policy evaluation"]
  node_policydata["Policy and rules<br/>[policy.go]"]
  node_conditions["CEL conditions<br/>[conditions.go]"]
  node_networks["Network matching<br/>[network.go]"]
  node_action["Rule actions<br/>[challenge.go]"]
end

subgraph group_challenge["Challenges"]
  node_requestdata["Request and challenge state<br/>[data.go]"]
  node_registrations["Challenge registration<br/>[register.go]"]
  node_browserchallenges["Browser challenges"]
  node_wasm["JavaScript WASM challenges<br/>[registration.go]"]
  node_pow["SHA-256 proof of work<br/>[runtime.go]"]
end

subgraph group_support["State and presentation"]
  node_templates["Challenge templates<br/>[template.go]"]
  node_state["Policy runtime state<br/>[state.go]"]
  node_networkdata["Network prefix sources<br/>[network.go]"]
end

node_client(("Incoming client"))
node_proxy(("Upstream site"))

node_client -->|"sends requests"| node_http
node_http -->|"creates request data"| node_requestdata
node_http -->|"evaluates challenges"| node_requestdata
node_command -->|"loads policy state"| node_state
node_command -.->|"opens listener"| node_bind
node_bind -->|"serves handler"| node_http
node_command -->|"loads settings"| node_settings
node_policydata -.->|"selects requests"| node_http
node_policydata -.->|"defines conditions"| node_conditions
node_policydata -.->|"defines networks"| node_networks
node_state -->|"loads prefixes"| node_networks
node_state -->|"creates challenges"| node_registrations
node_action -->|"selects challenges"| node_registrations
node_action -.->|"issues challenges"| node_browserchallenges
node_registrations -.->|"registers WASM"| node_wasm
node_wasm -.->|"runs challenge module"| node_pow
node_requestdata -.->|"renders challenge page"| node_templates
node_http -.->|"forwards permitted requests"| node_proxy
node_networkdata -->|"provides prefixes"| node_networks

click node_command "https://github.com/weebdatahoarder/go-away/blob/master/cmd/go-away/main.go"
click node_bind "https://github.com/weebdatahoarder/go-away/blob/master/lib/settings/bind.go"
click node_http "https://github.com/weebdatahoarder/go-away/blob/master/lib/http.go"
click node_settings "https://github.com/weebdatahoarder/go-away/blob/master/lib/settings/settings.go"
click node_policydata "https://github.com/weebdatahoarder/go-away/blob/master/lib/policy/policy.go"
click node_conditions "https://github.com/weebdatahoarder/go-away/blob/master/lib/conditions.go"
click node_networks "https://github.com/weebdatahoarder/go-away/blob/master/lib/policy/network.go"
click node_requestdata "https://github.com/weebdatahoarder/go-away/blob/master/lib/challenge/data.go"
click node_action "https://github.com/weebdatahoarder/go-away/blob/master/lib/action/challenge.go"
click node_registrations "https://github.com/weebdatahoarder/go-away/blob/master/lib/challenge/register.go"
click node_browserchallenges "https://github.com/weebdatahoarder/go-away/tree/master/lib/challenge"
click node_wasm "https://github.com/weebdatahoarder/go-away/blob/master/lib/challenge/wasm/registration.go"
click node_pow "https://github.com/weebdatahoarder/go-away/blob/master/embed/challenge/js-pow-sha256/runtime/runtime.go"
click node_templates "https://github.com/weebdatahoarder/go-away/blob/master/lib/template.go"
click node_state "https://github.com/weebdatahoarder/go-away/blob/master/lib/state.go"
click node_networkdata "https://github.com/weebdatahoarder/go-away/blob/master/lib/policy/network.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_command,node_bind,node_http,node_settings,node_client toneBlue
class node_policydata,node_conditions,node_networks,node_action toneAmber
class node_requestdata,node_registrations,node_browserchallenges,node_wasm,node_pow toneMint
class node_templates,node_state,node_networkdata toneRose
class node_proxy toneIndigo
```

## Components

### Proxy runtime

- [Server startup](https://github.com/weebdatahoarder/go-away/blob/master/cmd/go-away/main.go): `cmd/go-away/main.go`
- [Listener and TLS](https://github.com/weebdatahoarder/go-away/blob/master/lib/settings/bind.go): `lib/settings/bind.go`
- [HTTP request handler](https://github.com/weebdatahoarder/go-away/blob/master/lib/http.go): `lib/http.go`
- [Runtime settings](https://github.com/weebdatahoarder/go-away/blob/master/lib/settings/settings.go): `lib/settings/settings.go`

### Policy evaluation

- [Policy and rules](https://github.com/weebdatahoarder/go-away/blob/master/lib/policy/policy.go): `lib/policy/policy.go`
- [CEL conditions](https://github.com/weebdatahoarder/go-away/blob/master/lib/conditions.go): `lib/conditions.go`
- [Network matching](https://github.com/weebdatahoarder/go-away/blob/master/lib/policy/network.go): `lib/policy/network.go`
- [Rule actions](https://github.com/weebdatahoarder/go-away/blob/master/lib/action/challenge.go): `lib/action/challenge.go`

### Challenges

- [Request and challenge state](https://github.com/weebdatahoarder/go-away/blob/master/lib/challenge/data.go): `lib/challenge/data.go`
- [Challenge registration](https://github.com/weebdatahoarder/go-away/blob/master/lib/challenge/register.go): `lib/challenge/register.go`
- [Browser challenges](https://github.com/weebdatahoarder/go-away/tree/master/lib/challenge): `lib/challenge`
- [JavaScript WASM challenges](https://github.com/weebdatahoarder/go-away/blob/master/lib/challenge/wasm/registration.go): `lib/challenge/wasm/registration.go`
- [SHA-256 proof of work](https://github.com/weebdatahoarder/go-away/blob/master/embed/challenge/js-pow-sha256/runtime/runtime.go): `embed/challenge/js-pow-sha256/runtime/runtime.go`

### State and presentation

- [Challenge templates](https://github.com/weebdatahoarder/go-away/blob/master/lib/template.go): `lib/template.go`
- [Policy runtime state](https://github.com/weebdatahoarder/go-away/blob/master/lib/state.go): `lib/state.go`
- [Network prefix sources](https://github.com/weebdatahoarder/go-away/blob/master/lib/policy/network.go): `lib/policy/network.go`

### Other components

- **Incoming client**
- **Upstream site**

## Connections

- Incoming client → HTTP request handler: sends requests
- HTTP request handler → Request and challenge state: creates request data (evidence: `lib/http.go`)
- HTTP request handler → Request and challenge state: evaluates challenges (evidence: `lib/http.go`)
- Server startup → Policy runtime state: loads policy state (evidence: `cmd/go-away/main.go`)
- Server startup → Listener and TLS: opens listener
- Listener and TLS → HTTP request handler: serves handler (evidence: `lib/settings/bind.go`)
- Server startup → Runtime settings: loads settings (evidence: `cmd/go-away/main.go`)
- Policy and rules → HTTP request handler: selects requests
- Policy and rules → CEL conditions: defines conditions
- Policy and rules → Network matching: defines networks (evidence: `lib/policy/network.go`)
- Policy runtime state → Network matching: loads prefixes (evidence: `lib/state.go`)
- Policy runtime state → Challenge registration: creates challenges (evidence: `lib/state.go`)
- Rule actions → Challenge registration: selects challenges (evidence: `lib/action/challenge.go`)
- Rule actions → Browser challenges: issues challenges (evidence: `lib/action/challenge.go`)
- Challenge registration → JavaScript WASM challenges: registers WASM
- JavaScript WASM challenges → SHA-256 proof of work: runs challenge module
- Request and challenge state → Challenge templates: renders challenge page
- HTTP request handler → Upstream site: forwards permitted requests
- Network prefix sources → Network matching: provides prefixes (evidence: `lib/policy/network.go`)
