sing-box-cli 0.0.4__tar.gz → 0.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/CHANGELOG.md +19 -1
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/PKG-INFO +31 -11
- sing_box_cli-0.0.6/README.md +50 -0
- sing_box_cli-0.0.6/assets/image.png +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/pyproject.toml +1 -1
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/src/sing_box_service/__init__.py +1 -1
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/src/sing_box_service/config.py +8 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/src/sing_box_service/main.py +8 -5
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/src/sing_box_service/service.py +38 -4
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/uv.lock +1 -1
- sing_box_cli-0.0.4/README.md +0 -30
- sing_box_cli-0.0.4/assets/image.png +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/.github/dependabot.yml +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/.github/workflows/main.yml +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/.gitignore +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/.pre-commit-config.yaml +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/.vscode/PythonImportHelper-v2-Completion.json +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/.vscode/settings.json +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/LICENSE +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/scripts/bump.sh +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/scripts/format.sh +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/scripts/lint.sh +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.6}/src/sing_box_service/py.typed +0 -0
|
@@ -2,7 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
## 0.0.
|
|
5
|
+
## 0.0.6 - 2025-01-09
|
|
6
|
+
|
|
7
|
+
### 🚀 Features
|
|
8
|
+
|
|
9
|
+
- Add config clean_cache
|
|
10
|
+
|
|
11
|
+
### 📚 Documentation
|
|
12
|
+
|
|
13
|
+
- Update linux install and run
|
|
14
|
+
|
|
15
|
+
### ⚙️ Miscellaneous Tasks
|
|
16
|
+
|
|
17
|
+
- Update linux show logs prompt
|
|
18
|
+
|
|
19
|
+
## 0.0.5 - 2025-01-07
|
|
20
|
+
|
|
21
|
+
### 🚀 Features
|
|
22
|
+
|
|
23
|
+
- Enable windows logs
|
|
6
24
|
|
|
7
25
|
### 🐛 Bug Fixes
|
|
8
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sing-box-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: cross-platform sing-box-service manager.
|
|
5
5
|
Project-URL: Homepage, https://github.com/aittcuszz/sing-box-service
|
|
6
6
|
Project-URL: Issues, https://github.com/atticuszz/sing-box-service/issues
|
|
@@ -45,31 +45,51 @@ Description-Content-Type: text/markdown
|
|
|
45
45
|
|
|
46
46
|
# Sing-Box CLI
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
🎤 Cross-platform sing-box service manager.
|
|
49
49
|
|
|
50
50
|

|
|
51
51
|
|
|
52
52
|
## Install
|
|
53
53
|
|
|
54
|
-
###
|
|
54
|
+
### uv
|
|
55
|
+
|
|
56
|
+
Windows
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Linux
|
|
55
63
|
|
|
56
64
|
```bash
|
|
57
|
-
# root
|
|
58
|
-
sudo su
|
|
59
|
-
# install as root
|
|
60
65
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
61
|
-
# create link
|
|
62
|
-
ln -s $(which uv) /usr/local/bin/uv
|
|
63
66
|
```
|
|
64
67
|
|
|
65
|
-
###
|
|
68
|
+
### sing-box
|
|
69
|
+
|
|
70
|
+
Windows
|
|
71
|
+
|
|
72
|
+
```powershell
|
|
73
|
+
uv tool install sing-box-cli
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Linux
|
|
66
77
|
|
|
67
78
|
```bash
|
|
68
|
-
|
|
79
|
+
uv tool install sing-box-cli
|
|
80
|
+
sudo ln -sf $(which sing-box-cli) /usr/local/bin/
|
|
69
81
|
```
|
|
70
82
|
|
|
71
83
|
## Run
|
|
72
84
|
|
|
85
|
+
Windows in Admin powershell
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
sing-box-cli --help
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Linux
|
|
92
|
+
|
|
73
93
|
```bash
|
|
74
|
-
sudo
|
|
94
|
+
sudo sing-box-cli --help
|
|
75
95
|
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Sing-Box CLI
|
|
2
|
+
|
|
3
|
+
🎤 Cross-platform sing-box service manager.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
### uv
|
|
10
|
+
|
|
11
|
+
Windows
|
|
12
|
+
|
|
13
|
+
```powershell
|
|
14
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Linux
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### sing-box
|
|
24
|
+
|
|
25
|
+
Windows
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
uv tool install sing-box-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Linux
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uv tool install sing-box-cli
|
|
35
|
+
sudo ln -sf $(which sing-box-cli) /usr/local/bin/
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Run
|
|
39
|
+
|
|
40
|
+
Windows in Admin powershell
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
sing-box-cli --help
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Linux
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
sudo sing-box-cli --help
|
|
50
|
+
```
|
|
Binary file
|
|
@@ -209,7 +209,7 @@ sort_commits = "oldest"
|
|
|
209
209
|
|
|
210
210
|
|
|
211
211
|
[tool.bumpversion]
|
|
212
|
-
current_version = "0.0.
|
|
212
|
+
current_version = "0.0.6"
|
|
213
213
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
214
214
|
serialize = ["{major}.{minor}.{patch}"]
|
|
215
215
|
search = "{current_version}"
|
|
@@ -35,6 +35,7 @@ class Config:
|
|
|
35
35
|
|
|
36
36
|
self.config_file = self.install_dir / "config.json"
|
|
37
37
|
self.subscription_file = self.install_dir / "subscription.txt"
|
|
38
|
+
self.cache_db = self.install_dir / "cache.db"
|
|
38
39
|
|
|
39
40
|
def init_directories(self) -> None:
|
|
40
41
|
self.install_dir.mkdir(parents=True, exist_ok=True)
|
|
@@ -93,3 +94,10 @@ class Config:
|
|
|
93
94
|
print(self.sub_url)
|
|
94
95
|
else:
|
|
95
96
|
print("❌ No subscription URL found.")
|
|
97
|
+
|
|
98
|
+
def clean_cache(self) -> None:
|
|
99
|
+
if self.cache_db.exists():
|
|
100
|
+
self.cache_db.unlink()
|
|
101
|
+
print("🗑️ Cache database removed.")
|
|
102
|
+
else:
|
|
103
|
+
print("❌ Cache database not found.")
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import subprocess
|
|
3
2
|
import sys
|
|
4
3
|
|
|
5
4
|
import typer
|
|
@@ -128,14 +127,18 @@ def config_show() -> None:
|
|
|
128
127
|
cli.config.show_config()
|
|
129
128
|
|
|
130
129
|
|
|
130
|
+
@config.command("clean_cache")
|
|
131
|
+
def config_clean_cache() -> None:
|
|
132
|
+
"""Clean cache database"""
|
|
133
|
+
cli = SingBoxCLI()
|
|
134
|
+
cli.config.clean_cache()
|
|
135
|
+
|
|
136
|
+
|
|
131
137
|
@app.command()
|
|
132
138
|
def logs() -> None:
|
|
133
139
|
"""Show sing-box service logs"""
|
|
134
140
|
cli = SingBoxCLI()
|
|
135
|
-
|
|
136
|
-
print("⚠️ Log viewing is not supported on Windows")
|
|
137
|
-
else:
|
|
138
|
-
subprocess.run(["journalctl", "-u", "sing-box", "-o", "cat", "-f"])
|
|
141
|
+
cli.service.logs()
|
|
139
142
|
|
|
140
143
|
|
|
141
144
|
def main() -> None:
|
|
@@ -26,6 +26,9 @@ class ServiceManager:
|
|
|
26
26
|
def status(self) -> str:
|
|
27
27
|
raise NotImplementedError()
|
|
28
28
|
|
|
29
|
+
def logs(self) -> None:
|
|
30
|
+
raise NotImplementedError()
|
|
31
|
+
|
|
29
32
|
def disable(self) -> None:
|
|
30
33
|
raise NotImplementedError()
|
|
31
34
|
|
|
@@ -34,6 +37,7 @@ class WindowsServiceManager(ServiceManager):
|
|
|
34
37
|
def __init__(self, config: Config):
|
|
35
38
|
super().__init__(config)
|
|
36
39
|
self.task_name = "sing-box"
|
|
40
|
+
self.log_file = self.config.install_dir / "sing-box.log"
|
|
37
41
|
|
|
38
42
|
def create_service(self) -> None:
|
|
39
43
|
start_script = self.config.install_dir / "start-singbox.ps1"
|
|
@@ -47,16 +51,29 @@ public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
|
|
47
51
|
$console = [Console.Window]::GetConsoleWindow()
|
|
48
52
|
[Console.Window]::ShowWindow($console, 0)
|
|
49
53
|
|
|
54
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
55
|
+
$OutputEncoding = [System.Text.Encoding]::UTF8
|
|
56
|
+
chcp 65001 | Out-Null
|
|
57
|
+
|
|
50
58
|
Set-Location "{self.config.install_dir}"
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
|
|
60
|
+
if (Test-Path "{self.log_file}") {{
|
|
61
|
+
Clear-Content "{self.log_file}"
|
|
62
|
+
}}
|
|
63
|
+
|
|
64
|
+
try {{
|
|
65
|
+
& "{self.config.bin_path}" tools synctime -w -C "{self.config.install_dir}" *>&1 | Tee-Object -FilePath "{self.log_file}" -Append
|
|
66
|
+
& "{self.config.bin_path}" run -C "{self.config.install_dir}" *>&1 | Tee-Object -FilePath "{self.log_file}" -Append
|
|
67
|
+
}} catch {{
|
|
68
|
+
$_ | Out-File -FilePath "{self.log_file}" -Append
|
|
69
|
+
}}
|
|
53
70
|
"""
|
|
54
|
-
start_script.write_text(script_content)
|
|
71
|
+
start_script.write_text(script_content, encoding="utf-8")
|
|
55
72
|
|
|
56
73
|
ps_command = f"""
|
|
57
74
|
$action = New-ScheduledTaskAction `
|
|
58
75
|
-Execute "pwsh.exe" `
|
|
59
|
-
-Argument "-ExecutionPolicy Bypass -File `"{start_script}`""
|
|
76
|
+
-Argument "-ExecutionPolicy Bypass -NoLogo -WindowStyle Hidden -File `"{start_script}`""
|
|
60
77
|
|
|
61
78
|
$trigger = New-ScheduledTaskTrigger -AtLogon
|
|
62
79
|
$principal = New-ScheduledTaskPrincipal -UserId "{self.config.user}" -RunLevel Highest
|
|
@@ -111,6 +128,19 @@ if ($task) {{
|
|
|
111
128
|
)
|
|
112
129
|
return result.stdout.strip()
|
|
113
130
|
|
|
131
|
+
def logs(self) -> None:
|
|
132
|
+
if not self.log_file.exists():
|
|
133
|
+
print("⚠️ Log file not found")
|
|
134
|
+
return
|
|
135
|
+
try:
|
|
136
|
+
print("⌛ Showing real-time logs (Press Ctrl+C to exit)")
|
|
137
|
+
ps_command = (
|
|
138
|
+
f"Get-Content -Path '{self.log_file}' -Wait -Tail 50 -Encoding UTF8"
|
|
139
|
+
)
|
|
140
|
+
subprocess.run(["pwsh", "-Command", ps_command])
|
|
141
|
+
except KeyboardInterrupt:
|
|
142
|
+
return
|
|
143
|
+
|
|
114
144
|
def disable(self) -> None:
|
|
115
145
|
self.stop()
|
|
116
146
|
subprocess.run(
|
|
@@ -172,6 +202,10 @@ WantedBy=multi-user.target
|
|
|
172
202
|
except Exception:
|
|
173
203
|
return "Stopped"
|
|
174
204
|
|
|
205
|
+
def logs(self) -> None:
|
|
206
|
+
print("⌛ Showing real-time logs (Press Ctrl+C to exit)")
|
|
207
|
+
subprocess.run(["journalctl", "-u", "sing-box", "-o", "cat", "-f"])
|
|
208
|
+
|
|
175
209
|
def disable(self) -> None:
|
|
176
210
|
self.stop()
|
|
177
211
|
subprocess.run(["systemctl", "disable", self.service_name])
|
sing_box_cli-0.0.4/README.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Sing-Box CLI
|
|
2
|
-
|
|
3
|
-
cross-platform sing-box service manager
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
### Init UV
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
# root
|
|
13
|
-
sudo su
|
|
14
|
-
# install as root
|
|
15
|
-
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
16
|
-
# create link
|
|
17
|
-
ln -s $(which uv) /usr/local/bin/uv
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Add sing-box
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
sudo uv tool install sing-box-cli
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Run
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
sudo uv tool run sing-box-cli --help
|
|
30
|
-
```
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|