@alwith/module-chat 0.5.22 → 0.5.23
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/dist/activity-host.js +1 -1
- package/dist/approval/choice-elicitation-form.js +1 -1
- package/dist/approval/choice-schema.js +1 -1
- package/dist/approval/permission-options.js +1 -1
- package/dist/approval/permission-view.js +1 -1
- package/dist/approval/schema-elicitation-form.d.ts +1 -1
- package/dist/approval/schema-elicitation-form.js +1 -1
- package/dist/approval/url-elicitation-card.js +1 -1
- package/dist/{chunk-1tkzxktd.js → chunk-0mmcy6k7.js} +2 -2
- package/dist/chunk-0p6y2t9b.js +2 -0
- package/dist/{chunk-xgjkj9j8.js → chunk-0wa9yjg3.js} +2 -2
- package/dist/{chunk-dya74vts.js → chunk-0whxm2f0.js} +2 -2
- package/dist/{chunk-s55n9cby.js → chunk-1fggcrvs.js} +2 -2
- package/dist/{chunk-r9dt4bs3.js → chunk-1k21j77z.js} +2 -2
- package/dist/chunk-1k697ncv.js +2 -0
- package/dist/chunk-1mn2t6ga.js +2 -0
- package/dist/{chunk-2tce3pc5.js → chunk-1qyxrh0n.js} +3 -3
- package/dist/{chunk-2f1qx13s.js → chunk-1rg3nab3.js} +2 -2
- package/dist/{chunk-63kxepkh.js → chunk-2388yq9z.js} +2 -2
- package/dist/{chunk-2tkeevm0.js → chunk-28f3zv6v.js} +2 -2
- package/dist/{chunk-1ppfn0e1.js → chunk-2f9vjmxz.js} +2 -2
- package/dist/{chunk-8hte6dh7.js → chunk-36m8zstj.js} +2 -2
- package/dist/chunk-3bzqcxq2.js +2 -0
- package/dist/{chunk-9sq2etjk.js → chunk-3e6wcamp.js} +2 -2
- package/dist/{chunk-8t36vprh.js → chunk-3ka3bt0t.js} +2 -2
- package/dist/{chunk-xmstt6hh.js → chunk-3s94ekrs.js} +2 -2
- package/dist/{chunk-23rjsm3a.js → chunk-3yxjh7b1.js} +2 -2
- package/dist/{chunk-8jxcdap5.js → chunk-42atrgm1.js} +2 -2
- package/dist/{chunk-mg2mkzkk.js → chunk-48fj5m0p.js} +2 -2
- package/dist/{chunk-1e6x0018.js → chunk-4bb6dzzs.js} +2 -2
- package/dist/{chunk-dv65h7z5.js → chunk-4ddkzbm0.js} +2 -2
- package/dist/chunk-4fk0vjh5.js +2 -0
- package/dist/{chunk-n0khj68q.js → chunk-4gyd9hx9.js} +2 -2
- package/dist/{chunk-n3xhh6ch.js → chunk-4jfynrgh.js} +2 -2
- package/dist/chunk-4p6svs37.js +2 -0
- package/dist/chunk-4wa7tehh.js +3 -0
- package/dist/{chunk-m2b8kzpk.js → chunk-5a6xc345.js} +2 -2
- package/dist/chunk-5ap6fvrp.js +2 -0
- package/dist/chunk-6179zrn1.js +3 -0
- package/dist/chunk-658njfx1.js +4 -0
- package/dist/{chunk-nxp1b8ny.js → chunk-667z0pac.js} +2 -2
- package/dist/chunk-6cmttr4w.js +1 -0
- package/dist/{chunk-3jcmv5qf.js → chunk-6t5war9h.js} +2 -2
- package/dist/chunk-6trv0snh.js +2 -0
- package/dist/{chunk-jm6zja6h.js → chunk-76a04a6j.js} +2 -2
- package/dist/{chunk-k7k6qsqh.js → chunk-7z4gtfkd.js} +2 -2
- package/dist/{chunk-nq7gg9vg.js → chunk-855w49k0.js} +2 -2
- package/dist/chunk-8c8ncw1m.js +2 -0
- package/dist/{chunk-0fs2k5fe.js → chunk-95mynf7q.js} +2 -2
- package/dist/chunk-9tp0z23q.js +2 -0
- package/dist/{chunk-v4t0p6pp.js → chunk-9wasxr1v.js} +2 -2
- package/dist/{chunk-0gy6ngda.js → chunk-a42211a1.js} +2 -2
- package/dist/{chunk-77j8n5k5.js → chunk-a63k8tht.js} +2 -2
- package/dist/{chunk-ap0vmczf.js → chunk-acb8t4jt.js} +2 -2
- package/dist/{chunk-2nvsvw67.js → chunk-agqnt7xq.js} +2 -2
- package/dist/chunk-ah4pgmqr.js +2 -0
- package/dist/{chunk-vyk4zh1m.js → chunk-asyfpv8n.js} +7 -7
- package/dist/chunk-awmra30d.js +2 -0
- package/dist/{chunk-aza82m2p.js → chunk-azfmr99x.js} +2 -2
- package/dist/{chunk-0vhkv9ax.js → chunk-b12v22de.js} +2 -2
- package/dist/chunk-bbnhytn3.js +2 -0
- package/dist/{chunk-mcjwwxa1.js → chunk-bfhfbrzt.js} +2 -2
- package/dist/{chunk-w9dh298r.js → chunk-bg03czcx.js} +2 -2
- package/dist/chunk-bmey8et5.js +2 -0
- package/dist/{chunk-67hrx4kg.js → chunk-bvgqsaey.js} +2 -2
- package/dist/chunk-c32z3wjq.js +2 -0
- package/dist/{chunk-33620ca6.js → chunk-c723sswh.js} +2 -2
- package/dist/{chunk-x6nz6eyb.js → chunk-ce1qr37c.js} +2 -2
- package/dist/chunk-cgk9mtky.js +2 -0
- package/dist/{chunk-1q2cykp4.js → chunk-ckyat78p.js} +2 -2
- package/dist/chunk-cvz3k5gk.js +2 -0
- package/dist/{chunk-aqvy57zs.js → chunk-cw76pj9b.js} +2 -2
- package/dist/{chunk-b2wczqtd.js → chunk-cz4k8aad.js} +2 -2
- package/dist/{chunk-xyvqcpjx.js → chunk-d257n8gj.js} +2 -2
- package/dist/{chunk-sy5tq3y6.js → chunk-d8ytdk0x.js} +2 -2
- package/dist/{chunk-m7wn4z9x.js → chunk-drhzcs6e.js} +2 -2
- package/dist/{chunk-nqw4deag.js → chunk-dte0n4kf.js} +2 -2
- package/dist/{chunk-4s6gx750.js → chunk-e3pfvwhd.js} +2 -2
- package/dist/chunk-e5qk8b1f.js +2 -0
- package/dist/{chunk-dyqvhn6y.js → chunk-eg9hemqa.js} +5 -5
- package/dist/chunk-f1gj3yzt.js +2 -0
- package/dist/{chunk-0gersbj0.js → chunk-f1x483c9.js} +2 -2
- package/dist/chunk-f2rq6nj6.js +3 -0
- package/dist/{chunk-dyrgfdxz.js → chunk-f2w2sct6.js} +2 -2
- package/dist/{chunk-mgm1x3de.js → chunk-f5gsffbv.js} +2 -2
- package/dist/chunk-fh3pjhe6.js +2 -0
- package/dist/{chunk-vcy5vyp7.js → chunk-fnpf84rf.js} +2 -2
- package/dist/{chunk-3aq5c12k.js → chunk-g2qcyqc6.js} +2 -2
- package/dist/{chunk-hv1ejvhg.js → chunk-g44hhdha.js} +2 -2
- package/dist/chunk-g8w3emvn.js +2 -0
- package/dist/{chunk-xrs7x5ah.js → chunk-g9t2d8hg.js} +2 -2
- package/dist/{chunk-z2v008kc.js → chunk-gha517v4.js} +2 -2
- package/dist/{chunk-fke98cj0.js → chunk-gsfgdnfp.js} +2 -2
- package/dist/{chunk-memvzzc6.js → chunk-hac9xtfv.js} +2 -2
- package/dist/{chunk-8w22ck92.js → chunk-heyqzkxq.js} +2 -2
- package/dist/{chunk-k5rkpqbh.js → chunk-jgd6dcgy.js} +2 -2
- package/dist/chunk-jmb8r6aj.js +2 -0
- package/dist/{chunk-42nhwnbe.js → chunk-jwt7q6yx.js} +4 -4
- package/dist/{chunk-983gkw32.js → chunk-jxntqarp.js} +2 -2
- package/dist/chunk-k2k5tt5x.js +2 -0
- package/dist/{chunk-6dn3j8a2.js → chunk-k7ye738q.js} +2 -2
- package/dist/{chunk-72x7rae0.js → chunk-kc56dhwd.js} +2 -2
- package/dist/chunk-kfy7yvke.js +2 -0
- package/dist/{chunk-j86x2rn0.js → chunk-kg5hcf28.js} +2 -2
- package/dist/{chunk-42hkbpey.js → chunk-kmdag4vy.js} +2 -2
- package/dist/{chunk-n929wkw7.js → chunk-kz1kjzmq.js} +2 -2
- package/dist/{chunk-qwfwxfhn.js → chunk-m271yxxm.js} +2 -2
- package/dist/chunk-m8hb96f5.js +2 -0
- package/dist/{chunk-zxkvvecz.js → chunk-mj7094yh.js} +2 -2
- package/dist/{chunk-nn25kjm4.js → chunk-mvs2dzyt.js} +2 -2
- package/dist/{chunk-xktybk48.js → chunk-mxfvakya.js} +2 -2
- package/dist/chunk-mz8a6292.js +2 -0
- package/dist/chunk-mztwft71.js +2 -0
- package/dist/chunk-n0acc2tb.js +2 -0
- package/dist/{chunk-p4bb313p.js → chunk-n45a05jx.js} +3 -3
- package/dist/{chunk-e9ntencj.js → chunk-n5v1h0sk.js} +2 -2
- package/dist/{chunk-1f628zap.js → chunk-n66yy1m1.js} +2 -2
- package/dist/{chunk-0mp7tyea.js → chunk-nn2hmwzd.js} +2 -2
- package/dist/{chunk-a8p82wp7.js → chunk-nsf0e6gj.js} +2 -2
- package/dist/chunk-nv6s8x9f.js +2 -0
- package/dist/{chunk-82xjggwn.js → chunk-p7dd93e5.js} +2 -2
- package/dist/chunk-p8g927x6.js +2 -0
- package/dist/chunk-pk2rvqd0.js +2 -0
- package/dist/{chunk-7wk3d01c.js → chunk-pprt7ntb.js} +4 -4
- package/dist/{chunk-rcbb4ke2.js → chunk-pqa37epj.js} +2 -2
- package/dist/{chunk-t97yjy4f.js → chunk-pw8b9brz.js} +2 -2
- package/dist/{chunk-ns5rnxdj.js → chunk-pwjz3yxb.js} +2 -2
- package/dist/{chunk-z71pp1mb.js → chunk-pzjag1mt.js} +3 -3
- package/dist/chunk-pzyradqt.js +2 -0
- package/dist/chunk-q9zawfn1.js +2 -0
- package/dist/{chunk-141kppzb.js → chunk-qd1z91fm.js} +1 -1
- package/dist/{chunk-k5wgf59a.js → chunk-qdg5zphd.js} +2 -2
- package/dist/chunk-qn6ppn0r.js +2 -0
- package/dist/{chunk-8ch9444t.js → chunk-qwfw4xpn.js} +2 -2
- package/dist/chunk-r5z08bp6.js +2 -0
- package/dist/{chunk-mwpchd85.js → chunk-raye7hnk.js} +3 -3
- package/dist/{chunk-x2yc5748.js → chunk-rbv1scqm.js} +2 -2
- package/dist/{chunk-156m3888.js → chunk-rjkpe1fw.js} +3 -3
- package/dist/{chunk-xf36kt74.js → chunk-rjw63t34.js} +3 -3
- package/dist/chunk-rq5e0922.js +2 -0
- package/dist/{chunk-x334e7wb.js → chunk-sjs9484n.js} +3 -3
- package/dist/{chunk-b614gnnv.js → chunk-swpy2b9a.js} +2 -2
- package/dist/chunk-sz3vcbp5.js +2 -0
- package/dist/{chunk-c38t8809.js → chunk-t6vcdf4j.js} +2 -2
- package/dist/{chunk-7p1r1ha9.js → chunk-t7drk9ja.js} +2 -2
- package/dist/{chunk-5cdr7q6f.js → chunk-t9f2cw75.js} +3 -3
- package/dist/chunk-tpbqg729.js +2 -0
- package/dist/chunk-ttn8ss6b.js +2 -0
- package/dist/{chunk-w6rwngm3.js → chunk-tv0fwt2g.js} +2 -2
- package/dist/{chunk-vs02ry2r.js → chunk-tz1kzpzp.js} +2 -2
- package/dist/{chunk-8c042xya.js → chunk-vbab9hc4.js} +2 -2
- package/dist/{chunk-w0hpztj7.js → chunk-vfhxerxt.js} +2 -2
- package/dist/chunk-vnsgjnp3.js +2 -0
- package/dist/{chunk-59957gfy.js → chunk-vt6cyes7.js} +2 -2
- package/dist/chunk-vvtbtx09.js +2 -0
- package/dist/{chunk-z2fjwkmt.js → chunk-wccx911q.js} +2 -2
- package/dist/{chunk-g73f62qm.js → chunk-wgrmjfyp.js} +2 -2
- package/dist/chunk-wm0jty6e.js +2 -0
- package/dist/{chunk-h5m2fpp4.js → chunk-wvry7t79.js} +2 -2
- package/dist/{chunk-00eytt1z.js → chunk-y0q6jwq4.js} +2 -2
- package/dist/chunk-y97ne5kj.js +2 -0
- package/dist/{chunk-cbwya2ss.js → chunk-yakar0e2.js} +2 -2
- package/dist/{chunk-3yvd77ph.js → chunk-yg3xhn5m.js} +2 -2
- package/dist/{chunk-et8rcxw6.js → chunk-z3nybrbb.js} +2 -2
- package/dist/chunk-zheyzqcq.js +2 -0
- package/dist/codex/activity-group.js +1 -1
- package/dist/codex/assistant-message.js +1 -1
- package/dist/codex/async-question-card.js +1 -1
- package/dist/codex/disclosure-state.js +1 -1
- package/dist/codex/edited-files-card.js +1 -1
- package/dist/codex/image-view-activity.js +1 -1
- package/dist/codex/markdown-renderer.js +1 -1
- package/dist/codex/navigation-audio.js +1 -1
- package/dist/codex/navigation-preview.js +1 -1
- package/dist/codex/navigation-rail.js +1 -1
- package/dist/codex/patch-view.js +1 -1
- package/dist/codex/plan.js +1 -1
- package/dist/codex/timeline-virtualizer.js +1 -1
- package/dist/codex/turn-activity.js +1 -1
- package/dist/codex/user-message.js +1 -1
- package/dist/codex/virtualized-turn-list.js +1 -1
- package/dist/collections/collection-emoji.js +1 -1
- package/dist/collections/collection-menu.js +1 -1
- package/dist/collections/collection-panel.js +1 -1
- package/dist/collections/collections.js +1 -1
- package/dist/collections/host.js +1 -1
- package/dist/collections/locales.js +1 -1
- package/dist/collections/model.js +1 -1
- package/dist/collections/store.js +1 -1
- package/dist/composer/completion-filter.js +1 -1
- package/dist/composer/completion-menu.js +1 -1
- package/dist/composer/completion-trigger.js +1 -1
- package/dist/composer/effort-slider.js +1 -1
- package/dist/composer/menu-radio.js +1 -1
- package/dist/composer/model-select.js +1 -1
- package/dist/composer/permission-mode-select.js +1 -1
- package/dist/composer/prompt-input-attachments.js +1 -1
- package/dist/composer/prompt-input-clipboard.js +1 -1
- package/dist/composer/prompt-input-context.js +1 -1
- package/dist/composer/prompt-input-textarea.js +1 -1
- package/dist/composer/prompt-input.js +1 -1
- package/dist/conversation/action-card.js +1 -1
- package/dist/conversation/composer/composer.js +1 -1
- package/dist/conversation/composer/config-options.js +1 -1
- package/dist/conversation/composer/context.js +1 -1
- package/dist/conversation/composer/drafts.js +1 -1
- package/dist/conversation/composer/file-items.js +1 -1
- package/dist/conversation/composer/long-text.js +1 -1
- package/dist/conversation/composer/mention-chips.js +1 -1
- package/dist/conversation/composer/mention-uri.js +1 -1
- package/dist/conversation/composer/model-menu.js +1 -1
- package/dist/conversation/composer/pasted-text-attachment.js +1 -1
- package/dist/conversation/composer/permission-mode-menu.js +1 -1
- package/dist/conversation/composer/prediction.js +1 -1
- package/dist/conversation/composer/slash-command-button.js +1 -1
- package/dist/conversation/composer/submit-button.js +1 -1
- package/dist/conversation/composer/usage-meter.js +1 -1
- package/dist/conversation/connection-notice.js +1 -1
- package/dist/conversation/context.js +1 -1
- package/dist/conversation/conversation-body.js +1 -1
- package/dist/conversation/conversation-search.js +1 -1
- package/dist/conversation/conversation-view.js +1 -1
- package/dist/conversation/conversation.js +1 -1
- package/dist/conversation/diff-modal.js +1 -1
- package/dist/conversation/draft-project-picker.js +1 -1
- package/dist/conversation/session-actions.js +1 -1
- package/dist/conversation/subagent-sessions.js +1 -1
- package/dist/image-lightbox.js +1 -1
- package/dist/image-preview-dialog.js +1 -1
- package/dist/lib/code-highlighter.js +1 -1
- package/dist/lib/fuzzy.js +1 -1
- package/dist/lib/group-blocks.js +1 -1
- package/dist/lib/image-encode.js +1 -1
- package/dist/lib/limits.js +1 -1
- package/dist/lib/markdown-parser.js +1 -1
- package/dist/lib/markdown-rules.js +1 -1
- package/dist/lib/model-name.js +1 -1
- package/dist/lib/pointer-centered-zoom.js +1 -1
- package/dist/lib/prepare-prompt-files.js +1 -1
- package/dist/lib/stream-style.js +1 -1
- package/dist/lib/streaming-markdown.js +1 -1
- package/dist/locales.js +1 -1
- package/dist/plugins/catalog-header.js +1 -1
- package/dist/plugins/catalog-skeleton.js +1 -1
- package/dist/plugins/host.js +1 -1
- package/dist/plugins/new-chat-directory.js +1 -1
- package/dist/plugins/pane.js +1 -1
- package/dist/plugins/panel-item.js +1 -1
- package/dist/plugins/plugin-detail-page.js +1 -1
- package/dist/plugins/plugin-icon.js +1 -1
- package/dist/plugins/plugin-icons.js +1 -1
- package/dist/plugins/plugins-page.js +1 -1
- package/dist/plugins/plugins.js +1 -1
- package/dist/plugins/read-skill-document.js +1 -1
- package/dist/plugins/skill-document.js +1 -1
- package/dist/plugins/skills-tab.js +1 -1
- package/dist/plugins/store.js +1 -1
- package/dist/plugins/toolbox-layout.js +1 -1
- package/dist/search/chat-search.js +1 -1
- package/dist/search/codex-source-matches.js +1 -1
- package/dist/search/dom-matches.js +1 -1
- package/dist/search/find-bar.js +1 -1
- package/dist/search/literal-matches.js +1 -1
- package/dist/session-list/account-menu.js +1 -1
- package/dist/session-list/activity-list.js +1 -1
- package/dist/session-list/archived-sessions.js +1 -1
- package/dist/session-list/help-menu.js +1 -1
- package/dist/session-list/highlight.js +1 -1
- package/dist/session-list/host.js +1 -1
- package/dist/session-list/hover-info-card.js +1 -1
- package/dist/session-list/navigation-header.js +1 -1
- package/dist/session-list/navigation-store.js +1 -1
- package/dist/session-list/navigation-tabs.js +1 -1
- package/dist/session-list/navigation.js +1 -1
- package/dist/session-list/overflow-marquee.js +1 -1
- package/dist/session-list/platform.js +1 -1
- package/dist/session-list/row-stop-button.js +1 -1
- package/dist/session-list/session-groups.js +1 -1
- package/dist/session-list/session-info-card.js +1 -1
- package/dist/session-list/session-list.js +1 -1
- package/dist/session-list/session-row.js +1 -1
- package/dist/session-list/session-state-dot.js +1 -1
- package/dist/session-list/session-state-menu.js +1 -1
- package/dist/session-list/shortcut-hint.js +1 -1
- package/dist/session-list/shortcut.js +1 -1
- package/dist/session-list/sidebar-overlay.js +1 -1
- package/dist/session-list/trailing-swap.js +1 -1
- package/dist/session-list/use-activity-notification.js +1 -1
- package/dist/session-list/use-activity-preview.js +1 -1
- package/dist/session-list/use-cmd-held.js +1 -1
- package/dist/session-list/use-project-sessions.js +1 -1
- package/dist/session-list/virtual-session-rows.js +1 -1
- package/dist/session-timeline/activity-group.js +1 -1
- package/dist/session-timeline/activity-projection.js +1 -1
- package/dist/session-timeline/assistant-content.js +1 -1
- package/dist/session-timeline/assistant-turn.js +1 -1
- package/dist/session-timeline/async-questions.js +1 -1
- package/dist/session-timeline/edited-files-card.js +1 -1
- package/dist/session-timeline/history-timeline.js +1 -1
- package/dist/session-timeline/host.js +1 -1
- package/dist/session-timeline/navigation-rail.js +1 -1
- package/dist/session-timeline/plan.js +1 -1
- package/dist/session-timeline/question-reply.js +1 -1
- package/dist/session-timeline/resource-content.js +1 -1
- package/dist/session-timeline/session-timeline.js +1 -1
- package/dist/session-timeline/timeline-registry.js +1 -1
- package/dist/session-timeline/turn-activity.js +1 -1
- package/dist/session-timeline/turn-error.js +1 -1
- package/dist/session-timeline/turn-retry.js +1 -1
- package/dist/session-timeline/turn-time.js +1 -1
- package/dist/session-timeline/turns.js +1 -1
- package/dist/session-timeline/use-timeline-scroll.js +1 -1
- package/dist/session-timeline/user-message.js +1 -1
- package/dist/settings/codex-account-card.js +1 -1
- package/dist/settings/login-card.js +1 -1
- package/dist/settings/model-alias-settings.js +1 -1
- package/dist/settings/model-aliases.js +1 -1
- package/dist/settings/provider-logos.js +1 -1
- package/dist/settings/provider-section.js +1 -1
- package/dist/settings/providers-port.d.ts +3 -3
- package/dist/settings/providers-port.js +1 -1
- package/dist/settings/providers.js +1 -1
- package/dist/settings/settings-bridge.d.ts +3 -3
- package/dist/settings/settings-bridge.js +1 -1
- package/dist/settings/settings.js +1 -1
- package/package.json +3 -3
- package/rust/Cargo.lock +484 -10
- package/rust/Cargo.toml +16 -1
- package/rust/src/__tests__/native_network.rs +406 -0
- package/rust/src/lib.rs +3 -0
- package/rust/src/native_network.rs +302 -0
- package/rust/src/native_network_diagnostics.rs +220 -0
- package/rust/src/providers/tests.rs +4 -1
- package/rust/src/system_proxy.rs +257 -0
- package/dist/chunk-14exd146.js +0 -2
- package/dist/chunk-2ce8gd89.js +0 -2
- package/dist/chunk-3n47hknp.js +0 -2
- package/dist/chunk-40bcp4pa.js +0 -2
- package/dist/chunk-52p7kyam.js +0 -2
- package/dist/chunk-59exzf5n.js +0 -2
- package/dist/chunk-5nc3dtyt.js +0 -2
- package/dist/chunk-78s6h7r4.js +0 -2
- package/dist/chunk-80ckz04b.js +0 -2
- package/dist/chunk-85ffkcch.js +0 -2
- package/dist/chunk-8qw8erv6.js +0 -2
- package/dist/chunk-908ndb9r.js +0 -2
- package/dist/chunk-9g67z1b4.js +0 -2
- package/dist/chunk-9n79tr1q.js +0 -2
- package/dist/chunk-ajpxjj5m.js +0 -2
- package/dist/chunk-b3jg6nzv.js +0 -3
- package/dist/chunk-c1b8z8pa.js +0 -2
- package/dist/chunk-c9nbavk0.js +0 -2
- package/dist/chunk-cg8ekwka.js +0 -2
- package/dist/chunk-ec9rgnt3.js +0 -2
- package/dist/chunk-efrn25h9.js +0 -2
- package/dist/chunk-emcefs0g.js +0 -2
- package/dist/chunk-f28hhbf4.js +0 -2
- package/dist/chunk-f3924gdb.js +0 -2
- package/dist/chunk-f8zy35gz.js +0 -2
- package/dist/chunk-f98at4r5.js +0 -2
- package/dist/chunk-g242n3dt.js +0 -2
- package/dist/chunk-h1bhhqtq.js +0 -2
- package/dist/chunk-kc5k5e59.js +0 -3
- package/dist/chunk-kvc6ewkt.js +0 -4
- package/dist/chunk-kxmajv0m.js +0 -3
- package/dist/chunk-myrdfa3s.js +0 -2
- package/dist/chunk-nacjea1s.js +0 -2
- package/dist/chunk-py837qjk.js +0 -1
- package/dist/chunk-q7nn5xe5.js +0 -2
- package/dist/chunk-qjhkzdhm.js +0 -2
- package/dist/chunk-qxcnyvps.js +0 -2
- package/dist/chunk-r3qrftds.js +0 -2
- package/dist/chunk-r8rre2zb.js +0 -2
- package/dist/chunk-rbqn4725.js +0 -2
- package/dist/chunk-rekc1q3m.js +0 -2
- package/dist/chunk-rwkkqdcv.js +0 -2
- package/dist/chunk-rwnz06kr.js +0 -2
- package/dist/chunk-sxh0pd3y.js +0 -2
- package/dist/chunk-t0cr21e3.js +0 -2
- package/dist/chunk-vkrgdqnm.js +0 -2
- package/dist/chunk-wvdncbrt.js +0 -2
- package/dist/chunk-y7xcync7.js +0 -2
- package/dist/chunk-ye9tsdhn.js +0 -2
package/rust/Cargo.toml
CHANGED
|
@@ -10,6 +10,7 @@ description = "Model provider settings of the shared ALwith chat: credentials, c
|
|
|
10
10
|
default = ["rustls"]
|
|
11
11
|
# Applications that already select reqwest's TLS backend disable default features.
|
|
12
12
|
rustls = ["reqwest/rustls"]
|
|
13
|
+
native-network = ["reqwest/native-tls", "reqwest/stream", "reqwest/socks", "dep:axum", "dep:hyper", "dep:hyper-util", "dep:http-body-util", "dep:futures-util", "dep:tokio-util", "dep:tokio-tungstenite"]
|
|
13
14
|
[build-dependencies]
|
|
14
15
|
tauri-plugin = { version = "3.0.0-alpha.3", features = ["build"] }
|
|
15
16
|
[dependencies]
|
|
@@ -24,6 +25,20 @@ tempfile = "3"
|
|
|
24
25
|
sha2 = "0.11"
|
|
25
26
|
hex = "0.4"
|
|
26
27
|
uuid = { version = "1", features = ["v4"] }
|
|
27
|
-
tokio = { version = "1", features = ["sync", "time", "macros"] }
|
|
28
|
+
tokio = { version = "1", features = ["sync", "time", "macros", "net", "io-util", "rt"] }
|
|
29
|
+
axum = { version = "0.8", default-features = false, optional = true }
|
|
30
|
+
hyper = { version = "1", features = ["server", "http1"], optional = true }
|
|
31
|
+
hyper-util = { version = "0.1", features = ["tokio"], optional = true }
|
|
32
|
+
http-body-util = { version = "0.1", optional = true }
|
|
33
|
+
futures-util = { version = "0.3", features = ["sink"], optional = true }
|
|
34
|
+
tokio-util = { version = "0.7", features = ["rt"], optional = true }
|
|
35
|
+
tokio-tungstenite = { version = "0.28", optional = true }
|
|
28
36
|
[dev-dependencies]
|
|
37
|
+
rcgen = { version = "0.14", default-features = false, features = ["aws_lc_rs", "pem"] }
|
|
38
|
+
time = "0.3"
|
|
39
|
+
native-tls = "0.2"
|
|
40
|
+
tokio-native-tls = "0.3"
|
|
29
41
|
tokio = { version = "1", features = ["sync", "time", "macros", "rt-multi-thread", "io-util"] }
|
|
42
|
+
|
|
43
|
+
[target.'cfg(windows)'.dependencies]
|
|
44
|
+
windows-sys = { version = "0.61", features = ["Win32_Networking_WinHttp", "Win32_Foundation"] }
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
use super::*;
|
|
2
|
+
use std::sync::{Mutex, OnceLock};
|
|
3
|
+
use tokio::{
|
|
4
|
+
io::{AsyncReadExt, AsyncWriteExt},
|
|
5
|
+
net::TcpStream,
|
|
6
|
+
};
|
|
7
|
+
use tungstenite::{client::IntoClientRequest, Message};
|
|
8
|
+
fn certificate() -> &'static (String, String) {
|
|
9
|
+
static CERT: OnceLock<(String, String)> = OnceLock::new();
|
|
10
|
+
CERT.get_or_init(|| {
|
|
11
|
+
let mut params =
|
|
12
|
+
rcgen::CertificateParams::new(vec!["localhost".into(), "native-network.example.test".into()]).unwrap();
|
|
13
|
+
params.extended_key_usages = vec![rcgen::ExtendedKeyUsagePurpose::ServerAuth];
|
|
14
|
+
params.key_usages = vec![rcgen::KeyUsagePurpose::DigitalSignature, rcgen::KeyUsagePurpose::KeyEncipherment];
|
|
15
|
+
params.not_before = time::OffsetDateTime::now_utc() - time::Duration::days(1);
|
|
16
|
+
params.not_after = time::OffsetDateTime::now_utc() + time::Duration::days(30);
|
|
17
|
+
// Generate a fresh RSA identity in memory for each test process.
|
|
18
|
+
let key = rcgen::KeyPair::generate_rsa_for(&rcgen::PKCS_RSA_SHA256, rcgen::RsaKeySize::_2048).unwrap();
|
|
19
|
+
(params.self_signed(&key).unwrap().pem(), key.serialize_pem())
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
struct Server {
|
|
23
|
+
port: u16,
|
|
24
|
+
task: JoinHandle<()>,
|
|
25
|
+
}
|
|
26
|
+
impl Drop for Server {
|
|
27
|
+
fn drop(&mut self) {
|
|
28
|
+
self.task.abort();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async fn upstream(tls: bool) -> Server {
|
|
32
|
+
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
|
33
|
+
let port = listener.local_addr().unwrap().port();
|
|
34
|
+
let task = tokio::spawn(async move {
|
|
35
|
+
let mut clients = tokio::task::JoinSet::new();
|
|
36
|
+
loop {
|
|
37
|
+
let (socket, _) = listener.accept().await.unwrap();
|
|
38
|
+
clients.spawn(async move {
|
|
39
|
+
let service = hyper::service::service_fn(|mut request: Request<Incoming>| async move {
|
|
40
|
+
assert!(!request.headers().contains_key(TOKEN));
|
|
41
|
+
assert!(!request.headers().contains_key(TARGET));
|
|
42
|
+
if request.uri().path() == "/reject" {
|
|
43
|
+
return Ok::<_, Infallible>(
|
|
44
|
+
Response::builder().status(401).body(Body::from("unauthorized")).unwrap(),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if request.headers().contains_key("sec-websocket-key") {
|
|
48
|
+
let accept = tungstenite::handshake::derive_accept_key(
|
|
49
|
+
request.headers()["sec-websocket-key"].as_bytes(),
|
|
50
|
+
);
|
|
51
|
+
let upgrade = hyper::upgrade::on(&mut request);
|
|
52
|
+
tokio::spawn(async move {
|
|
53
|
+
let mut socket = WebSocketStream::from_raw_socket(
|
|
54
|
+
TokioIo::new(upgrade.await.unwrap()),
|
|
55
|
+
Role::Server,
|
|
56
|
+
None,
|
|
57
|
+
)
|
|
58
|
+
.await;
|
|
59
|
+
while let Some(Ok(msg)) = socket.next().await {
|
|
60
|
+
if msg == Message::Text("disconnect".into()) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
if msg.is_close() {
|
|
64
|
+
let _ = socket.flush().await;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if socket.send(msg).await.is_err() {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return Ok(Response::builder()
|
|
73
|
+
.status(101)
|
|
74
|
+
.header("connection", "Upgrade")
|
|
75
|
+
.header("upgrade", "websocket")
|
|
76
|
+
.header("sec-websocket-accept", accept)
|
|
77
|
+
.body(Body::empty())
|
|
78
|
+
.unwrap());
|
|
79
|
+
}
|
|
80
|
+
if request.uri().path() == "/stream" {
|
|
81
|
+
let stream = futures_util::stream::once(async { Ok::<_, io::Error>("data: first\n\n") })
|
|
82
|
+
.chain(futures_util::stream::pending());
|
|
83
|
+
return Ok(Response::builder()
|
|
84
|
+
.header("content-type", "text/event-stream")
|
|
85
|
+
.body(Body::from_stream(stream))
|
|
86
|
+
.unwrap());
|
|
87
|
+
}
|
|
88
|
+
let auth = request.headers().get("authorization").cloned();
|
|
89
|
+
let bytes = request.into_body().collect().await.unwrap().to_bytes();
|
|
90
|
+
let mut response = Response::builder().status(201).header("x-request-id", "test-id");
|
|
91
|
+
if let Some(auth) = auth {
|
|
92
|
+
response = response.header("x-test-auth", auth)
|
|
93
|
+
}
|
|
94
|
+
Ok(response.body(Body::from(bytes)).unwrap())
|
|
95
|
+
});
|
|
96
|
+
if tls {
|
|
97
|
+
let identity =
|
|
98
|
+
native_tls::Identity::from_pkcs8(certificate().0.as_bytes(), certificate().1.as_bytes())
|
|
99
|
+
.unwrap();
|
|
100
|
+
let acceptor = tokio_native_tls::TlsAcceptor::from(native_tls::TlsAcceptor::new(identity).unwrap());
|
|
101
|
+
if let Ok(socket) = acceptor.accept(socket).await {
|
|
102
|
+
let _ = hyper::server::conn::http1::Builder::new()
|
|
103
|
+
.serve_connection(TokioIo::new(socket), service)
|
|
104
|
+
.with_upgrades()
|
|
105
|
+
.await;
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
let _ = hyper::server::conn::http1::Builder::new()
|
|
109
|
+
.serve_connection(TokioIo::new(socket), service)
|
|
110
|
+
.with_upgrades()
|
|
111
|
+
.await;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Server { port, task }
|
|
117
|
+
}
|
|
118
|
+
async fn proxy_server(reject: bool) -> (Server, Arc<Mutex<Vec<String>>>) {
|
|
119
|
+
let calls = Arc::new(Mutex::new(vec![]));
|
|
120
|
+
let recorded = calls.clone();
|
|
121
|
+
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
|
122
|
+
let port = listener.local_addr().unwrap().port();
|
|
123
|
+
let task = tokio::spawn(async move {
|
|
124
|
+
let mut clients = tokio::task::JoinSet::new();
|
|
125
|
+
loop {
|
|
126
|
+
let (mut socket, _) = listener.accept().await.unwrap();
|
|
127
|
+
let calls = recorded.clone();
|
|
128
|
+
clients.spawn(async move {
|
|
129
|
+
let mut header = vec![];
|
|
130
|
+
while !header.ends_with(b"\r\n\r\n") {
|
|
131
|
+
header.push(socket.read_u8().await.unwrap());
|
|
132
|
+
assert!(header.len() < 32768);
|
|
133
|
+
}
|
|
134
|
+
let text = String::from_utf8(header).unwrap();
|
|
135
|
+
let line = text.lines().next().unwrap().to_owned();
|
|
136
|
+
calls.lock().unwrap().push(line.clone());
|
|
137
|
+
if reject {
|
|
138
|
+
socket
|
|
139
|
+
.write_all(b"HTTP/1.1 407 Proxy Authentication Required\r\nContent-Length: 0\r\n\r\n")
|
|
140
|
+
.await
|
|
141
|
+
.unwrap();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let mut words = line.split_whitespace();
|
|
145
|
+
let method = words.next().unwrap();
|
|
146
|
+
let target = words.next().unwrap();
|
|
147
|
+
let (address, rewritten) = if method == "CONNECT" {
|
|
148
|
+
(target.to_owned(), None)
|
|
149
|
+
} else {
|
|
150
|
+
let url = reqwest::Url::parse(target).unwrap();
|
|
151
|
+
(
|
|
152
|
+
format!("{}:{}", url.host_str().unwrap(), url.port_or_known_default().unwrap()),
|
|
153
|
+
Some(text.replacen(
|
|
154
|
+
target,
|
|
155
|
+
&format!("{}{}", url.path(), url.query().map(|q| format!("?{q}")).unwrap_or_default()),
|
|
156
|
+
1,
|
|
157
|
+
)),
|
|
158
|
+
)
|
|
159
|
+
};
|
|
160
|
+
// Keep the non-loopback PAC target entirely inside the test network.
|
|
161
|
+
let address = address.replace("native-network.example.test:", "127.0.0.1:");
|
|
162
|
+
let mut remote = TcpStream::connect(address).await.unwrap();
|
|
163
|
+
if let Some(request) = rewritten {
|
|
164
|
+
remote.write_all(request.as_bytes()).await.unwrap();
|
|
165
|
+
} else {
|
|
166
|
+
socket.write_all(b"HTTP/1.1 200 Connection Established\r\n\r\n").await.unwrap();
|
|
167
|
+
}
|
|
168
|
+
let _ = tokio::io::copy_bidirectional(&mut socket, &mut remote).await;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
(Server { port, task }, calls)
|
|
173
|
+
}
|
|
174
|
+
async fn network(proxy: Option<String>) -> NativeNetwork {
|
|
175
|
+
NativeNetwork::with_resolver(
|
|
176
|
+
Arc::new(move |_, _| Ok(proxy.clone())),
|
|
177
|
+
vec![reqwest::Certificate::from_pem(certificate().0.as_bytes()).unwrap()],
|
|
178
|
+
)
|
|
179
|
+
.await
|
|
180
|
+
.unwrap()
|
|
181
|
+
}
|
|
182
|
+
fn endpoint(network: &NativeNetwork) -> (String, String) {
|
|
183
|
+
let value: serde_json::Value = serde_json::from_str(network.endpoint()).unwrap();
|
|
184
|
+
(format!("http://127.0.0.1:{}", value["port"]), value["token"].as_str().unwrap().into())
|
|
185
|
+
}
|
|
186
|
+
async fn http(network: &NativeNetwork, url: &str) -> reqwest::Response {
|
|
187
|
+
let (base, token) = endpoint(network);
|
|
188
|
+
reqwest::Client::builder()
|
|
189
|
+
.no_proxy()
|
|
190
|
+
.build()
|
|
191
|
+
.unwrap()
|
|
192
|
+
.post(format!("{base}/v1/http"))
|
|
193
|
+
.header(TOKEN, token)
|
|
194
|
+
.header(TARGET, url)
|
|
195
|
+
.header("authorization", "Bearer test")
|
|
196
|
+
.body("request-body")
|
|
197
|
+
.send()
|
|
198
|
+
.await
|
|
199
|
+
.unwrap()
|
|
200
|
+
}
|
|
201
|
+
async fn websocket(
|
|
202
|
+
network: &NativeNetwork, url: &str,
|
|
203
|
+
) -> Result<WebSocketStream<tokio_tungstenite::MaybeTlsStream<TcpStream>>, tungstenite::Error> {
|
|
204
|
+
let (base, token) = endpoint(network);
|
|
205
|
+
let mut request = (base.replace("http:", "ws:") + "/v1/websocket").into_client_request().unwrap();
|
|
206
|
+
request.headers_mut().insert(TOKEN, token.parse().unwrap());
|
|
207
|
+
request.headers_mut().insert(TARGET, url.parse().unwrap());
|
|
208
|
+
tokio_tungstenite::connect_async(request).await.map(|(socket, _)| socket)
|
|
209
|
+
}
|
|
210
|
+
#[tokio::test]
|
|
211
|
+
async fn http_and_websocket_share_direct_and_proxy_routes() {
|
|
212
|
+
for tls in [false, true] {
|
|
213
|
+
for proxied in [false, true] {
|
|
214
|
+
let origin = upstream(tls).await;
|
|
215
|
+
let (proxy, calls) = proxy_server(false).await;
|
|
216
|
+
let network = network(proxied.then(|| format!("http://127.0.0.1:{}", proxy.port))).await;
|
|
217
|
+
let target = format!("{}://localhost:{}/echo?q=1", if tls { "https" } else { "http" }, origin.port);
|
|
218
|
+
let response = http(&network, &target).await;
|
|
219
|
+
assert_eq!(response.status(), 201);
|
|
220
|
+
assert_eq!(response.headers()["x-test-auth"], "Bearer test");
|
|
221
|
+
assert_eq!(response.text().await.unwrap(), "request-body");
|
|
222
|
+
for _ in 0..2 {
|
|
223
|
+
let mut ws = websocket(&network, &target).await.unwrap();
|
|
224
|
+
ws.send(Message::Text("hello".into())).await.unwrap();
|
|
225
|
+
assert_eq!(ws.next().await.unwrap().unwrap(), Message::Text("hello".into()));
|
|
226
|
+
ws.close(Some(tungstenite::protocol::CloseFrame { code: 4001.into(), reason: "finished".into() }))
|
|
227
|
+
.await
|
|
228
|
+
.unwrap();
|
|
229
|
+
}
|
|
230
|
+
let count = calls.lock().unwrap().len();
|
|
231
|
+
assert_eq!(count, if proxied { 3 } else { 0 });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
#[tokio::test]
|
|
236
|
+
async fn streams_without_buffering_and_owner_closes_requests_and_websockets() {
|
|
237
|
+
let origin = upstream(true).await;
|
|
238
|
+
let network = network(None).await;
|
|
239
|
+
let target = format!("https://localhost:{}", origin.port);
|
|
240
|
+
let response = http(&network, &format!("{target}/stream")).await;
|
|
241
|
+
let mut stream = response.bytes_stream();
|
|
242
|
+
assert_eq!(
|
|
243
|
+
tokio::time::timeout(Duration::from_secs(2), stream.next()).await.unwrap().unwrap().unwrap(),
|
|
244
|
+
"data: first\n\n"
|
|
245
|
+
);
|
|
246
|
+
let mut ws = websocket(&network, &format!("{target}/echo")).await.unwrap();
|
|
247
|
+
drop(network);
|
|
248
|
+
assert!(tokio::time::timeout(Duration::from_secs(2), stream.next()).await.unwrap().unwrap().is_err());
|
|
249
|
+
assert!(tokio::time::timeout(Duration::from_secs(2), ws.next()).await.unwrap().unwrap().is_err());
|
|
250
|
+
}
|
|
251
|
+
#[tokio::test]
|
|
252
|
+
async fn handshake_status_and_abnormal_disconnect_survive() {
|
|
253
|
+
let origin = upstream(false).await;
|
|
254
|
+
let network = network(None).await;
|
|
255
|
+
let target = format!("http://localhost:{}", origin.port);
|
|
256
|
+
let err = websocket(&network, &format!("{target}/reject")).await.unwrap_err();
|
|
257
|
+
assert!(matches!(err,tungstenite::Error::Http(response) if response.status()==401));
|
|
258
|
+
let mut ws = websocket(&network, &format!("{target}/echo")).await.unwrap();
|
|
259
|
+
ws.send(Message::Text("disconnect".into())).await.unwrap();
|
|
260
|
+
assert!(matches!(ws.next().await.unwrap().unwrap(),Message::Close(Some(frame)) if u16::from(frame.code)==1011));
|
|
261
|
+
}
|
|
262
|
+
#[tokio::test]
|
|
263
|
+
async fn proxy_failure_is_never_retried_direct() {
|
|
264
|
+
let origin = upstream(true).await;
|
|
265
|
+
let (proxy, calls) = proxy_server(true).await;
|
|
266
|
+
let network = network(Some(format!("http://127.0.0.1:{}", proxy.port))).await;
|
|
267
|
+
let target = format!("https://localhost:{}/echo", origin.port);
|
|
268
|
+
assert_eq!(http(&network, &target).await.status(), 502);
|
|
269
|
+
assert!(websocket(&network, &target).await.is_err());
|
|
270
|
+
assert_eq!(calls.lock().unwrap().len(), 2);
|
|
271
|
+
}
|
|
272
|
+
#[tokio::test]
|
|
273
|
+
async fn resolver_failure_is_fail_closed_for_both_protocols() {
|
|
274
|
+
let network =
|
|
275
|
+
NativeNetwork::with_resolver(Arc::new(|_, _| Err("NATIVE_PROXY_RESOLUTION_FAILED")), vec![]).await.unwrap();
|
|
276
|
+
let response = http(&network, "http://127.0.0.1:1/echo").await;
|
|
277
|
+
assert_eq!(response.status(), 502);
|
|
278
|
+
assert_eq!(response.text().await.unwrap(), "NATIVE_PROXY_RESOLUTION_FAILED");
|
|
279
|
+
assert!(websocket(&network, "http://127.0.0.1:1/echo").await.is_err());
|
|
280
|
+
}
|
|
281
|
+
#[tokio::test]
|
|
282
|
+
async fn native_tls_rejects_untrusted_certificates_and_wrong_hostnames() {
|
|
283
|
+
let origin = upstream(true).await;
|
|
284
|
+
let root = reqwest::Certificate::from_pem(certificate().0.as_bytes()).unwrap();
|
|
285
|
+
for (roots, host) in [(vec![], "localhost"), (vec![root], "127.0.0.1")] {
|
|
286
|
+
let network = NativeNetwork::with_resolver(Arc::new(|_, _| Ok(None)), roots).await.unwrap();
|
|
287
|
+
let target = format!("https://{host}:{}/echo", origin.port);
|
|
288
|
+
assert_eq!(http(&network, &target).await.status(), 502);
|
|
289
|
+
assert!(websocket(&network, &target).await.is_err());
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
#[tokio::test]
|
|
293
|
+
async fn invalid_local_credentials_cannot_open_network_requests() {
|
|
294
|
+
let network = NativeNetwork::with_resolver(Arc::new(|_, _| panic!("must authenticate before routing")), vec![])
|
|
295
|
+
.await
|
|
296
|
+
.unwrap();
|
|
297
|
+
let (base, _) = endpoint(&network);
|
|
298
|
+
let response = reqwest::Client::builder()
|
|
299
|
+
.no_proxy()
|
|
300
|
+
.build()
|
|
301
|
+
.unwrap()
|
|
302
|
+
.get(format!("{base}/v1/http"))
|
|
303
|
+
.header(TARGET, "http://127.0.0.1:1/")
|
|
304
|
+
.send()
|
|
305
|
+
.await
|
|
306
|
+
.unwrap();
|
|
307
|
+
assert_eq!(response.status(), 403);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
#[tokio::test]
|
|
311
|
+
async fn cancelling_pending_http_and_websocket_closes_upstream() {
|
|
312
|
+
for websocket in [false, true] {
|
|
313
|
+
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
|
314
|
+
let port = listener.local_addr().unwrap().port();
|
|
315
|
+
let network = network(None).await;
|
|
316
|
+
let (base, token) = endpoint(&network);
|
|
317
|
+
let url = reqwest::Url::parse(&base).unwrap();
|
|
318
|
+
let mut local = TcpStream::connect(("127.0.0.1", url.port().unwrap())).await.unwrap();
|
|
319
|
+
let upgrade = if websocket {
|
|
320
|
+
"Connection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
|
|
321
|
+
} else {
|
|
322
|
+
""
|
|
323
|
+
};
|
|
324
|
+
let path = if websocket { "websocket" } else { "http" };
|
|
325
|
+
local.write_all(format!("GET /v1/{path} HTTP/1.1\r\nHost: localhost\r\n{TOKEN}: {token}\r\n{TARGET}: http://127.0.0.1:{port}/hang\r\n{upgrade}\r\n").as_bytes()).await.unwrap();
|
|
326
|
+
let (mut remote, _) = tokio::time::timeout(Duration::from_secs(2), listener.accept()).await.unwrap().unwrap();
|
|
327
|
+
let mut headers = vec![];
|
|
328
|
+
while !headers.ends_with(b"\r\n\r\n") {
|
|
329
|
+
headers.push(remote.read_u8().await.unwrap());
|
|
330
|
+
}
|
|
331
|
+
drop(local);
|
|
332
|
+
let mut bytes = vec![];
|
|
333
|
+
tokio::time::timeout(Duration::from_secs(2), remote.read_to_end(&mut bytes))
|
|
334
|
+
.await
|
|
335
|
+
.expect("upstream connection must close when local request is cancelled")
|
|
336
|
+
.unwrap();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
#[tokio::test]
|
|
341
|
+
async fn cancellation_after_stream_headers_closes_upstream() {
|
|
342
|
+
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
|
343
|
+
let port = listener.local_addr().unwrap().port();
|
|
344
|
+
let network = network(None).await;
|
|
345
|
+
let server = tokio::spawn(async move {
|
|
346
|
+
let (mut socket, _) = listener.accept().await.unwrap();
|
|
347
|
+
let mut headers = vec![];
|
|
348
|
+
while !headers.ends_with(b"\r\n\r\n") {
|
|
349
|
+
headers.push(socket.read_u8().await.unwrap());
|
|
350
|
+
}
|
|
351
|
+
// The test sends the known POST body before subscribing to the response.
|
|
352
|
+
let mut body = vec![0; 12];
|
|
353
|
+
socket.read_exact(&mut body).await.unwrap();
|
|
354
|
+
socket.write_all(b"HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nTransfer-Encoding: chunked\r\n\r\nD\r\ndata: first\n\n\r\n").await.unwrap();
|
|
355
|
+
let mut bytes = vec![];
|
|
356
|
+
socket.read_to_end(&mut bytes).await.unwrap();
|
|
357
|
+
});
|
|
358
|
+
let mut stream = http(&network, &format!("http://127.0.0.1:{port}/stream")).await.bytes_stream();
|
|
359
|
+
assert!(stream.next().await.unwrap().is_ok());
|
|
360
|
+
drop(stream);
|
|
361
|
+
tokio::time::timeout(Duration::from_secs(2), server)
|
|
362
|
+
.await
|
|
363
|
+
.expect("cancelled SSE must close its native upstream")
|
|
364
|
+
.unwrap();
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
#[cfg(windows)]
|
|
368
|
+
#[tokio::test]
|
|
369
|
+
async fn windows_pac_routes_http_and_websocket_through_the_same_proxy() {
|
|
370
|
+
let origin = upstream(true).await;
|
|
371
|
+
let (proxy, calls) = proxy_server(false).await;
|
|
372
|
+
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
|
373
|
+
let port = listener.local_addr().unwrap().port();
|
|
374
|
+
let pac = Server {
|
|
375
|
+
port,
|
|
376
|
+
task: tokio::spawn(async move {
|
|
377
|
+
loop {
|
|
378
|
+
let (mut socket, _) = listener.accept().await.unwrap();
|
|
379
|
+
let mut headers = vec![];
|
|
380
|
+
while !headers.ends_with(b"\r\n\r\n") {
|
|
381
|
+
headers.push(socket.read_u8().await.unwrap());
|
|
382
|
+
}
|
|
383
|
+
let body =
|
|
384
|
+
format!("function FindProxyForURL(url, host) {{ return 'PROXY 127.0.0.1:{}'; }}", proxy.port);
|
|
385
|
+
socket.write_all(format!("HTTP/1.1 200 OK\r\nContent-Type: application/x-ns-proxy-autoconfig\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}",body.len(),body).as_bytes()).await.unwrap();
|
|
386
|
+
}
|
|
387
|
+
}),
|
|
388
|
+
};
|
|
389
|
+
let pac_url = format!("http://127.0.0.1:{}/proxy.pac", pac.port);
|
|
390
|
+
let network = NativeNetwork::with_resolver(
|
|
391
|
+
Arc::new(move |url, _| {
|
|
392
|
+
let route = system_proxy::resolve_pac(url, &pac_url)?;
|
|
393
|
+
assert!(route.is_some(), "PAC must select the test proxy for {url}");
|
|
394
|
+
Ok(route)
|
|
395
|
+
}),
|
|
396
|
+
vec![reqwest::Certificate::from_pem(certificate().0.as_bytes()).unwrap()],
|
|
397
|
+
)
|
|
398
|
+
.await
|
|
399
|
+
.unwrap();
|
|
400
|
+
let target = format!("https://native-network.example.test:{}/echo", origin.port);
|
|
401
|
+
assert_eq!(http(&network, &target).await.status(), 201);
|
|
402
|
+
let mut ws = websocket(&network, &target).await.unwrap();
|
|
403
|
+
ws.send(Message::Text("PAC".into())).await.unwrap();
|
|
404
|
+
assert_eq!(ws.next().await.unwrap().unwrap(), Message::Text("PAC".into()));
|
|
405
|
+
assert_eq!(calls.lock().unwrap().len(), 2);
|
|
406
|
+
}
|