Skip to main content

Launch mihomo with an administrator-elevated Trojan config generated from a share URL.

Project description

py-mihomo-trojan-interface

Generate a mihomo YAML config from a trojan:// share URL, relaunch with administrator privileges through py-admin-launch, and start mihomo with the generated config.

Install

python -m pip install -e .

Usage

Prefer passing the Trojan URL through stdin, an environment variable, or a file so the full URL does not stay in shell history.

printf '%s' 'trojan://<secret>@<host>:<port>?type=tcp&sni=<sni>#<name>' | \
  mihomo-trojan \
    --mihomo /path/to/mihomo \
    --country-mmdb /path/to/Country.mmdb \
    --trojan-url-stdin

PowerShell example:

$env:MIHOMO_TROJAN_URL = 'trojan://<secret>@<host>:<port>?type=tcp&sni=<sni>#<name>'
mihomo-trojan `
  --mihomo C:\path\to\mihomo.exe `
  --country-mmdb C:\path\to\Country.mmdb `
  --trojan-url-env MIHOMO_TROJAN_URL

You can also pass the URL directly when needed:

mihomo-trojan \
  --mihomo /path/to/mihomo \
  --country-mmdb /path/to/Country.mmdb \
  --trojan-url 'trojan://<secret>@<host>:<port>?type=tcp&sni=<sni>#<name>'

The launcher passes the mihomo data directory with -d and the generated YAML with -f. If --data-dir is not provided and the mmdb file is named Country.mmdb, the file's parent directory is used as the mihomo data directory.

On Linux and macOS, the launcher automatically marks the mihomo binary as executable before starting it, equivalent to running chmod +x on the path provided with --mihomo.

Useful options:

mihomo-trojan --help
mihomo-trojan --dry-run --log debug --mihomo /path/to/mihomo --country-mmdb /path/to/Country.mmdb --trojan-url-env MIHOMO_TROJAN_URL

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

py_mihomo_trojan_interface-0.1.5.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

py_mihomo_trojan_interface-0.1.5-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file py_mihomo_trojan_interface-0.1.5.tar.gz.

File metadata

  • Download URL: py_mihomo_trojan_interface-0.1.5.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for py_mihomo_trojan_interface-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2b1f3583722f6020bf8a2925ddf055101428f5117694b6fa3ca84ea7d1a02b75
MD5 2b24ac993a91cddbc8ca0a501b4d557c
BLAKE2b-256 646fe27ad303c04f9d370701c1d941fa9bebed92bf9dd9eef096eee9b43b52a0

See more details on using hashes here.

File details

Details for the file py_mihomo_trojan_interface-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for py_mihomo_trojan_interface-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 665f9fde2e5c10a79a8de0d454e56491e9e3cb5271b77afa26a2fd92f8f94b5b
MD5 56778b28a0cbc96db1bac3c9a089eea3
BLAKE2b-256 3ce488736dd96a0b6426db46b730526a308855288ecbcc9ea818791ec88bb687

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