v86
v86 copied to clipboard
Use networking without the websocket proxy?
Currently, networking is run through https://github.com/benjamincburns/websockproxy which needs a server to be set up and have v86 pointed at it. It also limits the speed. I was wondering if we could run the networking through javascript calls instead or by some other local solution. (websockproxy also doesn't support https so it would be nice if there was a solution that could use that)
There's not much we can do. One possibility would be to write a browser extension, but it's doubtful that this would be used by many people due to the security implications. Extension apis are also quite high-level (tcp/udp) I believe, so this would require an implementation of the full network stack below.
One could also implement proxies for the higher level protocols, for example an http and a dns proxy may be sufficient for most use-cases and don't need to be as restricted as the low-level proxy.
Alright.. well I guess I'll look around a little bit for this idea, but I'm not much of a developer
I've been thinking about this as well. Obviously full network (i.e., Internet) access is pretty much impossible due to browser origin/CORS/etc restrictions. However, I think LAN stye networking between the host, v86 vm, and original web server (i.e., your origin) could be really useful.
Here are some things that would be useful:
- use a
postMessage
style interface to connect a JS "server" in the browser to something running in the VM - similar to the above, but proxy a server running in the VM out to clients in the browser
- allow the VM to
wget
orcurl
things from your origin (e.g., leave large, optional pieces of the vm's files) on the origin server, but let the browserfetch
them and feed theArrayBuffer
s into the vm. - Allow something more robust than xterm->ttyS0 so you can easily manage window resizing. I'd love to connect my
xterm.js
session to a network interface and have this happen automatically.
Re-implementing the entire network stack in JS to do all this seems like overkill. Could we not expose a higher-level network socket so these types of things are possible?
@BenNottelling Did you find any solution for this networking? I have a situation to stream data to a process running in the VM using network. Any suggestion?
@BenNottelling Did you find any solution for this networking? I have a situation to stream data to a process running in the VM using network. Any suggestion?
No, I never really looked into it. I just made my own proxy server without the rate limiting, but it's still quite slow. https://github.com/BenNottelling/websockproxy Also, it doesn't do HTTPS. I haven't looked into an improved solution
@humphd
* use a `postMessage` style interface to connect a JS "server" in the browser to something running in the VM * similar to the above, but proxy a server running in the VM out to clients in the browser
I had setup an apache server inside the VM and trying to interface it to a webapp outside (may be imagine iframe) with postMessage. For instance, iframe.contenWindow.postMessage("message", "http://localhost");. It doesn't really work. Do you have an idea to expose webserver in the VM to outside?
Actually it is possible with WebRTC data channel. WebRTC requires signaling service and iceServers. Ice servers are optional for same computer and same network!
-
Signaling service implementation is not a part of WebRTC standard, so it can be any and emulated with some stub/mock. Signaling (RTCPeerConnection.currentLocalDescription + RTCPeerConnection.currentRemoteDescription) is only required to start communication; then it can be ignored.
-
ICE servers (multiple STUN and/or TURN) are optional. They are needed to resolve ip and url, when you are communicate between different networks or even with nat.
-
WebRTC can transfer different things: video, audio or data (e.g. you can use only data).
-
See also #569 #23 and №155
Examples of avoiding additional webrtc settings for data channel:
PeerJS - browser's WebRTC implementation to simplify peer-to-peer connection API WebRTC one to one without signaling server Simple Peer WebRTC Buggy data exchange example with php http signaling instead of websockets
Actually it is possible with WebRTC data channel. WebRTC requires signaling service and iceServers. Ice servers are optional for same computer and same network!
- Signaling service implementation is not a part of WebRTC standard, so it can be any and emulated with some stub/mock. Signaling (RTCPeerConnection.currentLocalDescription + RTCPeerConnection.currentRemoteDescription) is only required to start communication; then it can be ignored.
- ICE servers (multiple STUN and/or TURN) are optional. They are needed to resolve ip and url, when you are communicate between different networks or even with nat.
- WebRTC can transfer different things: video, audio or data (e.g. you can use only data).
- See also Networking between two or more instances #569 Network support #23 and №155
Examples of avoiding additional webrtc settings for data channel:
PeerJS - browser's WebRTC implementation to simplify peer-to-peer connection API WebRTC one to one without signaling server Simple Peer WebRTC Buggy data exchange example with php http signaling instead of websockets
You were right! Turns out it's easier than you'd think. :)
# Change the following lines if you want dnsmasq to serve SRV
# records.
# You may add multiple srv-host lines.
# The fields are <name>,<target>,<port>,<priority>,<weight>
# interface=eth0
bind-interfaces
domain=v86.p2p
dhcp-option=3,255.0.0.0
dhcp-option=6,10.5.0.1
dhcp-option=121,10.5.0.2/24,10.5.0.1
dhcp-range=10.5.0.2,10.5.250.250,5m
# A SRV record sending LDAP for the example.com domain to
# ldapserver.example.com port 289
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
# Two SRV records for LDAP, each with different priorities
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2
# A SRV record indicating that there is no LDAP server for the domain
# example.com
#srv-host=_ldap._tcp.example.com
# The following line shows how to make dnsmasq serve an arbitrary PTR
- /etc/dnsmasq.conf 1/43 2%
That's my dnsmasq.conf for OpenWRT (I copied dnsmasq.conf to /tmp and used `mount --bind /tmp/dnsmasq.conf /etc/dnsmasq.conf). DHCP actually works, surprisingly.
@hello-smile6 Thanks for config. DHCP is not a problem. But how do you connect instances through WebRTC?
@hello-smile6 Thanks for config. DHCP is not a problem. But how do you connect instances through WebRTC?
I'll upload to a Gitea repo and send a link.
@proxy-m https://gitea.9pfs.repl.co/9pfs/v86-webrtc-network/src/branch/main/ Feel free to add to it if there's something that could be improved.
@proxy-m https://gitea.9pfs.repl.co/9pfs/v86-webrtc-network/src/branch/main/ Feel free to add to it if there's something that could be improved.
This appears to be down now. Can you check on it or move it to Github?
@proxy-m https://gitea.9pfs.repl.co/9pfs/v86-webrtc-network/src/branch/main/ Feel free to add to it if there's something that could be improved.
This appears to be down now. Can you check on it or move it to Github?
If my Git server is down, it will usually come back up within a few minutes.
Now I'm getting this:
Now I'm getting this:
Partially my fault, partially Replit's fault. It should work within 24 hours, if it isn't already
Now I'm getting this:
Replit fixed it, works now!
Hello, @hello-smile6. Would you mind explaining how to use your WebRTC data channel to get faster internet transfer speeds using v86? I'm a novice linux user and using the Arch Linux distro on v86 and would like to know if it is possible and how to modify my Arch Linux installation on v86 to use your WebRTC data channel.
Thanks!
with the implementation of webrtc and direct peer to peer communication with @ip i get max speeds of 500Kb/s. has anyone managed to get better scores and if so how?
Can you share your code for this?
Can you share your code for this?
I have implemented the code provided above :
https://gitea.9pfs.repl.co/9pfs/v86-webrtc-network/src/branch/main/bridge2ws.js
but I can't go over 500kb/s, I'll try to use https://peerjs.com/ for webRTC and not bugout (https://chr15m.github.io/bugout/)
Let us know if that performs better. Thanks!
Here is another option: https://leaningtech.com/webvm-virtual-machine-with-networking-via-tailscale/
Hi, I am unable to access the repo at https://gitea.9pfs.repl.co/9pfs/v86-webrtc-network/src/branch/main/
@farhan-ct
to access the repo
https://github.com/proxy-m/v86-webrtc-network
Thank you @proxy-m
If someone insterested, container2wasm have network stack that works on Fetch API: https://github.com/ktock/container2wasm/blob/main/examples/networking/fetch/README.md, but CORS limits are still applied (HTTP(S)-only connections and required allowed CORS on webserver side)