Skip to main content

CLI generator for sing-box configuration files

Project description

Quickstart

Install the CLI:

pip install sekai-generator

Generate configs (local/test mode uses bundled fixtures):

sekai-generator --local --debug --start-port 8820 --tls-server-name mozilla.org --obfs-password password123

Outputs (in test mode):

  • test_data/inbounds.jsonc
  • test_data/outbounds.jsonc
  • test_data/users.jsonc

Manual usage and prerequisites

Download sing-box binary from GitHub releases

VERSION=1.12.14  # Replace with the desired version
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
    TARGETARCH=amd64
elif [ "$ARCH" = "aarch64" ]; then
    TARGETARCH=arm64
else
    echo "Unsupported architecture: $ARCH"
    exit 1
fi
curl -LJ "https://github.com/SagerNet/sing-box/releases/download/v${VERSION}/sing-box-${VERSION}-linux-${ARCH}.tar.gz" -o /tmp/sing-box.tar.gz

tar -xz -C ./ -f /tmp/sing-box.tar.gz --strip-components=1 && rm /tmp/sing-box.tar.gz

First think about two domain names for TLS handshake with TLS1.3 support and for ECH. I will use

  • mozilla.org for TLS handshake server name and
  • google.com for ECH domain since those are not blocked here, in Myanmar.
export TLS_SERVER_NAME=mozilla.org
export ECH_DOMAIN=google.com

Then generate self-signed certificate and private key:

mkdir -p certs && \
openssl ecparam -genkey -name prime256v1 -out data/certs/private.key && \
openssl req -new -x509 -days 36500 -key data/certs/private.key -out data/certs/certificate.crt \
-subj "/CN=${TLS_SERVER_NAME}" \
-addext "subjectAltName=DNS:${TLS_SERVER_NAME}"

Generate Reality keypair:

REALITY_KEYPAIR=$(./sing-box generate reality-keypair)
AUTO_REALITY_PRIVATE=$(awk '/PrivateKey/{print $NF}' <<< "$REALITY_KEYPAIR")
AUTO_REALITY_PUBLIC=$(awk '/PublicKey/{print $NF}' <<< "$REALITY_KEYPAIR")
REALITY_PRIVATE=${CUSTOM_REALITY_PRIVATE:-$AUTO_REALITY_PRIVATE}
REALITY_PUBLIC=${CUSTOM_REALITY_PUBLIC:-$AUTO_REALITY_PUBLIC}
printf '%s\n' "$REALITY_PRIVATE" > data/certs/reality_private.key
printf '%s\n' "$REALITY_PUBLIC" > data/certs/reality_public.key

Generate ECH keypair:

ECH_KEYPAIR=$(./sing-box generate ech-keypair ${ECH_DOMAIN})
AUTO_ECH_PUBLIC=$(sed -n '/-----BEGIN ECH CONFIGS-----/,/-----END ECH CONFIGS-----/p' <<< "$ECH_KEYPAIR")
AUTO_ECH_PRIVATE=$(sed -n '/-----BEGIN ECH KEYS-----/,/-----END ECH KEYS-----/p' <<< "$ECH_KEYPAIR")
ECH_PRIVATE=${CUSTOM_ECH_PRIVATE:-$AUTO_ECH_PRIVATE}
ECH_PUBLIC=${CUSTOM_ECH_PUBLIC:-$AUTO_ECH_PUBLIC}
printf '%s\n' "$ECH_PRIVATE" > data/certs/ech.key
printf '%s\n' "$ECH_PUBLIC" > data/certs/ech.config

Add users to users.yaml

  • A user must have a unique name, password, and UUID.
  • It's recommended to use a strong password and a randomly generated UUID.
  • Generate UUID (just in case you don't have one):
UUID=$(uuidgen)
echo "Generated UUID: $UUID"

Install dependencies:

python3 -m pip install -r requirements.txt

Run generator:

python3 app.py \
    --start-port 8820 \
    --tls-server-name $TLS_SERVER_NAME \
    --obfs_password "your_obfs_password"

Check out app.py for more options and details.

Run sing-box with the generated configuration:

./sing-box run -c config.jsonc

Run Tests:

pytest -vv

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sekai_generator-0.1.10.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sekai_generator-0.1.10-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file sekai_generator-0.1.10.tar.gz.

File metadata

  • Download URL: sekai_generator-0.1.10.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.12

File hashes

Hashes for sekai_generator-0.1.10.tar.gz
Algorithm Hash digest
SHA256 feefdaf4b05ee81aecd0b0afacc7d74e517341ce6b8b2d2bf9de3c59a3fbd0af
MD5 d71828757530558c03d4200fcb1675bc
BLAKE2b-256 f04ceed7a724e91e7a5c941263e1ec9f844f8d103395fcf2b71cba868ad23512

See more details on using hashes here.

File details

Details for the file sekai_generator-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for sekai_generator-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0fa9d26081d26dcaff565cad0b95098f4963355c695fb479f3091112da870476
MD5 a3fedec7dff2089c9b05adadbcc6733f
BLAKE2b-256 fb3aa110a6353f9e552c541cd196b980623465b33f727e2c0ec75cda1918f4f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page