tslocal 0.1.0
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.
- package/LICENSE +28 -0
- package/README.md +104 -0
- package/dist/index.cjs +695 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +744 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +744 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +651 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
- package/ts/src/client.ts +191 -0
- package/ts/src/errors.ts +68 -0
- package/ts/src/index.ts +28 -0
- package/ts/src/json.ts +20 -0
- package/ts/src/safesocket.ts +93 -0
- package/ts/src/transport.ts +104 -0
- package/ts/src/types.ts +1009 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Bouke van der Bijl
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# tslocal
|
|
2
|
+
|
|
3
|
+
Client libraries for the [Tailscale Local API](https://tailscale.com/kb/1242/tailscale-api-local) in Rust, Python, and TypeScript.
|
|
4
|
+
|
|
5
|
+
These are direct ports of the official Go client (`tailscale/client/local`), targeting Tailscale **v1.94.1**.
|
|
6
|
+
|
|
7
|
+
## Libraries
|
|
8
|
+
|
|
9
|
+
| Language | Path | Runtime |
|
|
10
|
+
|----------|------|---------|
|
|
11
|
+
| Rust | [`rust/`](rust/) | async/tokio |
|
|
12
|
+
| Python | [`python/`](python/) | sync |
|
|
13
|
+
| TypeScript | [`ts/`](ts/) | Node.js |
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
**Rust** — add to `Cargo.toml`:
|
|
18
|
+
```toml
|
|
19
|
+
[dependencies]
|
|
20
|
+
tslocal = "0.1.0"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Python**:
|
|
24
|
+
```sh
|
|
25
|
+
pip install tslocal
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**TypeScript**:
|
|
29
|
+
```sh
|
|
30
|
+
npm install tslocal
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
All three libraries communicate with the local Tailscale daemon over a Unix domain socket. The daemon must be running on the same machine.
|
|
36
|
+
|
|
37
|
+
### Rust
|
|
38
|
+
|
|
39
|
+
```rust
|
|
40
|
+
use tslocal::LocalClient;
|
|
41
|
+
|
|
42
|
+
#[tokio::main]
|
|
43
|
+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
44
|
+
let client = LocalClient::new();
|
|
45
|
+
let status = client.status().await?;
|
|
46
|
+
println!("Tailscale version: {}", status.version);
|
|
47
|
+
Ok(())
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Python
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from tslocal import LocalClient
|
|
55
|
+
|
|
56
|
+
with LocalClient() as client:
|
|
57
|
+
status = client.status()
|
|
58
|
+
print(f"Tailscale version: {status.version}")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### TypeScript
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { LocalClient } from "tslocal";
|
|
65
|
+
|
|
66
|
+
const client = new LocalClient();
|
|
67
|
+
const status = await client.status();
|
|
68
|
+
console.log(`Tailscale version: ${status.Version}`);
|
|
69
|
+
client.destroy();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Supported Methods
|
|
73
|
+
|
|
74
|
+
| Description | Go | Rust | Python | TypeScript |
|
|
75
|
+
|---|---|---|---|---|
|
|
76
|
+
| Get full node status including peers | `Status` | `status` | `status` | `status` |
|
|
77
|
+
| Get node status without peer information | `StatusWithoutPeers` | `status_without_peers` | `status_without_peers` | `statusWithoutPeers` |
|
|
78
|
+
| Look up identity by IP address | `WhoIs` | `who_is` | `who_is` | `whoIs` |
|
|
79
|
+
| Look up identity by node key | `WhoIsNodeKey` | `who_is_node_key` | `who_is_node_key` | `whoIsNodeKey` |
|
|
80
|
+
| Look up identity with proto and address | `WhoIsProto` | `who_is_proto` | `who_is_proto` | `whoIsProto` |
|
|
81
|
+
| Get TLS certificate and private key | `CertPair` | `cert_pair` | `cert_pair` | `certPair` |
|
|
82
|
+
| Get TLS certificate with minimum validity | `CertPairWithValidity` | `cert_pair_with_validity` | `cert_pair_with_validity` | `certPairWithValidity` |
|
|
83
|
+
| Get current serve configuration | `GetServeConfig` | `get_serve_config` | `get_serve_config` | `getServeConfig` |
|
|
84
|
+
| Set serve configuration | `SetServeConfig` | `set_serve_config` | `set_serve_config` | `setServeConfig` |
|
|
85
|
+
|
|
86
|
+
## Build & Test
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
# Rust
|
|
90
|
+
cargo test
|
|
91
|
+
cargo check
|
|
92
|
+
cargo clippy
|
|
93
|
+
|
|
94
|
+
# Python
|
|
95
|
+
uv run pytest
|
|
96
|
+
|
|
97
|
+
# TypeScript
|
|
98
|
+
npm test
|
|
99
|
+
npx tsc --noEmit
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
See [LICENSE](LICENSE).
|