first comm
This commit is contained in:
parent
427a466c1c
commit
c9aaa698d1
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
/alpine/*
|
||||||
1196
Cargo.lock
generated
Normal file
1196
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "websockets"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
websocket = "*"
|
||||||
4
index.html
Normal file
4
index.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<body>
|
||||||
|
<iframe src="http://localhost:6080/vnc.html" width="800" height="600"></iframe>
|
||||||
|
|
||||||
|
</body>>
|
||||||
7
init.sh
Normal file
7
init.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Download alpine iso
|
||||||
|
wget https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-standard-3.19.0-x86_64.iso -O alpine/alpine.iso
|
||||||
|
|
||||||
|
# Create qemu volume
|
||||||
|
qemu-img create -f qcow2 alpine.qcow2 2
|
||||||
11
run.sh
Normal file
11
run.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run qemu vm
|
||||||
|
qemu-system-x86_64 \
|
||||||
|
-m 512M \
|
||||||
|
-hda alpine.qcow2 \
|
||||||
|
-cdrom alpine.iso \
|
||||||
|
-boot d \
|
||||||
|
-net nic -net user \
|
||||||
|
-vnc :1 \
|
||||||
|
-monitor telnet:127.0.0.1:5555,server,nowait
|
||||||
21
src/main.rs
Normal file
21
src/main.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use std::thread;
|
||||||
|
use websocket::Message;
|
||||||
|
use websocket::sync::Server;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
|
||||||
|
let server = Server::bind("127.0.0.1:1234").unwrap();
|
||||||
|
|
||||||
|
for connection in server.filter_map(Result::ok) {
|
||||||
|
// Spawn a new thread for each connection.
|
||||||
|
thread::spawn(move || {
|
||||||
|
let mut client = connection.accept().unwrap();
|
||||||
|
|
||||||
|
let message = Message::text("Hello, client!");
|
||||||
|
let _ = client.send_message(&message);
|
||||||
|
let mess = client.recv_message();
|
||||||
|
println!("{:#?}", mess);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user