hs-hath: A Haskell implementation of the Hentai@Home client

[ gpl, library, program, web ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 1.1.1, 1.1.2, 1.2.0, 1.3.0
Change log CHANGELOG.md
Dependencies aeson (>=1 && <3), asn1-encoding (>=0.9 && <0.10), asn1-types (>=0.3.1 && <0.4), base (>=4.7 && <4.22), base64 (<2), base64-bytestring (>=1 && <2), basement (>=0.0.16 && <0.1), binary (<1), bytestring (>=0.11 && <0.13), case-insensitive (>=1 && <2), co-log (>=0.6 && <0.8), co-log-polysemy (>=0.0.1.5 && <0.0.2), conduit (>=1.3 && <1.4), conduit-extra (>=1 && <2), containers (>=0.6 && <0.8), crypton (>=1.0 && <1.1), crypton-connection (>=0.4 && <0.5), crypton-x509 (>=1.7 && <1.8), crypton-x509-validation (>=1.6 && <1.7), data-default-class (<1), dhall (>=1.42 && <1.43), digest (<1), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), hourglass (>=0.2 && <0.3), hs-hath, http-client (>=0.7 && <0.8), http-client-tls (>=0.3 && <0.4), http-conduit (>=2 && <3), http-types (>=0.12 && <0.13), ini (<1), lrucache (>=1.2 && <1.3), memory (>=0.18 && <0.19), network (>=3.2.12 && <3.3), network-uri (>=2 && <3), optparse-applicative (>=0.18 && <0.19), pem (>=0.1 && <0.3), polysemy (>=1.9 && <1.10), process (>=1.6 && <1.7), recv (>=0.1.0 && <0.2), relude (>=1.2 && <1.3), resourcet (>=1 && <2), retry (<1), sqlite-simple (>=0.4 && <0.5), stm (>=2.3 && <3), streaming-commons (<1), string-interpolate (>=0.3 && <0.4), template-haskell (>=2.19 && <2.24), text (>=2.0 && <2.2), time (>=1.12 && <1.15), time-units (>=1 && <2), tls (>=2.1.3 && <2.4), tls-session-manager (>=0.0.5 && <0.1), transformers (<1), unix (>=2.8 && <2.9), unliftio (>=0.2 && <0.3), unliftio-core (<1), unordered-containers (<1), wai (>=3.2 && <3.3), wai-extra (>=3.1 && <3.2), warp (>=3.4 && <3.5), xml-conduit (>=1 && <2) [details]
Tested with ghc ==9.12.2
License GPL-3.0-only
Copyright 2024-2026 pe200012
Author pe200012
Maintainer 1326263755@qq.com
Uploaded by pe200012 at 2026-11-18T14:15:22Z
Category Web
Home page https://github.com/pe200012/hs-hath#readme
Bug tracker https://github.com/pe200012/hs-hath/issues
Source repo head: git clone https://github.com/pe200012/hs-hath
Distributions
Executables migrate-to-r2, hs-hath, hath-bench
Downloads 75 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-11-18 [all 1 reports]

Readme for hs-hath-1.3.0

[back to package description]

hs-hath

A Hentai@Home client written in Haskell, also on Hackage.

It caches files on the local disk, in an SQLite database, or in S3-compatible storage (such as Cloudflare R2), uses Dhall for configuration, and exposes Prometheus metrics at /metrics.

Getting Started

Prerequisites

  • Stack
  • SQLite 3
  • The openssl command, only to run the test suite and hath-bench, which create certificates with it

Installation

  1. Build the project:

    stack build
    
  2. Copy client-login.example to client-login and fill in your credentials and paths:

    cp client-login.example client-login
    
    in  ClientConfig::{
        , clientId = "<YOURID>"
        , key = "<YOURKEY>"
        , version = "176"
        , downloadDir = "./download"
        , cachePath = "./cache"
        , cacheBackend = CacheBackend.CacheBackendFilesystem
        , r2Config = None R2Config
        }
    

    The example defines the record's types and defaults, so the file only names what differs. version, proxy and lruCacheSize are not read. cacheBackend is one of:

    • CacheBackendFilesystem: files under cachePath (a directory) as xxxx/<file id>, sent straight from disk. The least recently served files are evicted to stay under the disk limit set on the H@H settings page.
    • CacheBackendSQLite: files stored in the database file at cachePath. Nothing is evicted, and every cached file is checked against its hash at start unless --skip-startup-verify is given.
    • CacheBackendR2: r2Config = Some { r2Endpoint = "https://<account id>.r2.cloudflarestorage.com", r2Bucket = "<bucket>" }, with R2_ACCESS_KEY and R2_SECRET_KEY in the environment. A hit is answered with a redirect to a presigned link; nothing is evicted.

Usage

Run the client:

stack exec hs-hath

The configuration is read from ./client-login; -c FILE names another file. stack exec hs-hath -- --help lists the other options.

Prometheus metrics are served at /metrics, and the settings the server assigned at /admin/settings, once HATH_METRICS_TOKEN is set in the environment (any long random string, for example from openssl rand -hex 32). A request must send it as Authorization: Bearer <token>; in Prometheus:

scrape_configs:
  - job_name: hath
    scheme: https
    authorization:
      credentials: <token>
    static_configs:
      - targets: ["<host>:<port>"]

Without the variable both paths answer 404, like any path the official client does not have.

Notes & Caveats

  • Memory usage: Not optimized yet — expect ~200 MiB RAM on average.
  • S3 / Cloudflare R2: The object store must return ETag, Content-Length, and Last-Modified headers; missing ETag will fail cache writes.
  • Reverse proxy: Run with --trust-proxy-headers, which takes the reader's address from X-Forwarded-For when the proxy is on a loopback or private address. Flood control then counts readers, and server commands (/servercmd/) are taken from the RPC servers' addresses only. The connection limit sees only the peer's address and never refuses a local one, so it does not apply to a proxy on a local address.
  • Tunnels (rathole, frp, a plain port forward that rewrites the source): hs-hath sees every connection come from a local address and cannot tell readers apart, so neither flood control nor the connection limit applies; limit connections where the tunnel meets the internet. A server command from a local address is accepted on its key alone.
  • Start-up: If the server refuses client_start because another client is connected or the client id is in use, hs-hath exits. After any other failure (for example FAIL_CONNECT_TEST) it stays up without announcing itself, as the official client does, so that the port can be tested; restart it once the cause is fixed. A certificate with less than 24 h left is refused at start.
  • Galleries are saved as <downloadDir>/<title> [<gid>], or [<gid>-<xres>x] for a resized one, and galleryinfo.txt is written once all of a gallery's files are there.

License

Distributed under the GPL-3.0 License. See LICENSE.