broadcast-network.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!doctype html>
  2. <title>Networking via Broadcast Channel API</title>
  3. <script src="../build/libv86.js"></script>
  4. <script>
  5. "use strict";
  6. window.onload = function()
  7. {
  8. var emulator = window.emulator = new V86({
  9. wasm_path: "../build/v86.wasm",
  10. memory_size: 64 * 1024 * 1024,
  11. vga_memory_size: 2 * 1024 * 1024,
  12. screen_container: document.getElementById("screen_container"),
  13. bios: {
  14. url: "../bios/seabios.bin",
  15. },
  16. vga_bios: {
  17. url: "../bios/vgabios.bin",
  18. },
  19. bzimage: {
  20. url: "../images/buildroot-bzimage68.bin",
  21. },
  22. autostart: true,
  23. });
  24. var broadcast = new BroadcastChannel("v86-network");
  25. broadcast.addEventListener("message", function(e) {
  26. emulator.bus.send("net0-receive", e.data);
  27. });
  28. emulator.add_listener("net0-send", function(packet) {
  29. broadcast.postMessage(packet);
  30. });
  31. }
  32. </script>
  33. <div id="screen_container">
  34. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  35. <canvas style="display: none"></canvas>
  36. </div>
  37. <pre>
  38. # Configure a static IP
  39. ifconfig eth0 up arp 10.5.0.x
  40. # Ping by IP
  41. ping 10.5.0.x
  42. # Run a DNS server and send a query (10.5.0.x for server, 10.5.0.y for record)
  43. echo "anotherhost 10.5.0.y" | dnsd -c - -v - server
  44. nslookup -type=a anotherhost 10.5.0.x - client
  45. # Telnet calculator
  46. socat TCP-L:23,fork exec:bc
  47. # Simple HTTP server
  48. socat TCP-L:80,crlf,fork system:'echo HTTP/1.1 200 OK;echo;lua /root/test.lua'
  49. </pre>