Commit Graph

85 Commits

Author SHA1 Message Date
Karl Seguin
f2a2acc1aa Merge pull request #2134 from lightpanda-io/cache_public_default
Cache-Control is public by default
2026-04-14 12:22:25 +08:00
Karl Seguin
63104a7f82 Re-enable debug allocator in debug
Disabled this when looking at memory profiles, and must have accidentally
committed it.
2026-04-11 12:24:19 +08:00
Karl Seguin
3be913750e Cache-Control is public by default
- If private isn't specified, default to public.
- Add some tests
- Optimize parsing by lower-casing once and switch to std.mem
2026-04-11 07:23:56 +08:00
Adrià Arrufat
070ee7df80 Merge branch 'main' into fix-telemetry-decoding 2026-04-10 09:42:21 +02:00
Pierre Tachoire
a4617390de Merge pull request #2104 from lightpanda-io/feat/add-ip-filter
Feat/add ip filter
2026-04-10 08:46:06 +02:00
Karl Seguin
8eaeafe16c Fix a lot of typos.
I used https://github.com/crate-ci/typos, it worked well.

Also, make sure cdp-initiated KeyboardEvent is freed when no element is in focus
2026-04-10 06:51:10 +08:00
Adrià Arrufat
d19e62ec3c http: add default write callback to prevent stdout pollution 2026-04-09 22:03:09 +02:00
Karl Seguin
0253092f20 Improvements to IpFilters
The main change is changing how CidrV4 and CidrV6 are stored, by pre-calculating
their mask and storing their address as integer.

This allows significant simplification of matchesCidrV4 and matchesCidrV6.
2026-04-09 15:40:16 +08:00
Adrià Arrufat
182447c907 cache: add log filter to garbage file test 2026-04-08 19:36:29 +02:00
Pierre Tachoire
6ef518438b fix custom cidrs mem leak 2026-04-08 15:09:01 +02:00
Pierre Tachoire
efb2fa9c22 Send Sec-Ch-Ua http header 2026-04-08 12:11:09 +02:00
Lucien Coffe
7f5abfc9cf fix: use dashes in CLI flag names for consistency
Rename --block_private_networks to --block-private-networks and
--block_cidrs to --block-cidrs to match the existing flag naming
convention (e.g. --http-proxy, --proxy-bearer-token).
2026-04-08 12:10:46 +02:00
Lucien Coffe
fb6c4e4978 feat: add allow-list exclusions to --block_cidrs
CIDRs prefixed with '-' are treated as allow rules that exempt matching
IPs from blocking. Allow rules take precedence over both
--block_private_networks and custom block CIDRs.

Example: --block_private_networks --block_cidrs -10.0.0.42/32
blocks all private ranges except 10.0.0.42.

Adds 3 new tests for allow-list behavior.
2026-04-08 12:10:46 +02:00
Lucien Coffe
f5cfc4d315 feat: add --block_private_networks and --block_cidrs CLI flags
Block outbound HTTP requests to specified IP ranges before TCP handshake
using libcurl CURLOPT_OPENSOCKETFUNCTION callback. Fires after DNS
resolution, reads resolved IP directly from sockaddr, does bitwise CIDR
comparison. Fail-closed: unknown address families are blocked.

--block_private_networks blocks RFC1918, localhost, link-local, ULA.
--block_cidrs blocks additional comma-separated CIDRs.
IPv4-mapped IPv6 (::ffff:x.x.x.x) is unwrapped to prevent bypass.
2026-04-08 12:10:42 +02:00
Pierre Tachoire
8781d7e73b Add XMLHttpRequest.timeout with curl enforcement
Implement the XHR timeout property end-to-end: the JS-visible
getter/setter stores the value, send() passes it to the HTTP client,
and curl enforces it via CURLOPT_TIMEOUT_MS. On timeout, a `timeout`
event is dispatched instead of `error`, per the XHR spec.
2026-04-07 08:47:10 +02:00
Karl Seguin
c4250418af Address feedback
-dispatch error on abnormal close
-reciprocal close message
-more url validation
-cleanup dead code
2026-04-04 07:39:55 +08:00
Karl Seguin
14dcb7895a Give websockets their own connection pool, improve websocket message logging 2026-04-04 07:00:24 +08:00
Karl Seguin
5733c35a2d WebSocket WebAPI
Uses libcurl's websocket capabilities to add support for WebSocket.

Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/167
Issue: https://github.com/lightpanda-io/browser/issues/1952

This is a WIP because it currently uses the same connection pool used for all
HTTP requests. It would be pretty easy for a page to starve the pool and block
any progress.

We previously stored the *Transfer inside of the easy's private data. We now
store the *Connection, and a Connection now has a `transport` field which is
a union for `http: *Transfer` or `websocket: *Websocket`.
2026-04-04 06:59:28 +08:00
Muki Kiboigo
ca5fa2b866 change --cache-dir -> --http-cache-dir 2026-04-03 07:23:32 -07:00
Pierre Tachoire
a71ff521aa cache: add debug log with no store reason 2026-04-03 07:23:32 -07:00
Muki Kiboigo
5a551607c2 better logging on FsCache init failure 2026-04-03 07:23:32 -07:00
Muki Kiboigo
13ea4d1ee3 more expressive cache logging 2026-04-03 07:23:32 -07:00
Muki Kiboigo
3d760e4577 add format to CachedMetadata 2026-04-03 07:23:31 -07:00
Muki Kiboigo
a1a301666f dupe url in tryCache 2026-04-03 07:23:31 -07:00
Muki Kiboigo
f098a991a8 remove cache revalidation stubs 2026-04-03 07:23:30 -07:00
Muki Kiboigo
7b5e4d6f52 add Vary support 2026-04-03 07:23:30 -07:00
Muki Kiboigo
9ffc99d6a2 add more FsCache tests 2026-04-03 07:23:30 -07:00
Muki Kiboigo
d65a4b09f3 better logging for cache 2026-04-03 07:23:30 -07:00
Muki Kiboigo
6a57d69359 switch to single file cache 2026-04-03 07:23:30 -07:00
Muki Kiboigo
9c5e67fbf5 properly deinit cache 2026-04-03 07:23:30 -07:00
Muki Kiboigo
7edb24e54d use wyhash for power of two lock stripes 2026-04-03 07:23:29 -07:00
Muki Kiboigo
a60932bbe0 require timestamp passed in with cache request 2026-04-03 07:23:29 -07:00
Muki Kiboigo
77e9f5caf7 remove unused cache method on fs cache 2026-04-03 07:23:29 -07:00
Muki Kiboigo
cedc894445 add basic fs cache get/put test 2026-04-03 07:23:29 -07:00
Muki Kiboigo
9d62e58c9a check age on fs cache get 2026-04-03 07:23:29 -07:00
Muki Kiboigo
609983da87 only store stuff when we know we will cache 2026-04-03 07:23:29 -07:00
Muki Kiboigo
65f77af84d shortcircuit a lot of caching checks 2026-04-03 07:23:29 -07:00
Muki Kiboigo
557a4458a4 use CacheRequest instead of key 2026-04-03 07:23:28 -07:00
Muki Kiboigo
ce620e208d add striped lock to FsCache 2026-04-03 07:23:28 -07:00
Muki Kiboigo
2de35a9db2 use arena_pool for cache get 2026-04-03 07:23:28 -07:00
Muki Kiboigo
3eb05fdd1a use writer for fs cache body file 2026-04-03 07:23:28 -07:00
Muki Kiboigo
186fdee59b use json for fs cache metadata file 2026-04-03 07:23:28 -07:00
Muki Kiboigo
3c8bb5bc00 use sha256 instead of wyhash 2026-04-03 07:23:28 -07:00
Muki Kiboigo
5c2207ecc3 add more http caching rules 2026-04-03 07:23:27 -07:00
Muki Kiboigo
18d347e247 use CacheControl and Vary 2026-04-03 07:23:27 -07:00
Muki Kiboigo
29dfbbfdea cache headers along with response 2026-04-03 07:23:27 -07:00
Muki Kiboigo
349d5a0a0b create cache owned by the network struct 2026-04-03 07:23:27 -07:00
Muki Kiboigo
647d989191 use enum approach instead of vtable 2026-04-03 07:23:27 -07:00
Muki Kiboigo
41a24623fa add basic FsCache impl 2026-04-03 07:23:27 -07:00
Muki Kiboigo
2962864f3d create Cache interface file 2026-04-03 07:22:20 -07:00