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.

Useful options:

mihomo-trojan --help
mihomo-trojan --dry-run --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.0.tar.gz (11.5 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.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_mihomo_trojan_interface-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 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.0.tar.gz
Algorithm Hash digest
SHA256 d02ba3311ed6adfdc280194d517e43e618302a4355a88cf5b12760ac3d2b1bc5
MD5 49095109764c72473fac9e7fcf21539e
BLAKE2b-256 0dc9062d1189605b7c2c9fe4322847c39efc03d529f271c50412d24cfa2a3d82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_mihomo_trojan_interface-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 405cd3f9842845b49c86ccdd727e96fcc20a2b7c077b13aace9e6cd1212e6f0e
MD5 de461da22f6651d65d48a3b75c5b6690
BLAKE2b-256 2ff906527bed80ce532d2e8e491ad0f1997636ec988289047026b05b700b2f72

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