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 --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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_mihomo_trojan_interface-0.1.1.tar.gz.
File metadata
- Download URL: py_mihomo_trojan_interface-0.1.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1fb814ab8be8ed78244aa42664db1ee34293829fe76f1d683002ddf7ed73fb3
|
|
| MD5 |
c6d511701248aad33039478e0829557a
|
|
| BLAKE2b-256 |
0031d8b913d8b7462fa30ad67a5699bd58568286195ca4f951319f160419d265
|
File details
Details for the file py_mihomo_trojan_interface-0.1.1-py3-none-any.whl.
File metadata
- Download URL: py_mihomo_trojan_interface-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ce1f49a085bb28067fb5e7ad918c881eaa7313a2148418032f276cb83024f1f
|
|
| MD5 |
e58a2dbd81f702c5a6a4a7b78739ff62
|
|
| BLAKE2b-256 |
bbaa2d5e05a0e6300dbde49beebc6077b80b75225fecb18dc2ad2eaea1138d7e
|