Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

berzdev/fokus

Repository files navigation

Fokus

Description

Focus was developed to make our networked world more human-friendly.

Focus makes it possible to block distractions without using up a lot of willpower.

For example, computer systems can be blocked after a set period of use per day. Or disruptive internet sites can be blocked (YouTube, Amazon, Reddit…).

I personally use Fokus for the following use cases, for example:

  1. Block Instant Messengers after 10 minutes a day (Hetzner VM)
    • No longer distracted by constant messages
    • Peace of mind to live without being permanently available.
    • More focused during the day

Concept

./docs/concept.svg

Quick Start

Requirements:

  • Hetzner Cloud Account
  • Hetzner Cloud API Token with RW Access
  • Hetzner Cloud VServer + Firewall
  1. Download the repo git clone ...
  2. Edit docker-compose.yml with your Hetzner API Key and Hetzner Firewall ID
  3. Run docker compose up -d
  4. Now you should be able to make API calls
curl http://demohost/api/v1/service/status?token=yourtoken&service=chatx

Services

A service describes a system with which this API interacts.

Each service has a fixed time per day. After this time has elapsed, the service is set to “off” (switched off). For example, access to a VServer can be deactivated after X minutes.

At the moment following services are supported:

  • Hetzner Cloud Firewall

One Hetzner Firewall service is currently defined inside the Code:

xyz := NewService("xyz", 0, 4).TypeHetznerFirewall(hetznerFirewall{token: os.Getenv("HETZNER_TOKEN"), id: os.Getenv("HETZNER_FW_ID")})

API Reference

API Basepath: http://host:8080/api/v1

/service/on

Activates a service.

GET Parameter

ParameterTypeDefinitionReq
------------------------------------------------
tokenstrAuthentication tokentrue
servicestrServicenametrue

CURL Bsp.

curl $APIPATH/service/on$APIAUTH

/service/off

Deactivate a service.

GET Parameter

ParameterTypeDefinitionReq
------------------------------------------------
tokenstrAuthentication tokentrue
servicestrServicenametrue

CURL Bsp.

curl $APIPATH/service/off$APIAUTH

/service/status

Get the status of a service.

GET Parameter

ParameterTypeDefinitionReq
------------------------------------------------
tokenstrAuthentication tokentrue
servicestrServicenametrue

CURL Bsp.

curl $APIPATH/service/status$APIAUTH

/service/limitfill

Set the time per day to max. So you don’t have access to the service anymore for the whole day.

GET Parameter

ParameterTypeDefinitionReq
------------------------------------------------
tokenstrAuthentication tokentrue
servicestrServicenametrue

CURL Bsp.

curl $APIPATH/service/limitfill$APIAUTH

/metrics

This path provides a prometheus exporter for monitoring. Following custom metrics are implemented: apiActions backendFailure validationFailure authStatus

Releases

No releases published

Packages

No packages published