@@ -18,8 +18,6 @@ use vector_config::configurable_component;
18
18
const GELF_MAGIC : & [ u8 ] = & [ 0x1e , 0x0f ] ;
19
19
const GZIP_MAGIC : & [ u8 ] = & [ 0x1f , 0x8b ] ;
20
20
const ZLIB_MAGIC : & [ u8 ] = & [ 0x78 ] ;
21
- // TODO: add lz4 compression detection?
22
- // TODO: add zstd compression detect?
23
21
const GELF_MAX_TOTAL_CHUNKS : u8 = 128 ;
24
22
const DEFAULT_TIMEOUT_SECS : f64 = 5.0 ;
25
23
@@ -173,7 +171,6 @@ pub enum ChunkedGelfDecompression {
173
171
}
174
172
175
173
impl ChunkedGelfDecompression {
176
- // TODO: add tests for compression detection
177
174
pub fn from_magic ( data : & Bytes ) -> Self {
178
175
if data. starts_with ( GZIP_MAGIC ) {
179
176
debug ! ( "Detected Gzip compression" ) ;
@@ -182,17 +179,11 @@ impl ChunkedGelfDecompression {
182
179
183
180
if data. starts_with ( ZLIB_MAGIC ) {
184
181
if let Some ( [ first_byte, second_byte] ) = data. get ( 0 ..2 ) {
185
- // TODO: add inspired from https://github.com/grafana/go-gelf/blob/25db8704bcf3f484c958312cd0cc49e5c768dcf1/gelf/reader.go#L120
186
- // and https://github.com/Graylog2/graylog2-server/blob/1bdeca5f8ad3d31ff0c1c7981978ae8c4d300ebc/graylog2-server/src/main/java/org/graylog2/inputs/codecs/gelf/GELFMessage.java#L157
187
182
if ( * first_byte as u16 * 256 + * second_byte as u16 ) % 31 == 0 {
188
183
debug ! ( "Detected Zlib compression" ) ;
189
184
return Self :: Zlib ;
190
185
}
191
186
} ;
192
- // TODO: should we return and error if the data starts with de ZLIB MAGIC
193
- // but does not match the previous branches?
194
- // for example, take a look to the graylog2server implementation
195
- // https://github.com/Graylog2/graylog2-server/blob/1bdeca5f8ad3d31ff0c1c7981978ae8c4d300ebc/graylog2-server/src/main/java/org/graylog2/inputs/codecs/gelf/GELFMessage.java#L160
196
187
} ;
197
188
198
189
debug ! ( "No compression detected" , ) ;
@@ -231,9 +222,6 @@ pub enum ChunkedGelfDecompressionError {
231
222
ZlibDecompression { source : std:: io:: Error } ,
232
223
}
233
224
234
- // TODO: add a comment that I removed the PartialEq and Eq derive due to
235
- // std::io::Error not implementing them. I had to refactor assert_eq to
236
- // assert!(matches!(..)) in tests due to this.
237
225
#[ derive( Debug , Snafu ) ]
238
226
pub enum ChunkedGelfDecoderError {
239
227
#[ snafu( display( "Invalid chunk header with less than 10 bytes: 0x{header:0x}" ) ) ]
@@ -516,8 +504,6 @@ impl Decoder for ChunkedGelfDecoder {
516
504
}
517
505
}
518
506
519
- // TODO: should I add compression tests in the UDP socket module tests?
520
- // as we did with the initial chunked gelf implementation.
521
507
#[ cfg( test) ]
522
508
mod tests {
523
509
0 commit comments