fixed at least zero things

This commit is contained in:
Ellie D 2019-05-31 00:59:11 -05:00
parent 3a5b9ce46a
commit 1b3d87e9a6
2 changed files with 23 additions and 16 deletions

19
README.md Normal file
View File

@ -0,0 +1,19 @@
# Sunbeam TCP Relay v0.1
#### Elizabeth Evelene Amelia Diode, June 2019
#### AGPL v3
### Oh no, what is it this time?
Sunbeam is a simple and fast multi-endpoint TCP relay for
for um
we swear we had a perfectly reasonable use in mind but we honestly can't remember it now.
Basically it just lets clients connect from anywhere, takes data from them, and redistributes
it to all the other connected clients. It's written with an asynchronous structure and
nonblocking I/O, meaning it should be pretty fast, ideally fast enough to handle audio streams
and stuff.
We originally envisioned this as a similar (and similarly-cursed) project to Epistlebox, which
would play the role of an online chat platform to complement the other's terrible imitation of
email. You can indeed use it for that purpose, e.g. by running
`nc [server address] 55555`
on each of the clients, typing messages, and pressing enter.

View File

@ -23,7 +23,7 @@ fn main() {
listener.set_nonblocking(true).expect("cannot set listener to nonblocking");
let mut connections:VecDeque<(TcpStream,SocketAddr)> = VecDeque::new();
let mut bottle:[u8;1] = [0x00];
let mut bottle:[u8;512] = [0x00;512];
let mut idlecycles:usize = 0;
'processor:loop {
@ -56,21 +56,9 @@ fn main() {
0 => {
println!("- connection to {} closed: read reached end of stream",address);
},
_ => {
for _ in 0..connections.len() {
if let Some((mut otherstream,otheraddress)) = connections.pop_front() {
match otherstream.write(&bottle) {
Err(why) => println!("- connection to {} failed: write error: {}",otheraddress,why),
Ok(n) => match n {
0 => {
println!("- connection to {} closed: write reached end of stream",otheraddress);
},
_ => {
connections.push_back((otherstream,otheraddress));
},
},
};
}
n => {
for (otherstream,_otheraddress) in connections.iter_mut() {
let _ = otherstream.write_all(&bottle[..n]);
}
connections.push_back((stream,address));
idlecycles = 0;