Filtering asynchronous SOCKS5 (TCP/UDP) proxy server https://crates.io/crates/psocks
Find a file
2026-03-27 11:14:33 +02:00
src rename list to rules, change api to free list control namespace 2026-03-27 11:14:33 +02:00
.gitignore initial commit 2026-03-22 01:06:24 +02:00
Cargo.lock update version 2026-03-27 11:11:37 +02:00
Cargo.toml update version 2026-03-27 11:11:37 +02:00
LICENSE Initial commit 2026-03-22 00:02:29 +01:00
README.md rename list to rules, change api to free list control namespace 2026-03-27 11:14:33 +02:00

psocks

Filtering asynchronous SOCKS5 (TCP/UDP) proxy server based on fast-socks5, featuring allowlist-based access control that drops everything except what is allowed by the user. Includes JSON/API based on Rocket framework.

Goals

  • Ad/tracking protection (before sending a DNS request)
  • Reduce CPU usage by filtering extra SSL traffic on background

Roadmap

  • SOCKS5 (TCP/UDP) server
  • Web JSON/API
  • Web UI

Usage

RUST_LOG=trace cargo run -- --allow=http://localhost/allow.txt \
                            --allow=/path/to/allow.txt \
                            --cache=/path/to/cache.txt \
                            no-auth
  • set socks5://127.0.0.1:1080 proxy in your application
  • use http://127.0.0.1:8010 for API:
    • /api/allow/{domain.com} - add rule to the current session (and --cache if defined)
    • /api/block/{domain.com} - delete rule from the current session (and --cache if defined)
    • /api/rules - return active rules (from server memory)
    • /api/cache/clean - clean the --cache file (returns deleted rules or null if not enabled)

Allow list example

# /path/to/allow.txt

// exact match
duckduckgo.com

// google.com with subdomains
.google.com

// IP
1.2.3.4

systemd

git clone https://codeberg.org/postscriptum/psocks.git
cd psocks
cargo build --release --locked
sudo install target/release/psocks /usr/local/bin
sudo useradd -s /usr/sbin/nologin -Mr psocks
sudo mkdir /var/lib/psocks && sudo chown psocks:psocks /var/lib/psocks
sudo mkdir /var/log/psocks && sudo chown psocks:psocks /var/log/psocks
#/etc/systemd/system/psocks.service

[Unit]
After=network-online.target
Wants=network-online.target

[Service]
User=psocks
Group=psocks

WorkingDirectory=/var/lib/psocks
ExecStart=/usr/local/bin/psocks \
              -a=https://codeberg.org/postscriptum/psocks-list/raw/branch/main/allow/internet.txt \
              -c=/var/lib/psocks/cache.txt \
              no-auth

Restart=always

Environment="RUST_LOG=psocks=warn"
Environment="NO_COLOR=1"

StandardOutput=file:///var/log/psocks/debug.log
StandardError=file:///var/log/psocks/error.log

[Install]
WantedBy=multi-user.target
  • sudo systemctl restart psocks
  • sudo systemctl enable psocks
  • sudo systemctl status psocks