Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ngx-rust-rev = "cda9d8372ccd2e139ef2b03e5806e019e7796187"
nginx-core-version = "1.31.4"
nginx-core-tarball-sha256 = "e6f20b644a17a643f059ae6467a1971fe2811587d025e071068753a1f1e3b3c3"
rustscript-git = "https://github.com/rustscript-lang/rustscript"
rustscript-rev = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73"
rustscript-rev = "2f433edab3f1907e8cb060e901357d7e2af016ce"

[lib]
crate-type = ["cdylib", "rlib"]
Expand All @@ -27,7 +27,7 @@ sha1 = { version = "0.10", default-features = false }
sha2 = { version = "0.10", default-features = false }
nginx-sys = { git = "https://github.com/nginx/ngx-rust", rev = "cda9d8372ccd2e139ef2b03e5806e019e7796187" }
ngx = { git = "https://github.com/nginx/ngx-rust", rev = "cda9d8372ccd2e139ef2b03e5806e019e7796187", default-features = false, features = ["std"] }
pd-host-function = { git = "https://github.com/rustscript-lang/rustscript", rev = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73" }
pd-host-function = { git = "https://github.com/rustscript-lang/rustscript", rev = "2f433edab3f1907e8cb060e901357d7e2af016ce" }
tokio = { version = "1", default-features = false, features = ["rt", "rt-multi-thread", "time", "net", "sync", "io-util"] }
rustls = { version = "0.23", default-features = false, features = ["std", "tls12", "ring"] }
tokio-rustls = { version = "0.26", default-features = false, features = ["ring"] }
Expand All @@ -36,7 +36,7 @@ rustls-pemfile = { version = "2", default-features = false, features = ["std"] }
rustls-native-certs = "0.8"
webpki-roots = "0.26"
zeroize = { version = "1", default-features = false, features = ["alloc"] }
vm = { package = "pd-vm", git = "https://github.com/rustscript-lang/rustscript", rev = "fc8b0c8179640a8ffe460a64b3690e35c2f7eb73", default-features = false, features = ["runtime", "async", "http-client", "sqlite"] }
vm = { package = "pd-vm", git = "https://github.com/rustscript-lang/rustscript", rev = "2f433edab3f1907e8cb060e901357d7e2af016ce", default-features = false, features = ["runtime", "async", "http-client", "sqlite"] }

[features]
default = ["export-modules"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ phase stays synchronous and fail-closed.
| --- | --- |
| [ngx-rust](https://github.com/nginx/ngx-rust) | `cda9d8372ccd2e139ef2b03e5806e019e7796187` (`ngx` / `nginx-sys` 0.5.0) |
| NGINX | Official NGINX 1.31.4 (`nginx_version` 1031004), tarball SHA-256 `e6f20b644a17a643f059ae6467a1971fe2811587d025e071068753a1f1e3b3c3` |
| RustScript / `pd-vm` | [`https://github.com/rustscript-lang/rustscript`](https://github.com/rustscript-lang/rustscript) at `fc8b0c8179640a8ffe460a64b3690e35c2f7eb73` (Cargo git dependency `package = "pd-vm"` on that immutable rev; no sibling path) |
| RustScript / `pd-vm` | [`https://github.com/rustscript-lang/rustscript`](https://github.com/rustscript-lang/rustscript) at `2f433edab3f1907e8cb060e901357d7e2af016ce` (Cargo git dependency `package = "pd-vm"` on that immutable rev; no sibling path) |
| Rust toolchain | 1.85.0 or later (ngx-rust MSRV). Verified with rustc 1.94.1 |

Required build tools on Linux:
Expand Down
4 changes: 2 additions & 2 deletions docs/api/codec.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ struct DecodedArgsResult {
| `ngx.encode_args` | `ngx::encode_args(args: unknown) -> string` | adapted | `PHASE_ENCODE_ARGS` | 1024 pairs; input/output caps | Catalog type is `unknown` because object literals are not an exact map schema; runtime requires a map. Array values emit repeated keys. `true` is a bare key; `false`/`()` omitted. Nested maps/arrays-as-single-value rejected. Duplicate map keys overwrite; use arrays for multi-value keys. Not allowed in `init` / `init_worker`. | `tests/ngx_codec.rs` (`encode_args_*`) |
| `ngx.decode_args` | `ngx::decode_args(query: string, max_args: unknown) -> DecodedArgsResult` | adapted | `PHASE_DECODE_ARGS` | default 100; hard max 1024 | Returns fields `args: array<ArgEntry>` and `truncated: bool`. See cross-cutting item 4. `max_args` is `()` or int. | `tests/ngx_codec.rs` (`decode_args_*`) |
| `ngx.encode_base64` | `ngx::encode_base64(input: unknown, no_padding: unknown) -> string` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input/output caps | `input` is string or bytes. `no_padding` is `()`/`false` or `true`. | `tests/ngx_codec.rs` (`encode_base64_padding_and_decode_variants`) |
| `ngx.decode_base64` | `ngx::decode_base64(text: string) -> Option<bytes>` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | Invalid input is `Option::None`, not an error. Padding may be omitted. | `tests/ngx_codec.rs` (`encode_base64_padding_and_decode_variants`) |
| `ngx.decode_base64mime` | `ngx::decode_base64mime(text: string) -> Option<bytes>` | adapted | `PHASE_CODEC_MISC` | input cap | Skips non-alphabet bytes; stops at first `=`. `data_len % 4 == 1` is `Option::None`. **Not** allowed in `ssl_client_hello` (OpenResty v0.10.29 exception). | `tests/ngx_codec.rs` (`decode_base64mime_*`), `tests/host_catalog.rs` |
| `ngx.decode_base64` | `ngx::decode_base64(text: string) -> Option<bytes>` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | Invalid input is `None`, not an error. Padding may be omitted. | `tests/ngx_codec.rs` (`encode_base64_padding_and_decode_variants`) |
| `ngx.decode_base64mime` | `ngx::decode_base64mime(text: string) -> Option<bytes>` | adapted | `PHASE_CODEC_MISC` | input cap | Skips non-alphabet bytes; stops at first `=`. `data_len % 4 == 1` is `None`. **Not** allowed in `ssl_client_hello` (OpenResty v0.10.29 exception). | `tests/ngx_codec.rs` (`decode_base64mime_*`), `tests/host_catalog.rs` |
| `ngx.crc32_short` | `ngx::crc32_short(data: string) -> int` | supported | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | IEEE CRC-32. Currently matches `crc32_long`. | `tests/ngx_codec.rs` (`hash_and_hmac_use_fixed_vectors`) |
| `ngx.crc32_long` | `ngx::crc32_long(data: string) -> int` | supported | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap | Same result as `crc32_short` in this release. | `tests/ngx_codec.rs` (`hash_and_hmac_use_fixed_vectors`) |
| `ngx.hmac_sha1` | `ngx::hmac_sha1(secret: string, data: string) -> bytes` | adapted | `PHASE_CODEC_MISC_SSL_CLIENT_HELLO` | input cap on each arg | Raw digest **bytes**, not hex. | `tests/ngx_codec.rs` (`hash_and_hmac_use_fixed_vectors`) |
Expand Down
8 changes: 4 additions & 4 deletions docs/api/ctx.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
`ngx.ctx` is adapted as four explicit hosts rather than a Lua table. The map
is owned by `AccessExec` (request lifetime). Values are `string`; a callable
or any non-string value is rejected. Empty and embedded-NUL keys are
rejected. `delete` returns `Option<string>`: `Option::Some(removed)` or
`Option::None` when the key is missing (OpenResty uses `ngx.ctx.key = nil`).
rejected. `delete` returns `Option<string>`: `Some(removed)` or
`None` when the key is missing (OpenResty uses `ngx.ctx.key = nil`).
Configuration phases cannot import these hosts. Capability is `RequestCtx`
only — ctx hosts do not read the request pointer.

| OpenResty API | RustScript callable | Status | Phases | Limits | Semantic differences | Acceptance |
| --- | --- | --- | --- | --- | --- | --- |
| `ngx.ctx` | `ngx::ctx::get(key: string) -> Option<string>` | adapted | `PHASE_CTX` | missing → `Option::None` | Explicit get; missing is `Option::None`, a stored empty string is `Option::Some("")`. | `tests/ngx_request_ctx.rs` |
| `ngx.ctx` | `ngx::ctx::get(key: string) -> Option<string>` | adapted | `PHASE_CTX` | missing → `None` | Explicit get; missing is `None`, a stored empty string is `Some("")`. | `tests/ngx_request_ctx.rs` |
| `ngx.ctx` | `ngx::ctx::set(key: string, value: string) -> ()` | adapted | `PHASE_CTX` | 256 keys; 256-byte key; 8192-byte value | Failed set leaves the previous value intact. | `tests/ngx_request_ctx.rs` |
| `ngx.ctx` | `ngx::ctx::delete(key: string) -> Option<string>` | adapted | `PHASE_CTX` | same key policy | Returns `Option::Some(removed)` or `Option::None` if missing. | `tests/ngx_request_ctx.rs` |
| `ngx.ctx` | `ngx::ctx::delete(key: string) -> Option<string>` | adapted | `PHASE_CTX` | same key policy | Returns `Some(removed)` or `None` if missing. | `tests/ngx_request_ctx.rs` |
| `ngx.ctx` | `ngx::ctx::clear() -> ()` | adapted | `PHASE_CTX` | — | Drops every entry. OpenResty would assign a new table. | `tests/ngx_request_ctx.rs` |

`PHASE_CTX` (OpenResty v0.10.29 `ngx.ctx` contexts): `set`, `rewrite`,
Expand Down
8 changes: 4 additions & 4 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ pd-vm I/O, HTTP, and SQLite hosts are not part of the 199 ngx names; see
| Acceptance | Tests that exercise the host or family |

Catalog type labels: `number` (int or float), `int`, `string`, `bytes`,
`bool`, `()`, `array<T>`, `Option<T>` (`Option::Some(T)` or `Option::None`),
`bool`, `()`, `array<T>`, `Option<T>` (`Some(T)` or `None`),
`Result<T, E>`, named records, and `resource` (typed VM handle). A host
output never carries `unknown`, `null`, or the legacy `optional<T>` schema.

The pinned compiler matches host arity exactly. OpenResty optional
trailing arguments are explicit arguments: pass `()` where the default is
wanted. Absence in a result is `Option::None`, never `null`.
wanted. Absence in a result is `None`, never `null`.

## Inventory

Expand Down Expand Up @@ -186,13 +186,13 @@ host adds a further difference.
`ArgEntry { name: string, value: Option<string> }`. `max_args` of `()`
defaults to 100; `0` is clamped to the hard max 1024 (not unbounded);
values above 1024 are rejected. A key without `=` carries
`Option::None`; a present empty value is `Option::Some("")`. Repeated
`None`; a present empty value is `Some("")`. Repeated
keys repeat the entry. Empty keys are skipped. Invalid `%` sequences are
left as-is.
5. **Byte versus string results.** Hex `ngx::md5` returns `string`.
`ngx::md5_bin`, `ngx::sha1_bin`, and `ngx::hmac_sha1` return `bytes`.
`ngx::decode_base64` / `ngx::decode_base64mime` return
`Option<bytes>` (`Option::None` on invalid input). `ngx::unescape_uri` returns a string even
`Option<bytes>` (`None` on invalid input). `ngx::unescape_uri` returns a string even
when decoded bytes are not UTF-8 (each byte becomes `char::from`).
6. **Time cache / update boundary.** Time hosts use a process-local
cached clock, not nginx `ngx_time` / `ngx_timeofday`. Reads reuse the
Expand Down
Loading
Loading