Metadata-Version: 2.4
Name: py-mihomo-trojan-interface
Version: 0.1.0
Summary: Launch mihomo with an administrator-elevated Trojan config generated from a share URL.
Author: GGN_2015
License: MIT License
        
        Copyright (c) 2026 GGN_2015
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: administrator,clash,mihomo,proxy,trojan
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet :: Proxy Servers
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.9
Requires-Dist: py-admin-launch>=0.1.3
Description-Content-Type: text/markdown

# 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

```bash
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.

```bash
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:

```powershell
$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:

```bash
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:

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