Skip to content

Commit

Permalink
network: Fetch based browser networking
Browse files Browse the repository at this point in the history
Emulate a networking stack, intercept HTTP requests, serve
them with fetch().  Enable by setting networking_proxy=fetch

Somewhat fixes copy#198

Just enough networking for http work for package managers and
net-boot. The networking stack just reflects the macaddress of
packets it receives, so shouldnt be bothered by mac address
changes. Services include:

- ARP replies by establishing the gateways IP
- DHCP server sending gateway, dns, and client-ip
  - Gatway: 192.168.86.1
  - Client: 192.168.86.100
  - Netmask: 255.255.255.0
- UDP DNS server, all addresses resolve to: 192.168.87.1
- NTP Server, giving out the current time from Date()
- Replies to ICMP pings to any IP address
- UDP echo server on port 8

Lilimitations:
- Request are limited by CORS rules, but CORS-proxies can work around
  this.
- Redirects are handled transparently by fetch. The upside is sites that
  force an http->https upgrade appear to the VM to work over http.

Future Work:
- Allow HTTP requests from browser to be served by VM.
- HTTPS support (maybe with help of a rust based TLS stack in WASM)
- Support for POSTing binary data
  • Loading branch information
basicer committed Jun 20, 2024
1 parent a0ef1cc commit 3a27b62
Show file tree
Hide file tree
Showing 5 changed files with 1,154 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ CORE_FILES=const.js config.js io.js main.js lib.js buffer.js ide.js pci.js flopp
LIB_FILES=9p.js filesystem.js jor1k.js marshall.js utf8.js
BROWSER_FILES=screen.js keyboard.js mouse.js speaker.js serial.js \
network.js starter.js worker_bus.js dummy_screen.js \
print_stats.js filestorage.js
fetch_network.js print_stats.js filestorage.js

RUST_FILES=$(shell find src/rust/ -name '*.rs') \
src/rust/gen/interpreter.rs src/rust/gen/interpreter0f.rs \
Expand Down
2 changes: 1 addition & 1 deletion debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"memory.js dma.js pit.js vga.js ps2.js rtc.js uart.js acpi.js apic.js ioapic.js sb16.js " +
"ne2k.js state.js virtio.js virtio_console.js bus.js elf.js kernel.js";

var BROWSER_FILES = "main.js screen.js keyboard.js mouse.js speaker.js serial.js network.js starter.js worker_bus.js print_stats.js filestorage.js";
var BROWSER_FILES = "main.js screen.js keyboard.js mouse.js speaker.js serial.js network.js fetch_network.js starter.js worker_bus.js print_stats.js filestorage.js";
var LIB_FILES = "";

// jor1k stuff
Expand Down
Loading

0 comments on commit 3a27b62

Please sign in to comment.