lingling 2.2.0__tar.gz → 2.2.0.post1__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.
- {lingling-2.2.0 → lingling-2.2.0.post1}/LICENSE +24 -24
- lingling-2.2.0.post1/PKG-INFO +113 -0
- lingling-2.2.0.post1/README.md +94 -0
- {lingling-2.2.0 → lingling-2.2.0.post1}/lingling/__init__.py +36 -30
- {lingling-2.2.0 → lingling-2.2.0.post1}/lingling/__main__.py +6 -4
- lingling-2.2.0.post1/lingling/cli.py +170 -0
- lingling-2.2.0.post1/lingling/defaults.env +148 -0
- lingling-2.2.0.post1/lingling/lock.py +81 -0
- lingling-2.2.0.post1/lingling/net.py +41 -0
- lingling-2.2.0.post1/lingling/plug/index.ts +191 -0
- {lingling-2.2.0 → lingling-2.2.0.post1}/lingling/plug/package.json +1 -1
- lingling-2.2.0.post1/lingling/plug/shared.ts +33 -0
- lingling-2.2.0.post1/lingling/plug/tui.ts +899 -0
- lingling-2.2.0.post1/lingling/pool.py +30 -0
- lingling-2.2.0.post1/lingling/profile.py +219 -0
- lingling-2.2.0.post1/lingling/proof.py +296 -0
- lingling-2.2.0.post1/lingling/proxy.py +316 -0
- lingling-2.2.0.post1/lingling/route.py +385 -0
- lingling-2.2.0.post1/lingling/settings.py +167 -0
- lingling-2.2.0.post1/lingling/setup.py +271 -0
- lingling-2.2.0.post1/lingling/state.py +83 -0
- lingling-2.2.0.post1/lingling/store.py +39 -0
- lingling-2.2.0.post1/lingling/term.py +42 -0
- lingling-2.2.0.post1/lingling/tunnel.py +658 -0
- lingling-2.2.0.post1/lingling/update.py +872 -0
- lingling-2.2.0.post1/lingling/watch.py +877 -0
- lingling-2.2.0.post1/lingling/win32.py +58 -0
- lingling-2.2.0.post1/lingling.egg-info/PKG-INFO +113 -0
- {lingling-2.2.0 → lingling-2.2.0.post1}/lingling.egg-info/SOURCES.txt +23 -1
- {lingling-2.2.0 → lingling-2.2.0.post1}/pyproject.toml +54 -34
- lingling-2.2.0.post1/tests/test_api.py +114 -0
- lingling-2.2.0.post1/tests/test_cli.py +134 -0
- lingling-2.2.0.post1/tests/test_lock.py +86 -0
- lingling-2.2.0.post1/tests/test_net.py +115 -0
- lingling-2.2.0.post1/tests/test_pool.py +54 -0
- lingling-2.2.0.post1/tests/test_profile.py +166 -0
- lingling-2.2.0.post1/tests/test_proof.py +136 -0
- lingling-2.2.0.post1/tests/test_proxy.py +186 -0
- lingling-2.2.0.post1/tests/test_rescue.py +391 -0
- lingling-2.2.0.post1/tests/test_route.py +227 -0
- lingling-2.2.0.post1/tests/test_settings.py +86 -0
- lingling-2.2.0.post1/tests/test_setup.py +131 -0
- lingling-2.2.0.post1/tests/test_state.py +99 -0
- lingling-2.2.0.post1/tests/test_term.py +43 -0
- lingling-2.2.0.post1/tests/test_update.py +471 -0
- lingling-2.2.0.post1/tests/test_watch.py +172 -0
- lingling-2.2.0/PKG-INFO +0 -109
- lingling-2.2.0/README.md +0 -90
- lingling-2.2.0/lingling/cli.py +0 -133
- lingling-2.2.0/lingling/lock.py +0 -65
- lingling-2.2.0/lingling/plug/index.ts +0 -73
- lingling-2.2.0/lingling/plug/tui.ts +0 -741
- lingling-2.2.0/lingling/pool.py +0 -21
- lingling-2.2.0/lingling/profile.py +0 -199
- lingling-2.2.0/lingling/proof.py +0 -189
- lingling-2.2.0/lingling/proxy.py +0 -224
- lingling-2.2.0/lingling/route.py +0 -290
- lingling-2.2.0/lingling/settings.py +0 -209
- lingling-2.2.0/lingling/setup.py +0 -192
- lingling-2.2.0/lingling/state.py +0 -83
- lingling-2.2.0/lingling/tunnel.py +0 -532
- lingling-2.2.0/lingling/update.py +0 -668
- lingling-2.2.0/lingling/watch.py +0 -644
- lingling-2.2.0/lingling.egg-info/PKG-INFO +0 -109
- {lingling-2.2.0 → lingling-2.2.0.post1}/lingling.egg-info/dependency_links.txt +0 -0
- {lingling-2.2.0 → lingling-2.2.0.post1}/lingling.egg-info/entry_points.txt +0 -0
- {lingling-2.2.0 → lingling-2.2.0.post1}/lingling.egg-info/top_level.txt +0 -0
- {lingling-2.2.0 → lingling-2.2.0.post1}/setup.cfg +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
Lingling License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Lingling contributors
|
|
4
|
-
|
|
5
|
-
You are free to use and run this software, in whole or in part, for any
|
|
6
|
-
purpose, at no cost.
|
|
7
|
-
|
|
8
|
-
You may NOT:
|
|
9
|
-
- sell this software, or offer it (modified or not) as a paid product or
|
|
10
|
-
paid service;
|
|
11
|
-
- distribute modified versions of this software, or publish derivative
|
|
12
|
-
works based on it.
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies of the software.
|
|
16
|
-
|
|
17
|
-
All rights not expressly granted above are reserved by the copyright holder.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
23
|
-
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Lingling License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lingling contributors
|
|
4
|
+
|
|
5
|
+
You are free to use and run this software, in whole or in part, for any
|
|
6
|
+
purpose, at no cost.
|
|
7
|
+
|
|
8
|
+
You may NOT:
|
|
9
|
+
- sell this software, or offer it (modified or not) as a paid product or
|
|
10
|
+
paid service;
|
|
11
|
+
- distribute modified versions of this software, or publish derivative
|
|
12
|
+
works based on it.
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies of the software.
|
|
16
|
+
|
|
17
|
+
All rights not expressly granted above are reserved by the copyright holder.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
23
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lingling
|
|
3
|
+
Version: 2.2.0.post1
|
|
4
|
+
Summary: OpenCode over local Route64 WireGuard tunnels.
|
|
5
|
+
License-Expression: LicenseRef-Lingling
|
|
6
|
+
Keywords: opencode,route64,wireguard,ipv6,proxy
|
|
7
|
+
Classifier: Environment :: Console
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Internet :: Proxy Servers
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# Lingling
|
|
21
|
+
|
|
22
|
+
OpenCode gives away good models for free. the catch is a daily limit -- it can
|
|
23
|
+
follow an IP, a request size, or one session record. a new session sometimes
|
|
24
|
+
keeps working when an old one is stuck.
|
|
25
|
+
|
|
26
|
+
Lingling spreads requests across the `/64`s of your own Route64 tunnel. it
|
|
27
|
+
moves a lane at half the day's allowance, before the limit, so one bucket never
|
|
28
|
+
stops the session. OpenCode keeps the same local window the whole time.
|
|
29
|
+
|
|
30
|
+
## Needs
|
|
31
|
+
|
|
32
|
+
- Windows
|
|
33
|
+
- a free [Route64](https://manager.route64.org) account
|
|
34
|
+
- [WireGuard](https://www.wireguard.com/install/) -- setup installs it if missing
|
|
35
|
+
- `opencode` on your PATH
|
|
36
|
+
- Python 3.11 or newer
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install lingling
|
|
42
|
+
lingling
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
first launch runs setup.
|
|
46
|
+
|
|
47
|
+
## Setup
|
|
48
|
+
|
|
49
|
+
1. sign in at [manager.route64.org](https://manager.route64.org).
|
|
50
|
+
2. open **IPv6 Tunnelbroker** and create a **WireGuard** tunnel.
|
|
51
|
+
3. download or copy the WireGuard config.
|
|
52
|
+
4. open **List IP subnets** and copy the routed `/56`.
|
|
53
|
+
|
|
54
|
+
run `lingling` and paste the config path when asked. drag and drop works.
|
|
55
|
+
|
|
56
|
+
the address inside the config is the tunnel `/64`:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
Address = 2001:db8:1:2::2/64
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
its not the block Lingling rotates through. use the routed `/56` that Route64
|
|
63
|
+
shows separately, for example:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
2001:db8:1:300::/56
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
setup installs a WireGuard service called `lingling`, asks for admin once, and
|
|
70
|
+
starts the service only while Lingling is open. to replace the profile:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
lingling setup --reset
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Use
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
lingling
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Lingling starts the tunnel, picks the first unused `/64`, and opens OpenCode
|
|
83
|
+
with its own local proxy. if a newer build is out, launch offers it first; Y
|
|
84
|
+
installs it and restarts into it before OpenCode opens. it spreads each lane
|
|
85
|
+
to half the daily allowance before moving. a free limit spends the lane and
|
|
86
|
+
moves to a fresh one. if that fresh lane hits the limit too, the limit
|
|
87
|
+
follows the session, not the address, so Lingling stops there and burns no
|
|
88
|
+
more lanes. the lane stays in place for
|
|
89
|
+
the new session and Lingling opens a fresh root session with the current chat
|
|
90
|
+
context first. if that fresh session is rejected too, it falls back to a
|
|
91
|
+
summary handoff. the old chat stays as a backup; the new session opens in the
|
|
92
|
+
same folder with the model and effort you picked. spent lanes reset at
|
|
93
|
+
`00:00 UTC`.
|
|
94
|
+
|
|
95
|
+
the proof log sits in the data folder -- `%TEMP%\lingling-data\route.log`
|
|
96
|
+
by default.
|
|
97
|
+
|
|
98
|
+
every path, name, timing, and color can be overridden with a `LINGLING_*`
|
|
99
|
+
environment variable; defaults live in `lingling/defaults.env`.
|
|
100
|
+
|
|
101
|
+
## Commands
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
lingling start a session
|
|
105
|
+
lingling setup set up or replace your Route64 profile
|
|
106
|
+
lingling setup --reset remove the old profile and run setup again
|
|
107
|
+
lingling update install the newest build
|
|
108
|
+
lingling uninstall remove the profile and tunnel
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Lingling
|
|
2
|
+
|
|
3
|
+
OpenCode gives away good models for free. the catch is a daily limit -- it can
|
|
4
|
+
follow an IP, a request size, or one session record. a new session sometimes
|
|
5
|
+
keeps working when an old one is stuck.
|
|
6
|
+
|
|
7
|
+
Lingling spreads requests across the `/64`s of your own Route64 tunnel. it
|
|
8
|
+
moves a lane at half the day's allowance, before the limit, so one bucket never
|
|
9
|
+
stops the session. OpenCode keeps the same local window the whole time.
|
|
10
|
+
|
|
11
|
+
## Needs
|
|
12
|
+
|
|
13
|
+
- Windows
|
|
14
|
+
- a free [Route64](https://manager.route64.org) account
|
|
15
|
+
- [WireGuard](https://www.wireguard.com/install/) -- setup installs it if missing
|
|
16
|
+
- `opencode` on your PATH
|
|
17
|
+
- Python 3.11 or newer
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install lingling
|
|
23
|
+
lingling
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
first launch runs setup.
|
|
27
|
+
|
|
28
|
+
## Setup
|
|
29
|
+
|
|
30
|
+
1. sign in at [manager.route64.org](https://manager.route64.org).
|
|
31
|
+
2. open **IPv6 Tunnelbroker** and create a **WireGuard** tunnel.
|
|
32
|
+
3. download or copy the WireGuard config.
|
|
33
|
+
4. open **List IP subnets** and copy the routed `/56`.
|
|
34
|
+
|
|
35
|
+
run `lingling` and paste the config path when asked. drag and drop works.
|
|
36
|
+
|
|
37
|
+
the address inside the config is the tunnel `/64`:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
Address = 2001:db8:1:2::2/64
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
its not the block Lingling rotates through. use the routed `/56` that Route64
|
|
44
|
+
shows separately, for example:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
2001:db8:1:300::/56
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
setup installs a WireGuard service called `lingling`, asks for admin once, and
|
|
51
|
+
starts the service only while Lingling is open. to replace the profile:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
lingling setup --reset
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Use
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
lingling
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Lingling starts the tunnel, picks the first unused `/64`, and opens OpenCode
|
|
64
|
+
with its own local proxy. if a newer build is out, launch offers it first; Y
|
|
65
|
+
installs it and restarts into it before OpenCode opens. it spreads each lane
|
|
66
|
+
to half the daily allowance before moving. a free limit spends the lane and
|
|
67
|
+
moves to a fresh one. if that fresh lane hits the limit too, the limit
|
|
68
|
+
follows the session, not the address, so Lingling stops there and burns no
|
|
69
|
+
more lanes. the lane stays in place for
|
|
70
|
+
the new session and Lingling opens a fresh root session with the current chat
|
|
71
|
+
context first. if that fresh session is rejected too, it falls back to a
|
|
72
|
+
summary handoff. the old chat stays as a backup; the new session opens in the
|
|
73
|
+
same folder with the model and effort you picked. spent lanes reset at
|
|
74
|
+
`00:00 UTC`.
|
|
75
|
+
|
|
76
|
+
the proof log sits in the data folder -- `%TEMP%\lingling-data\route.log`
|
|
77
|
+
by default.
|
|
78
|
+
|
|
79
|
+
every path, name, timing, and color can be overridden with a `LINGLING_*`
|
|
80
|
+
environment variable; defaults live in `lingling/defaults.env`.
|
|
81
|
+
|
|
82
|
+
## Commands
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
lingling start a session
|
|
86
|
+
lingling setup set up or replace your Route64 profile
|
|
87
|
+
lingling setup --reset remove the old profile and run setup again
|
|
88
|
+
lingling update install the newest build
|
|
89
|
+
lingling uninstall remove the profile and tunnel
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
see [LICENSE](LICENSE).
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
"""Lingling: OpenCode over local Route64 WireGuard tunnels."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import tempfile
|
|
5
|
+
import tomllib
|
|
6
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from . import settings
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _source_version() -> str:
|
|
13
|
+
"""Read the version from a checkout when no package is installed."""
|
|
14
|
+
path = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
doc = tomllib.loads(path.read_text(encoding="utf-8"))
|
|
18
|
+
return str(doc["project"]["version"])
|
|
19
|
+
except (OSError, KeyError, TypeError, ValueError):
|
|
20
|
+
return "0+unknown"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
try:
|
|
24
|
+
__version__ = version(settings.PACKAGE)
|
|
25
|
+
except PackageNotFoundError:
|
|
26
|
+
__version__ = _source_version()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def data_dir() -> Path:
|
|
30
|
+
"""Return the per-user folder for the profile, state, and logs."""
|
|
31
|
+
override = os.environ.get("LINGLING_DATA_DIR")
|
|
32
|
+
|
|
33
|
+
if override:
|
|
34
|
+
return Path(override)
|
|
35
|
+
|
|
36
|
+
return Path(tempfile.gettempdir()) / (settings.APP + settings.DATA_SUFFIX)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Command line entry: pick a command, then hand it the data folder."""
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
import sys
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
|
|
7
|
+
from . import (
|
|
8
|
+
__version__,
|
|
9
|
+
data_dir,
|
|
10
|
+
lock,
|
|
11
|
+
profile,
|
|
12
|
+
route,
|
|
13
|
+
settings,
|
|
14
|
+
setup,
|
|
15
|
+
term,
|
|
16
|
+
tunnel,
|
|
17
|
+
update,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
HELP = "\n".join(
|
|
21
|
+
(
|
|
22
|
+
f"{settings.APP} -- OpenCode over local {settings.NETWORK} tunnels",
|
|
23
|
+
"",
|
|
24
|
+
f" {settings.APP} start a session",
|
|
25
|
+
f" {settings.APP} setup set up or replace your "
|
|
26
|
+
f"{settings.NETWORK} profile",
|
|
27
|
+
f" {settings.APP} setup --reset remove the old profile,",
|
|
28
|
+
"then run setup again",
|
|
29
|
+
f" {settings.APP} update install the newest build",
|
|
30
|
+
f" {settings.APP} uninstall remove the profile and tunnel",
|
|
31
|
+
"",
|
|
32
|
+
"The first launch runs setup automatically.",
|
|
33
|
+
"",
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _busy(other: int) -> int:
|
|
39
|
+
"""Tell the user another session holds the lock."""
|
|
40
|
+
running = f" (pid {other})" if other > 0 else ""
|
|
41
|
+
print(settings.APP + " is already running" + running)
|
|
42
|
+
return 1
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _locked(folder, work: Callable[[], int]) -> int:
|
|
46
|
+
"""Run work under the session lock, or report the current owner."""
|
|
47
|
+
other = lock.claim(folder)
|
|
48
|
+
|
|
49
|
+
if other:
|
|
50
|
+
return _busy(other)
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
return work()
|
|
54
|
+
finally:
|
|
55
|
+
lock.release(folder)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _remove(folder, args: list[str]) -> int:
|
|
59
|
+
"""Confirm, remove the tunnel, then delete the data folder."""
|
|
60
|
+
data = profile.load(folder)
|
|
61
|
+
|
|
62
|
+
if "--yes" not in args:
|
|
63
|
+
if not sys.stdin.isatty():
|
|
64
|
+
print("refusing to uninstall without --yes")
|
|
65
|
+
return 1
|
|
66
|
+
|
|
67
|
+
if not term.confirm(
|
|
68
|
+
"Remove the " + settings.NAME + " profile and tunnel? [y/N] ",
|
|
69
|
+
default=False,
|
|
70
|
+
):
|
|
71
|
+
print("cancelled")
|
|
72
|
+
return 0
|
|
73
|
+
|
|
74
|
+
if data:
|
|
75
|
+
try:
|
|
76
|
+
tunnel.uninstall(data["service"], folder)
|
|
77
|
+
except Exception as exc:
|
|
78
|
+
term.warn("tunnel removal", exc)
|
|
79
|
+
|
|
80
|
+
try:
|
|
81
|
+
shutil.rmtree(folder)
|
|
82
|
+
except FileNotFoundError:
|
|
83
|
+
return 0
|
|
84
|
+
except OSError as exc:
|
|
85
|
+
term.warn("data folder removal", exc)
|
|
86
|
+
return 1
|
|
87
|
+
|
|
88
|
+
print(settings.NAME + " profile removed.")
|
|
89
|
+
print(
|
|
90
|
+
"Remove the package with: "
|
|
91
|
+
+ settings.PIP
|
|
92
|
+
+ " uninstall "
|
|
93
|
+
+ settings.PACKAGE
|
|
94
|
+
)
|
|
95
|
+
return 0
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _uninstall(args: list[str]) -> int:
|
|
99
|
+
"""Remove the saved profile and tunnel for this data folder."""
|
|
100
|
+
folder = data_dir()
|
|
101
|
+
return _locked(folder, lambda: _remove(folder, args))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _setup(args: list[str]) -> int:
|
|
105
|
+
"""Run setup while holding the session lock."""
|
|
106
|
+
folder = data_dir()
|
|
107
|
+
return _locked(folder, lambda: setup.command(args))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _start(folder, args: list[str], opencode: str) -> int:
|
|
111
|
+
"""Run setup first when needed, then start the session."""
|
|
112
|
+
if not profile.complete(folder) and not setup.run(folder):
|
|
113
|
+
return 1
|
|
114
|
+
|
|
115
|
+
return route.run(folder, args, opencode)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _session(args: list[str]) -> int:
|
|
119
|
+
"""Find OpenCode and start a session."""
|
|
120
|
+
opencode = shutil.which(settings.OPENCODE)
|
|
121
|
+
|
|
122
|
+
if opencode is None:
|
|
123
|
+
print(
|
|
124
|
+
settings.APP
|
|
125
|
+
+ ": couldn't find `"
|
|
126
|
+
+ settings.OPENCODE
|
|
127
|
+
+ "` on your PATH."
|
|
128
|
+
)
|
|
129
|
+
print("Install it first: " + settings.OPENCODE_URL)
|
|
130
|
+
return 1
|
|
131
|
+
|
|
132
|
+
folder = data_dir()
|
|
133
|
+
|
|
134
|
+
if profile.complete(folder) and not lock.owner(folder):
|
|
135
|
+
code = update.launch_prompt(folder, args)
|
|
136
|
+
if code is not None:
|
|
137
|
+
return code
|
|
138
|
+
|
|
139
|
+
return _locked(folder, lambda: _start(folder, args, opencode))
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def main(argv: list[str]) -> int:
|
|
143
|
+
"""Dispatch one command line and return its exit code."""
|
|
144
|
+
args = list(argv)
|
|
145
|
+
first = args[0] if args else ""
|
|
146
|
+
|
|
147
|
+
if first in ("setup", "--setup"):
|
|
148
|
+
return _setup(args[1:])
|
|
149
|
+
if first in ("update", "--update"):
|
|
150
|
+
return update.update_command(args[1:])
|
|
151
|
+
if first in ("uninstall", "--uninstall"):
|
|
152
|
+
return _uninstall(args[1:])
|
|
153
|
+
if first in ("--version", "-v"):
|
|
154
|
+
print(settings.APP + " " + __version__)
|
|
155
|
+
update.cached_hint(data_dir())
|
|
156
|
+
return 0
|
|
157
|
+
if first in ("--help", "-h"):
|
|
158
|
+
print(HELP)
|
|
159
|
+
return 0
|
|
160
|
+
|
|
161
|
+
return _session(args)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def entry() -> None:
|
|
165
|
+
"""Console entry point: turn a closed session into exit code 130."""
|
|
166
|
+
try:
|
|
167
|
+
sys.exit(main(sys.argv[1:]))
|
|
168
|
+
except KeyboardInterrupt:
|
|
169
|
+
print(settings.APP + ": closed")
|
|
170
|
+
sys.exit(130)
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# LINGLING_* defaults; the prefix after = is the value type.
|
|
2
|
+
LINGLING_DATA_SUFFIX=text:-data
|
|
3
|
+
LINGLING_NETWORK=text:Route64
|
|
4
|
+
LINGLING_PROFILE=text:profile.json
|
|
5
|
+
LINGLING_STATE=text:route-state.json
|
|
6
|
+
LINGLING_ROUTE_LOG=text:route.log
|
|
7
|
+
LINGLING_SWITCH=text:switch.request
|
|
8
|
+
LINGLING_RECOVER=text:recover.request
|
|
9
|
+
LINGLING_RESET=text:reset.request
|
|
10
|
+
LINGLING_FREE_LIMIT=text:provider.free-limit
|
|
11
|
+
LINGLING_TUNNEL_STATUS=text:tunnel.json
|
|
12
|
+
LINGLING_TUNNEL_STOP=text:tunnel.stop
|
|
13
|
+
LINGLING_TUNNEL_LOG=text:tunnel.log
|
|
14
|
+
LINGLING_INSTALL_LOG=text:wireguard-install.log
|
|
15
|
+
LINGLING_SESSION_LOCK=text:session.lock
|
|
16
|
+
LINGLING_UI_DIR=text:ui
|
|
17
|
+
LINGLING_PLUG_DIR=text:plug
|
|
18
|
+
LINGLING_TMP_SUFFIX=text:.tmp
|
|
19
|
+
LINGLING_HANDLED_SUFFIX=text:.handled
|
|
20
|
+
LINGLING_CLAIMED_SUFFIX=text:.claimed
|
|
21
|
+
LINGLING_OLD_SUFFIX=text:.old-
|
|
22
|
+
LINGLING_LANES_SCRIPT=text:lanes.txt
|
|
23
|
+
LINGLING_OK_TEXT=text:ok
|
|
24
|
+
LINGLING_PROOF_SESSION_COLOR=text:1;36
|
|
25
|
+
LINGLING_PROOF_SWITCH_COLOR=text:33
|
|
26
|
+
LINGLING_PROOF_LIMIT_COLOR=text:33
|
|
27
|
+
LINGLING_PROOF_WAIT_COLOR=text:2
|
|
28
|
+
LINGLING_PROOF_FAIL_COLOR=text:31
|
|
29
|
+
LINGLING_SETUP_HEAD_COLOR=text:1
|
|
30
|
+
LINGLING_SETUP_URL_COLOR=text:36
|
|
31
|
+
LINGLING_SETUP_OK_COLOR=text:32
|
|
32
|
+
LINGLING_SETUP_EOF=text:EOF
|
|
33
|
+
LINGLING_RESET_LABEL=text:00:00 UTC
|
|
34
|
+
LINGLING_CACHE=text:update-check.json
|
|
35
|
+
LINGLING_UPDATE_LOG=text:update.log
|
|
36
|
+
LINGLING_OPENCODE_CONFIG_CONTENT=text:{}
|
|
37
|
+
LINGLING_OPENCODE_STANDALONE=text:--standalone
|
|
38
|
+
LINGLING_PLUGIN_WALL=text:lingling.wall
|
|
39
|
+
LINGLING_PLUGIN_RESCUE=text:lingling.rescue
|
|
40
|
+
LINGLING_FREE_SUFFIX=text:-free
|
|
41
|
+
LINGLING_OPENCODE=text:opencode
|
|
42
|
+
LINGLING_OPENCODE_URL=text:https://opencode.ai
|
|
43
|
+
LINGLING_PROXY_HOST=text:127.0.0.1
|
|
44
|
+
LINGLING_NO_PROXY=text:localhost,127.0.0.1,::1
|
|
45
|
+
LINGLING_ROUTE64_URL=text:https://manager.route64.org
|
|
46
|
+
LINGLING_WIREGUARD_URL=text:https://download.wireguard.com/windows-client/wireguard-installer.exe
|
|
47
|
+
LINGLING_WIREGUARD_DOCS=text:https://www.wireguard.com/install/
|
|
48
|
+
LINGLING_WIREGUARD_ID=text:WireGuard.WireGuard
|
|
49
|
+
LINGLING_WIREGUARD=text:
|
|
50
|
+
LINGLING_WIREGUARD_DIR=text:WireGuard
|
|
51
|
+
LINGLING_WIREGUARD_EXE=text:wireguard.exe
|
|
52
|
+
LINGLING_UPDATE_URL=text:https://lingling-update.vercel.app/api/latest
|
|
53
|
+
LINGLING_REGISTRY_NAME=text:PyPI
|
|
54
|
+
LINGLING_REGISTRY_SOURCE=text:pypi
|
|
55
|
+
LINGLING_PIP=text:pip
|
|
56
|
+
LINGLING_PYTHON=text:python
|
|
57
|
+
LINGLING_PIPX_LABEL=text:pipx
|
|
58
|
+
LINGLING_UV_LABEL=text:uv
|
|
59
|
+
LINGLING_CLOCK_FORMAT=text:%H:%M:%S
|
|
60
|
+
LINGLING_LOG_FORMAT=text:%Y-%m-%d %H:%M:%S
|
|
61
|
+
LINGLING_SETUP_SCRIPT=text:wireguard-setup.ps1
|
|
62
|
+
LINGLING_INSTALL_RESULT=text:wireguard-install-result.txt
|
|
63
|
+
LINGLING_WIREGUARD_RESULT=text:wireguard-result.txt
|
|
64
|
+
LINGLING_WIREGUARD_INSTALLER=text:wireguard-installer.exe
|
|
65
|
+
LINGLING_PRIVATE_MODE=int:0o600
|
|
66
|
+
LINGLING_TOAST=int:8000
|
|
67
|
+
LINGLING_UPDATE_SCHEMA=int:1
|
|
68
|
+
LINGLING_MAX_LANES=int:65536
|
|
69
|
+
LINGLING_HOST_OFFSET=int:2
|
|
70
|
+
LINGLING_ROUTE_BITS=int:56
|
|
71
|
+
LINGLING_LANE_BITS=int:64
|
|
72
|
+
LINGLING_PROXY_MAX_HEAD=int:65536
|
|
73
|
+
LINGLING_PROXY_BACKLOG=int:32
|
|
74
|
+
LINGLING_PROXY_CHUNK=int:65536
|
|
75
|
+
LINGLING_PROXY_HEAD_CHUNK=int:4096
|
|
76
|
+
LINGLING_MS_SECOND=int:1000
|
|
77
|
+
LINGLING_TOKENS_K=int:1000
|
|
78
|
+
LINGLING_SECONDS_MINUTE=int:60
|
|
79
|
+
LINGLING_SECONDS_HOUR=int:3600
|
|
80
|
+
LINGLING_SECONDS_DAY=int:86400
|
|
81
|
+
LINGLING_RESET_SLACK=int:5
|
|
82
|
+
LINGLING_WATCH_RECENT=int:12
|
|
83
|
+
LINGLING_WATCH_DEPTH=int:16
|
|
84
|
+
LINGLING_WATCH_STRIKE=int:1
|
|
85
|
+
LINGLING_WATCH_SOFT=int:100
|
|
86
|
+
LINGLING_WATCH_DAY=int:200
|
|
87
|
+
LINGLING_WATCH_MAX=int:86700
|
|
88
|
+
LINGLING_WATCH_GATES=int:2
|
|
89
|
+
LINGLING_RESCUE_SEEN=int:64
|
|
90
|
+
LINGLING_RESCUE_TRIES=int:4
|
|
91
|
+
LINGLING_RETRY_DELAY_MS=int:3000
|
|
92
|
+
LINGLING_SERVICE_LOOKUP=int:20
|
|
93
|
+
LINGLING_SERVICE_LOOKUP_MS=int:500
|
|
94
|
+
LINGLING_UPDATE_CACHE_TTL=int:21600
|
|
95
|
+
LINGLING_UPDATE_UP_TTL=int:900
|
|
96
|
+
LINGLING_UPDATE_FAIL_TTL=int:3600
|
|
97
|
+
LINGLING_HELPER_WAIT=int:86400
|
|
98
|
+
LINGLING_HELPER_MAX=int:604800
|
|
99
|
+
LINGLING_WIREGUARD_MAX=int:67108864
|
|
100
|
+
LINGLING_PROCESS_WAIT=int:1048576
|
|
101
|
+
LINGLING_SETUP_MAX_CONFIG=int:65536
|
|
102
|
+
LINGLING_PROXY_SELECT=float:1.0
|
|
103
|
+
LINGLING_RECOVER_POLL=float:1.0
|
|
104
|
+
LINGLING_WATCH_PAUSE=float:0.5
|
|
105
|
+
# A limit on the fresh lane within this many seconds means the session is
|
|
106
|
+
# poisoned: keep that lane, offer a rescue, and stop moving that chat.
|
|
107
|
+
LINGLING_WATCH_PROBE=float:10.0
|
|
108
|
+
LINGLING_WATCH_GATE=float:300.0
|
|
109
|
+
LINGLING_WATCH_LONG=float:3600.0
|
|
110
|
+
LINGLING_WATCH_POLL=float:0.5
|
|
111
|
+
LINGLING_WATCH_FLOOR=float:1.0
|
|
112
|
+
LINGLING_RESCUE_WAIT=float:300.0
|
|
113
|
+
LINGLING_RESCUE_POLL=float:0.5
|
|
114
|
+
LINGLING_RESCUE_CHECK=float:5.0
|
|
115
|
+
LINGLING_WATCH_TIMEOUT=float:1.0
|
|
116
|
+
LINGLING_WATCH_JOIN=float:2.0
|
|
117
|
+
LINGLING_LOCK_TIMEOUT=float:5.0
|
|
118
|
+
LINGLING_TUNNEL_READY=float:60.0
|
|
119
|
+
LINGLING_TUNNEL_STOP_WAIT=float:15.0
|
|
120
|
+
LINGLING_TUNNEL_POLL=float:0.25
|
|
121
|
+
LINGLING_SERVICE_START=float:25.0
|
|
122
|
+
LINGLING_SERVICE_STOP=float:25.0
|
|
123
|
+
LINGLING_SERVICE_SETTLE=float:1.0
|
|
124
|
+
LINGLING_WIREGUARD_WAIT=float:30.0
|
|
125
|
+
LINGLING_WINGET_WAIT=float:15.0
|
|
126
|
+
LINGLING_WINGET_TIMEOUT=float:300.0
|
|
127
|
+
LINGLING_ELEVATE_TIMEOUT=float:180.0
|
|
128
|
+
LINGLING_SPAWN_TIMEOUT=float:90.0
|
|
129
|
+
LINGLING_OPENCODE_STOP=float:5.0
|
|
130
|
+
LINGLING_PROOF_STOP=float:3.0
|
|
131
|
+
LINGLING_UPDATE_TIMEOUT=float:3.0
|
|
132
|
+
LINGLING_HELPER_POLL=float:2.0
|
|
133
|
+
LINGLING_INSTALL_TIMEOUT=float:600.0
|
|
134
|
+
LINGLING_PROOF_POLL=float:0.3
|
|
135
|
+
LINGLING_SESSION_POLL=float:0.3
|
|
136
|
+
LINGLING_SERVICE_TIMEOUT=float:10.0
|
|
137
|
+
LINGLING_OPENCODE_DB=csv:data,opencode,opencode.db
|
|
138
|
+
LINGLING_OPENCODE_CONFIG=csv:config,opencode
|
|
139
|
+
LINGLING_PLUGIN_DIR=csv:plugins,lingling
|
|
140
|
+
LINGLING_OPENCODE_DROP=csv:OPENCODE_API_KEY,OPENCODE_DISABLE_FREE_MODELS
|
|
141
|
+
LINGLING_HOME_DIRS=csv:home,config,data,cache
|
|
142
|
+
LINGLING_FAIL_EVENTS=csv:session.step.failed,session.execution.failed
|
|
143
|
+
LINGLING_LIMIT_MARKERS=csv:free usage limit,free-limit,freeusagelimiterror
|
|
144
|
+
LINGLING_WIREGUARD_NAMES=csv:wireguard.exe,wireguard
|
|
145
|
+
LINGLING_POWERSHELL=tool:powershell.exe
|
|
146
|
+
LINGLING_SC=tool:sc.exe
|
|
147
|
+
LINGLING_NETSH=tool:netsh.exe
|
|
148
|
+
LINGLING_WINGET=tool:winget
|