mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
add HEADER_BYTES_LEN
This commit is contained in:
parent
2a01232f6a
commit
7b0bc23a9f
1 changed files with 4 additions and 2 deletions
|
|
@ -14,6 +14,8 @@ use gio::{
|
||||||
};
|
};
|
||||||
use glib::{Bytes, Priority};
|
use glib::{Bytes, Priority};
|
||||||
|
|
||||||
|
pub const HEADER_BYTES_LEN: usize = 0x400; // 1024
|
||||||
|
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
status: Status,
|
status: Status,
|
||||||
meta: Option<Meta>,
|
meta: Option<Meta>,
|
||||||
|
|
@ -34,7 +36,7 @@ impl Header {
|
||||||
) {
|
) {
|
||||||
// Take header buffer from input stream
|
// Take header buffer from input stream
|
||||||
Self::read_from_socket_connection_async(
|
Self::read_from_socket_connection_async(
|
||||||
Vec::with_capacity(1024),
|
Vec::with_capacity(HEADER_BYTES_LEN),
|
||||||
socket_connection,
|
socket_connection,
|
||||||
match cancellable {
|
match cancellable {
|
||||||
Some(value) => Some(value),
|
Some(value) => Some(value),
|
||||||
|
|
@ -105,7 +107,7 @@ impl Header {
|
||||||
move |result| match result {
|
move |result| match result {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
// Expect valid header length
|
// Expect valid header length
|
||||||
if bytes.len() == 0 || buffer.len() + 1 > 1024 {
|
if bytes.len() == 0 || buffer.len() >= HEADER_BYTES_LEN {
|
||||||
return callback(Err((Error::Protocol, None)));
|
return callback(Err((Error::Protocol, None)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue