tslocalapi 0.0.1__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.
- tslocalapi-0.0.1/.claude/settings.local.json +11 -0
- tslocalapi-0.0.1/.gitignore +144 -0
- tslocalapi-0.0.1/CLAUDE.md +56 -0
- tslocalapi-0.0.1/Cargo.lock +1142 -0
- tslocalapi-0.0.1/Cargo.toml +3 -0
- tslocalapi-0.0.1/LICENSE +28 -0
- tslocalapi-0.0.1/PKG-INFO +9 -0
- tslocalapi-0.0.1/README.md +112 -0
- tslocalapi-0.0.1/cmd/typegen/comments.go +94 -0
- tslocalapi-0.0.1/cmd/typegen/gen_python.go +201 -0
- tslocalapi-0.0.1/cmd/typegen/gen_rust.go +281 -0
- tslocalapi-0.0.1/cmd/typegen/gen_rust_test.go +62 -0
- tslocalapi-0.0.1/cmd/typegen/gen_typescript.go +102 -0
- tslocalapi-0.0.1/cmd/typegen/go.mod +19 -0
- tslocalapi-0.0.1/cmd/typegen/go.sum +38 -0
- tslocalapi-0.0.1/cmd/typegen/main.go +153 -0
- tslocalapi-0.0.1/cmd/typegen/reflect.go +388 -0
- tslocalapi-0.0.1/cmd/typegen/typegen +0 -0
- tslocalapi-0.0.1/package-lock.json +2302 -0
- tslocalapi-0.0.1/package.json +23 -0
- tslocalapi-0.0.1/pyproject.toml +24 -0
- tslocalapi-0.0.1/python/examples/status.py +13 -0
- tslocalapi-0.0.1/python/examples/whois.py +17 -0
- tslocalapi-0.0.1/python/src/tslocalapi/__init__.py +79 -0
- tslocalapi-0.0.1/python/src/tslocalapi/_client.py +647 -0
- tslocalapi-0.0.1/python/src/tslocalapi/_errors.py +47 -0
- tslocalapi-0.0.1/python/src/tslocalapi/_generated_types.py +1816 -0
- tslocalapi-0.0.1/python/src/tslocalapi/_ipn_bus_watcher.py +98 -0
- tslocalapi-0.0.1/python/src/tslocalapi/_safesocket.py +95 -0
- tslocalapi-0.0.1/python/src/tslocalapi/_transport.py +129 -0
- tslocalapi-0.0.1/python/src/tslocalapi/_types.py +77 -0
- tslocalapi-0.0.1/python/src/tslocalapi/py.typed +0 -0
- tslocalapi-0.0.1/python/tests/__init__.py +0 -0
- tslocalapi-0.0.1/python/tests/conftest.py +1 -0
- tslocalapi-0.0.1/python/tests/test_client.py +849 -0
- tslocalapi-0.0.1/python/tests/test_errors.py +66 -0
- tslocalapi-0.0.1/python/tests/test_safesocket.py +76 -0
- tslocalapi-0.0.1/python/tests/test_types.py +160 -0
- tslocalapi-0.0.1/rust/Cargo.toml +27 -0
- tslocalapi-0.0.1/rust/examples/dial.rs +102 -0
- tslocalapi-0.0.1/rust/examples/status.rs +9 -0
- tslocalapi-0.0.1/rust/examples/whois.rs +10 -0
- tslocalapi-0.0.1/rust/src/api/auth.rs +23 -0
- tslocalapi-0.0.1/rust/src/api/certs.rs +66 -0
- tslocalapi-0.0.1/rust/src/api/debug.rs +72 -0
- tslocalapi-0.0.1/rust/src/api/derp.rs +35 -0
- tslocalapi-0.0.1/rust/src/api/diagnostics.rs +181 -0
- tslocalapi-0.0.1/rust/src/api/dial.rs +70 -0
- tslocalapi-0.0.1/rust/src/api/dns.rs +20 -0
- tslocalapi-0.0.1/rust/src/api/events.rs +5 -0
- tslocalapi-0.0.1/rust/src/api/exit_node.rs +23 -0
- tslocalapi-0.0.1/rust/src/api/logging.rs +45 -0
- tslocalapi-0.0.1/rust/src/api/metrics.rs +53 -0
- tslocalapi-0.0.1/rust/src/api/mod.rs +21 -0
- tslocalapi-0.0.1/rust/src/api/network_lock.rs +159 -0
- tslocalapi-0.0.1/rust/src/api/ping.rs +66 -0
- tslocalapi-0.0.1/rust/src/api/policy.rs +26 -0
- tslocalapi-0.0.1/rust/src/api/prefs.rs +20 -0
- tslocalapi-0.0.1/rust/src/api/profiles.rs +47 -0
- tslocalapi-0.0.1/rust/src/api/serve.rs +20 -0
- tslocalapi-0.0.1/rust/src/api/status.rs +19 -0
- tslocalapi-0.0.1/rust/src/api/taildrive.rs +44 -0
- tslocalapi-0.0.1/rust/src/api/taildrop.rs +84 -0
- tslocalapi-0.0.1/rust/src/api/whois.rs +83 -0
- tslocalapi-0.0.1/rust/src/client.rs +196 -0
- tslocalapi-0.0.1/rust/src/error.rs +121 -0
- tslocalapi-0.0.1/rust/src/lib.rs +20 -0
- tslocalapi-0.0.1/rust/src/safesocket/darwin.rs +122 -0
- tslocalapi-0.0.1/rust/src/safesocket/mod.rs +44 -0
- tslocalapi-0.0.1/rust/src/safesocket/unix.rs +33 -0
- tslocalapi-0.0.1/rust/src/transport.rs +143 -0
- tslocalapi-0.0.1/rust/src/types.rs +2769 -0
- tslocalapi-0.0.1/ts/examples/status.ts +6 -0
- tslocalapi-0.0.1/ts/examples/whois.ts +12 -0
- tslocalapi-0.0.1/ts/src/client.ts +597 -0
- tslocalapi-0.0.1/ts/src/errors.ts +68 -0
- tslocalapi-0.0.1/ts/src/index.ts +38 -0
- tslocalapi-0.0.1/ts/src/ipn-bus-watcher.ts +81 -0
- tslocalapi-0.0.1/ts/src/safesocket.ts +84 -0
- tslocalapi-0.0.1/ts/src/transport.ts +118 -0
- tslocalapi-0.0.1/ts/src/types.ts +2349 -0
- tslocalapi-0.0.1/ts/test/client.test.ts +594 -0
- tslocalapi-0.0.1/ts/test/errors.test.ts +61 -0
- tslocalapi-0.0.1/ts/test/safesocket.test.ts +56 -0
- tslocalapi-0.0.1/tsconfig.json +21 -0
- tslocalapi-0.0.1/tsdown.config.ts +9 -0
- tslocalapi-0.0.1/uv.lock +217 -0
- tslocalapi-0.0.1/vitest.config.ts +7 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# local checkout of tailscale source
|
|
2
|
+
/tailscale
|
|
3
|
+
|
|
4
|
+
# Rust
|
|
5
|
+
/target
|
|
6
|
+
rust/target
|
|
7
|
+
|
|
8
|
+
# Python
|
|
9
|
+
__pycache__/
|
|
10
|
+
*.py[cod]
|
|
11
|
+
*.egg-info/
|
|
12
|
+
.venv/
|
|
13
|
+
python/.venv/
|
|
14
|
+
|
|
15
|
+
# Logs
|
|
16
|
+
logs
|
|
17
|
+
*.log
|
|
18
|
+
npm-debug.log*
|
|
19
|
+
yarn-debug.log*
|
|
20
|
+
yarn-error.log*
|
|
21
|
+
lerna-debug.log*
|
|
22
|
+
.pnpm-debug.log*
|
|
23
|
+
|
|
24
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
25
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
26
|
+
|
|
27
|
+
# Runtime data
|
|
28
|
+
pids
|
|
29
|
+
*.pid
|
|
30
|
+
*.seed
|
|
31
|
+
*.pid.lock
|
|
32
|
+
|
|
33
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
34
|
+
lib-cov
|
|
35
|
+
|
|
36
|
+
# Coverage directory used by tools like istanbul
|
|
37
|
+
coverage
|
|
38
|
+
*.lcov
|
|
39
|
+
|
|
40
|
+
# nyc test coverage
|
|
41
|
+
.nyc_output
|
|
42
|
+
|
|
43
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
44
|
+
.grunt
|
|
45
|
+
|
|
46
|
+
# Bower dependency directory (https://bower.io/)
|
|
47
|
+
bower_components
|
|
48
|
+
|
|
49
|
+
# node-waf configuration
|
|
50
|
+
.lock-wscript
|
|
51
|
+
|
|
52
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
53
|
+
build/Release
|
|
54
|
+
|
|
55
|
+
# Dependency directories
|
|
56
|
+
node_modules/
|
|
57
|
+
jspm_packages/
|
|
58
|
+
|
|
59
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
60
|
+
web_modules/
|
|
61
|
+
|
|
62
|
+
# TypeScript cache
|
|
63
|
+
*.tsbuildinfo
|
|
64
|
+
|
|
65
|
+
# Optional npm cache directory
|
|
66
|
+
.npm
|
|
67
|
+
|
|
68
|
+
# Optional eslint cache
|
|
69
|
+
.eslintcache
|
|
70
|
+
|
|
71
|
+
# Optional stylelint cache
|
|
72
|
+
.stylelintcache
|
|
73
|
+
|
|
74
|
+
# Microbundle cache
|
|
75
|
+
.rpt2_cache/
|
|
76
|
+
.rts2_cache_cjs/
|
|
77
|
+
.rts2_cache_es/
|
|
78
|
+
.rts2_cache_umd/
|
|
79
|
+
|
|
80
|
+
# Optional REPL history
|
|
81
|
+
.node_repl_history
|
|
82
|
+
|
|
83
|
+
# Output of 'npm pack'
|
|
84
|
+
*.tgz
|
|
85
|
+
|
|
86
|
+
# Yarn Integrity file
|
|
87
|
+
.yarn-integrity
|
|
88
|
+
|
|
89
|
+
# dotenv environment variable files
|
|
90
|
+
.env
|
|
91
|
+
.env.development.local
|
|
92
|
+
.env.test.local
|
|
93
|
+
.env.production.local
|
|
94
|
+
.env.local
|
|
95
|
+
|
|
96
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
97
|
+
.cache
|
|
98
|
+
.parcel-cache
|
|
99
|
+
|
|
100
|
+
# Next.js build output
|
|
101
|
+
.next
|
|
102
|
+
out
|
|
103
|
+
|
|
104
|
+
# Nuxt.js build / generate output
|
|
105
|
+
.nuxt
|
|
106
|
+
dist
|
|
107
|
+
|
|
108
|
+
# Gatsby files
|
|
109
|
+
.cache/
|
|
110
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
111
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
112
|
+
# public
|
|
113
|
+
|
|
114
|
+
# vuepress build output
|
|
115
|
+
.vuepress/dist
|
|
116
|
+
|
|
117
|
+
# vuepress v2.x temp and cache directory
|
|
118
|
+
.temp
|
|
119
|
+
.cache
|
|
120
|
+
|
|
121
|
+
# Docusaurus cache and generated files
|
|
122
|
+
.docusaurus
|
|
123
|
+
|
|
124
|
+
# Serverless directories
|
|
125
|
+
.serverless/
|
|
126
|
+
|
|
127
|
+
# FuseBox cache
|
|
128
|
+
.fusebox/
|
|
129
|
+
|
|
130
|
+
# DynamoDB Local files
|
|
131
|
+
.dynamodb/
|
|
132
|
+
|
|
133
|
+
# TernJS port file
|
|
134
|
+
.tern-port
|
|
135
|
+
|
|
136
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
137
|
+
.vscode-test
|
|
138
|
+
|
|
139
|
+
# yarn v2
|
|
140
|
+
.yarn/cache
|
|
141
|
+
.yarn/unplugged
|
|
142
|
+
.yarn/build-state.yml
|
|
143
|
+
.yarn/install-state.gz
|
|
144
|
+
.pnp.*
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Tailscale Local API Client Libraries
|
|
2
|
+
|
|
3
|
+
Client libraries for the Tailscale Local API in Rust, Python, and TypeScript.
|
|
4
|
+
|
|
5
|
+
The libraries should use exact ports of the Go source, you can find the original implementation under `tailscale/client/local/`.
|
|
6
|
+
|
|
7
|
+
## Versioning
|
|
8
|
+
|
|
9
|
+
Package versions are independently versioned (currently **0.0.1**). The libraries target Tailscale **v1.94.1** (matching `tailscale/` checkout at v1.94.1).
|
|
10
|
+
|
|
11
|
+
## Project Structure
|
|
12
|
+
|
|
13
|
+
- `rust/` — Rust crate (async/tokio)
|
|
14
|
+
- `python/` — Python package (async/asyncio)
|
|
15
|
+
- `ts/` — TypeScript/Node.js package
|
|
16
|
+
- `tailscale/` — Go reference source (gitignored)
|
|
17
|
+
|
|
18
|
+
## Build & Test Commands
|
|
19
|
+
|
|
20
|
+
- **Rust**: `cargo test`, `cargo check`, `cargo clippy`
|
|
21
|
+
- **Python**: `uv run pytest`, `uvx ty check python/src`
|
|
22
|
+
- **TypeScript**: `npm test`, `npx tsc --noEmit`
|
|
23
|
+
|
|
24
|
+
## Conventions
|
|
25
|
+
|
|
26
|
+
- Go JSON uses PascalCase field names; Rust uses serde rename, Python converts snake_case↔PascalCase, TypeScript interfaces match wire format directly
|
|
27
|
+
- All HTTP requests use `Host: local-tailscaled.sock` and header `Tailscale-Cap: 131` (CurrentCapabilityVersion from tailcfg.go)
|
|
28
|
+
- Error mapping: HTTP 403→AccessDeniedError, 412→PreconditionsFailedError, 404 on WhoIs→PeerNotFoundError
|
|
29
|
+
- Connections should be reused where possible (HTTP keep-alive, connection pooling)
|
|
30
|
+
- TDD: write failing tests first, then implement
|
|
31
|
+
- `rust/src/types.rs` is generated by `cmd/typegen` — never edit it manually, fix the generator instead
|
|
32
|
+
|
|
33
|
+
## Validation
|
|
34
|
+
|
|
35
|
+
Compare client output against the `tailscale` CLI to verify implementations match the wire format:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
# Status: capture both outputs and diff
|
|
39
|
+
cargo run --example status 2>/dev/null > /tmp/rust_status.json
|
|
40
|
+
tailscale status --json 2>/dev/null > /tmp/ts_status.json
|
|
41
|
+
|
|
42
|
+
# WhoIs: use your own Tailscale IP
|
|
43
|
+
cargo run --example whois -- <tailscale-ip> 2>/dev/null > /tmp/rust_whois.json
|
|
44
|
+
tailscale whois --json <tailscale-ip> 2>/dev/null > /tmp/ts_whois.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Known acceptable differences:
|
|
48
|
+
- **null vs `[]`**: Go serializes nil slices as `null`, Rust empty `Vec` serializes as `[]`. This is cosmetic and handled by `deserialize_null_default` in the generated types.
|
|
49
|
+
- **Ephemeral fields**: `LastWrite`, `RxBytes`, `TxBytes`, `Online`, etc. may differ between captures due to timing.
|
|
50
|
+
|
|
51
|
+
### typegen pitfalls found during validation
|
|
52
|
+
|
|
53
|
+
- `tailcfg.RawMessage` is `type RawMessage string` (not `encoding/json.RawMessage` which is `[]byte`) — must be explicitly mapped to `serde_json::Value` in `knownTypeMap`
|
|
54
|
+
- `opt.Bool` resolves as kind=string via reflection but maps to `Option<bool>` — `resolveType` must detect `Option<` prefix in the Rust type to set `isOptional=true`
|
|
55
|
+
- Go map values that are slice types can be `null` in JSON — Rust map value types must be wrapped in `Option<Vec<...>>` for these cases
|
|
56
|
+
- Go nil slices/maps serialize as `null`, not absent — use `deserialize_with = "deserialize_null_default"` (not just `#[serde(default)]`) for `Vec` and `HashMap` fields
|