generated from PlexSheep/rs-base
mini https
This commit is contained in:
parent
c240551ad5
commit
5ff6987a07
|
@ -73,7 +73,7 @@ impl Server {
|
|||
let (stream, addr) = match rc_self.server.accept().await {
|
||||
Ok(s) => s,
|
||||
Err(err) => {
|
||||
warn!("could not accept stream: {err:?}");
|
||||
warn!("could not accept tcp stream: {err:?}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -86,7 +86,7 @@ impl Server {
|
|||
match ref_self.acceptor.accept(stream).await {
|
||||
Ok(s) => s,
|
||||
Err(err) => {
|
||||
error!("could not accept tcp stream: {err}");
|
||||
warn!("could not accept tls stream: {err}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -150,12 +150,20 @@ impl Server {
|
|||
addr: SocketAddr,
|
||||
) -> Result<()> {
|
||||
debug!("new peer: {:?}", addr);
|
||||
let mut buf = [0; BUF_SIZE];
|
||||
while stream.read(&mut buf).await? != 0 {
|
||||
stream.write_all(b"pong\0");
|
||||
|
||||
loop {
|
||||
stream
|
||||
.write_all(
|
||||
&b"HTTP/1.0 200 ok\r\n\
|
||||
Connection: close\r\n\
|
||||
Content-length: 12\r\n\
|
||||
\r\n\
|
||||
Hello world!"[..],
|
||||
)
|
||||
.await?;
|
||||
stream.flush().await?;
|
||||
// we should wait, so that we don't spam the client
|
||||
std::thread::sleep(self.cfg.delay);
|
||||
break;
|
||||
}
|
||||
debug!("disconnected peer: {:?}", addr);
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue