v86 icon indicating copy to clipboard operation
v86 copied to clipboard

network: Fetch based browser networking

Open basicer opened this issue 8 months ago • 2 comments

Emulate a networking stack, intercept HTTP requests, serve them with fetch(). Enable by setting networking_proxy=fetch

Somewhat fixes #198

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

  • ARP replies by establishing the gateways IP
  • DHCP server sending gateway, dns, and client-ip
    • Gateway: 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

Limitations:

  • 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

basicer avatar Jun 20 '24 06:06 basicer