Crates.io | clashtui |
lib.rs | clashtui |
version | 0.1.0 |
source | src |
created_at | 2023-12-29 10:01:34.92089 |
updated_at | 2023-12-29 10:01:34.92089 |
description | Mihomo TUI Client |
homepage | https://github.com/JohanChane/clashtui |
repository | https://github.com/JohanChane/clashtui |
max_upload_size | |
id | 1083155 |
size | 1,253,597 |
For example: ArchLinux.
# cat /etc/pacman.d/hooks/mihomo.hook (Systems without hooks may need manual setcap or use mihomo@root service)
[Trigger]
Operation = Install
Operation = Upgrade
Type = Path
Target = usr/bin/mihomo
[Action]
When = PostTransaction
Exec = /usr/bin/setcap 'cap_net_admin,cap_net_bind_service=+ep' /usr/bin/mihomo
# ---
paru -S mihomo
# systemctl edit mihomo
[Service]
# Remove the original ExecStart
ExecStart=
ExecStart=/usr/bin/mihomo -d /srv/mihomo -f /srv/mihomo/config.yaml
# ---
mkdir /srv/mihomo
cd /srv/mihomo
chown -R mihomo:mihomo /srv/mihomo
usermod -a -G mihomo <user>
groups <user> # Check if the user is in the mihomo group
chmod g+w /srv/mihomo # Required for clashtui to create files.
chmod g+w /srv/mihomo/config.yaml # Required for clashtui to have write permissions.
systemctl enable mihomo # Enable at boot
systemctl restart mihomo # Start the service
It's advisable to test the mihomo service with a functional mihomo configuration to verify its success. Check for any missing meta-rules-dat files.
Install scoop (optional):
irm get.scoop.sh -outfile 'install.ps1'
.\install.ps1 -ScoopDir 'D:\Scoop' -ScoopGlobalDir 'D:\ScoopGlobal' -NoProxy # I chose to install it in the D drive.
For instance:
scoop install mihomo
to install mihomo. Alternatively, download a suitable mihomo for your system and place it in D:/PortableProgramFiles/mihomo/mihomo.exe
.D:/MyAppData/mihomo
and a file D:/MyAppData/mihomo/config.yaml
.If mihomo client (e.g., metacubexd) can access but requires a proxy for certain websites:
D:\Scoop\apps\mihomo\1.17.0\mihomo.exe
instead of the current path. After updating mihomo, repeat this process.D:/PortableProgramFiles/mihomo/mihomo.exe
.For instance: ArchLinux
# Check for the latest [PKGBUILD](https://github.com/JohanChane/clashtui/blob/main/PKGBUILD).
paru -S clashtui # For other Linux distributions, manually download and place clashtui in the PATH.
clashtui # Initial run generates default files in ~/.config/clashtui.
# nvim ~/.config/clashtui/config.toml
[default]
# Parameters correspond to the command <clash_core_path> -d <clash_cfg_dir> -f <clash_cfg_path>
clash_core_path = "mihomo"
clash_cfg_dir = "/srv/mihomo"
clash_cfg_path = "/srv/mihomo/config.yaml"
clash_srv_name = "mihomo" # systemctl {restart | stop} <clash_srv_name>
# ---
If you have cargo, you can use cargo install clashtui
to install clashtui.
Manually download and install clashtui or install via scoop bucket add extras; scoop install clashtui
. Later, the file clashtui.json will be added to the scoop extras repository. If not added to scoop extras, you can place the clashtui.json file in D:\Scoop\buckets\extras\bucket\clashtui.json
for scoop install clashtui
to work.
Running clashtui for the first time generates default files in %APPDATA%/clashtui
.
Modify %APPDATA%/clashtui/config.toml
:
[default]
# Parameters correspond to the command <clash_core_path> -d <clash_cfg_dir> -f <clash_cfg_path>
#clash_core_path = "D:/PortableProgramFiles/mihomo/mihomo.exe"
clash_core_path = "D:/Scoop/shims/mihomo.exe" # `Get-Command mihomo`
clash_cfg_dir = "D:/MyAppData/mihomo"
clash_cfg_path = "D:/MyAppData/mihomo/config.yaml"
clash_srv_name = "mihomo" # nssm {install | remove | restart | stop | edit} <clash_srv_name>
After editing, add clashtui and nssm to PATH:
scoop install nssm
D:/PortableProgramFiles/clashtui
to PATH.Run clashtui. In ClashSrvCtl
, select InstallSrv
. The program will install the mihomo
core service based on the configured settings. This service starts automatically at boot. After installation, start the core service, and input R
to proceed.
basic_clash_config.yaml
Manually configure {~/.config | %APPDATA%}/clashtui/basic_clash_config.yaml
. Some basic fields in this file merge into clash_cfg_path
. Refer to here to configure tun mode.
Choose one of the following methods:
clashtui
command to PATH. Start by typing clashtui
in the terminal, win + r
, or in File Explorer's address bar.clashtui
.clashtui uses crossterm and ratatui for implementation. For optimal usage on Windows, consider using Windows Terminal. Set the command startup method in Windows Terminal to use Windows Terminal
for executing the clashtui
command.
Create a folder named data
in the clashtui program directory. This stores data in data
instead of ~/.config/clashtui
OR %APPDATA%/clashtui
.
Press ?
to display help.
i
to input Name (try avoiding suffixes) and Uri.U
to update dependencies for the Profile. It defaults to using its proxy for updates. If using tun mode or system proxy with no available nodes, stop the mihomo service (press S
) before updating.Enter
to select the Profile.http://127.0.0.1:9090/ui
in the browser.If the Windows platform can't open http://127.0.0.1:9090/ui
:
ClashSrvCtl
, choose TestClashConfig
to check syntax and auto-downloaded geo files.L
to view logs. (H
opens clashtui config dir. G
opens clash config dir. Check if the related files are correct.)netstat -aon | findstr "9090"
to check if the port exists. If not, consider using a compatible version of mihomo.mihomo
through the firewall.Supports importing file configurations. Input the file path as Uri
.
t
to switch to Templates.template_proxy_providers
, press e
to edit, and input subscription links (copy without modification) as needed.For example:
https://....
https://....
# Supports comments
#https://....
Enter
to generate configurations in Profile
. Press p
to switch back to Profile, and Enter
to select the configuration.Downloaded clashtui versions usually include templates. If not, the latest templates are available here.
Configure in ./data/config.toml
. %s
will automatically replace with the selected file's path.
For Linux:
[default]
edit_cmd = "alacritty -e nvim %s"
opendir_cmd = "alacritty -e ranger %s"
For Windows:
[default]
edit_cmd = "notepad %s"
The template feature is unique to clashtui. Refer to provided sample templates for usage instructions.
Define repeatedly used fields:
pp: &pp {interval: 3600, intehealth-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}}
delay_test: &delay_test {url: https://www.gstatic.com/generate_204, interval: 300}
Generate a proxy-provider
for each link in template_proxy_providers
:
proxy-providers:
provider:
tpl_param:
type: http # The type field should be placed here, not in pp, as it's used for updating resources.
<<: *pp
Generate a Select, Auto
proxy-group
for each proxy-provider:
proxy-groups:
- name: "Select"
tpl_param:
providers: ["provider"]
type: select
- name: "Auto"
tpl_param:
providers: ["provider"]
type: url-test
<<: *delay_test
Use Select, Auto
proxy-groups:
proxy-groups:
- name: "Entry"
type: select
proxies:
- <Auto>
- <Select>
basic_clash_config.yaml
: Contains basic fields for mihomo configuration, which will be merged into clash_cfg_path
.config.yaml
: Configuration file for clashtui.This project is for educational and reference purposes only. The author doesn't guarantee the accuracy, completeness, or applicability of the code in this project. Users should use the code at their own risk.
The author is not responsible for any direct or indirect losses caused by the use of this project's code, including but not limited to data loss, computer damage, or business interruption.
Before using the code in this project, users should fully understand its functionality and potential risks. Seek professional advice if necessary. The author bears no responsibility for any consequences resulting from the use of this project's code.
When using the code in this project, abide by relevant laws and regulations. Do not use it for illegal activities or actions that infringe upon others' rights.
The author reserves the right to interpret this disclaimer and may modify and update it at any time.