sing-box-cli 0.0.4__tar.gz → 0.0.5__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.5}/CHANGELOG.md +5 -1
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/PKG-INFO +20 -4
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/README.md +19 -3
- sing_box_cli-0.0.5/assets/image.png +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/pyproject.toml +1 -1
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/src/sing_box_service/__init__.py +1 -1
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/src/sing_box_service/main.py +1 -5
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/src/sing_box_service/service.py +37 -4
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/uv.lock +1 -1
- sing_box_cli-0.0.4/assets/image.png +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/.github/dependabot.yml +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/.github/workflows/main.yml +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/.gitignore +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/.pre-commit-config.yaml +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/.vscode/PythonImportHelper-v2-Completion.json +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/.vscode/settings.json +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/LICENSE +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/scripts/bump.sh +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/scripts/format.sh +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/scripts/lint.sh +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/src/sing_box_service/config.py +0 -0
- {sing_box_cli-0.0.4 → sing_box_cli-0.0.5}/src/sing_box_service/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sing-box-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
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
|
|
@@ -51,7 +51,15 @@ cross-platform sing-box service manager
|
|
|
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
65
|
# root
|
|
@@ -62,14 +70,22 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
62
70
|
ln -s $(which uv) /usr/local/bin/uv
|
|
63
71
|
```
|
|
64
72
|
|
|
65
|
-
###
|
|
73
|
+
### sing-box
|
|
66
74
|
|
|
67
75
|
```bash
|
|
68
|
-
|
|
76
|
+
uv tool install sing-box-cli
|
|
69
77
|
```
|
|
70
78
|
|
|
71
79
|
## Run
|
|
72
80
|
|
|
81
|
+
Windows in Admin powershell
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
sing-box-cli --help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Linux
|
|
88
|
+
|
|
73
89
|
```bash
|
|
74
90
|
sudo uv tool run sing-box-cli --help
|
|
75
91
|
```
|
|
@@ -6,7 +6,15 @@ cross-platform sing-box service manager
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
###
|
|
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
|
|
10
18
|
|
|
11
19
|
```bash
|
|
12
20
|
# root
|
|
@@ -17,14 +25,22 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
17
25
|
ln -s $(which uv) /usr/local/bin/uv
|
|
18
26
|
```
|
|
19
27
|
|
|
20
|
-
###
|
|
28
|
+
### sing-box
|
|
21
29
|
|
|
22
30
|
```bash
|
|
23
|
-
|
|
31
|
+
uv tool install sing-box-cli
|
|
24
32
|
```
|
|
25
33
|
|
|
26
34
|
## Run
|
|
27
35
|
|
|
36
|
+
Windows in Admin powershell
|
|
37
|
+
|
|
38
|
+
```powershell
|
|
39
|
+
sing-box-cli --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Linux
|
|
43
|
+
|
|
28
44
|
```bash
|
|
29
45
|
sudo uv tool run sing-box-cli --help
|
|
30
46
|
```
|
|
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.5"
|
|
213
213
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
214
214
|
serialize = ["{major}.{minor}.{patch}"]
|
|
215
215
|
search = "{current_version}"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import subprocess
|
|
3
2
|
import sys
|
|
4
3
|
|
|
5
4
|
import typer
|
|
@@ -132,10 +131,7 @@ def config_show() -> None:
|
|
|
132
131
|
def logs() -> None:
|
|
133
132
|
"""Show sing-box service logs"""
|
|
134
133
|
cli = SingBoxCLI()
|
|
135
|
-
|
|
136
|
-
print("⚠️ Log viewing is not supported on Windows")
|
|
137
|
-
else:
|
|
138
|
-
subprocess.run(["journalctl", "-u", "sing-box", "-o", "cat", "-f"])
|
|
134
|
+
cli.service.logs()
|
|
139
135
|
|
|
140
136
|
|
|
141
137
|
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,9 @@ WantedBy=multi-user.target
|
|
|
172
202
|
except Exception:
|
|
173
203
|
return "Stopped"
|
|
174
204
|
|
|
205
|
+
def logs(self) -> None:
|
|
206
|
+
subprocess.run(["journalctl", "-u", "sing-box", "-o", "cat", "-f"])
|
|
207
|
+
|
|
175
208
|
def disable(self) -> None:
|
|
176
209
|
self.stop()
|
|
177
210
|
subprocess.run(["systemctl", "disable", self.service_name])
|
|
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
|
|
File without changes
|