An open API service indexing awesome lists of open source software.

https://github.com/zackproser/procrastiproxy

A simple configurable proxy that blocks distracting hosts
https://github.com/zackproser/procrastiproxy

distraction-blocker focus golang productivity proxy

Last synced: 6 months ago
JSON representation

A simple configurable proxy that blocks distracting hosts

Awesome Lists containing this project

README

          

# Overview

[![Go Report Card](https://goreportcard.com/badge/github.com/zackproser/procrastiproxy)](https://goreportcard.com/report/github.com/zackproser/procrastiproxy)
[![CircleCI](https://circleci.com/gh/zackproser/procrastiproxy.svg?style=shield)](https://circleci.com/gh/zackproser/procrastiproxy)

![Procrastiproxy Open-Source reverse proxy](./docs/cover.png)

Procrastiproxy is a simple, configurable proxy that helps you focus by blocking distracting websites.

```
curl https://raw.githubusercontent.com/zackproser/procrastiproxy/main/install.sh | bash
```

Example: block reddit and twitter during work hours

```
procrastiproxy --block reddit.com,twitter.com
```

Procrastiproxy implements an in-memory, mutable list for tracking hosts that should be blocked. This in-memory list allows for fast (`O(1)` or "constant time") look-ups of blocked hosts.

```mermaid
graph TD
A[User] -->|Itches to browse something distracting| B(GET reddit.com/)
B --> C(Procrastiproxy)
C --> D{Should this request be allowed?}
D -->|It's not working hours| E(Allow Request)
D -->|It's time to work!| F(Access denied!)
```

# Getting started

**Install with one command**

To install procrastiproxy as a command-line interface (CLI) tool, you can execute the install script:

```
curl https://raw.githubusercontent.com/zackproser/procrastiproxy/main/install.sh | bash
```

**Install as a library**

You can import procrastiproxy into your own project:

```golang
import github.com/zackproser/procrastiproxy
```

**Install via Go**

You can install and use procrastiproxy as a command line interface (CLI) tool:

```bash
go install github.com/zackproser/procrastiproxy
```

**Build from source and run locally**

`go build -o procrastiproxy ./cmd`

`./procrastiproxy --port 8001`

# Features

## Configurable and dynamic block list

The block list is kept in-memory and is implemented as a map for fast lookups. You can set your baseline block list in `.procrastiproxy.yaml`. It can be modified at runtime via the admin control endpoints described below.

## Admin control

Make a request to the `/admin/` path, passing either `block` or `unblock` followed by a host, like so:

### Add a new host to the block list

`curl http://localhost:8001/admin/block/reddit.com`

### Remove a host from the block list

`curl http://localhost:8001/admin/unblock/reddit.com`

## Office hours

If a request is made to procrastiproxy within the configured office hours, the request will be examined and blocked if its host is on the block list. If a request is made to procrastiproxy outside of the configured office hours, it will be allowed.

# Running tests

Procrastiproxy comes complete with tests to verify its functionality.

`go test`