Unix Domain Socket -- how to debug no data flowing

Hi
I am trying to write an utility that can be used insead of the fstrm_capture . See here for details ( Jan-Piet Mens :: DNS query/response logging with dnstap (jpmens.net) The relevant details are :

fstrm_capture
I can use fstrm_capture to create a required Unix domain socket which dnstap clients can write to. The program needs a “Frame Streams” content type specified as well as the path to the Unix socket and the file name it should protocol buffer frames to:

$ fstrm_capture -t protobuf:dnstap.Dnstap -u /var/run/dnstap.sock -w fstrm.tap

I wrote a program in Rust which can read a Unix Data Socket .[ The server ]
I wrote a client that reads data and writes to the Unix Data Socket [ The client ] This works

But when I point the actual DNS Server to send packets to this program it is not reading the socket . When I kill the DNS program it writes some data to socket . If I use the fstrm_capture things work fine and packets are captured

I have a suspicion it is blocking data but it is able to read data from the client I write

I know it is a very generic problem and I am looking for any help / pointers.
This is the program I have for the server

fn main() -> io::Result<()> {
    info!(
        " Starting with the following values Chunk Size : {:?}, Socket Name : {:
?} ",
        chunk_size, addr
    );
    // Create a socket and listen to it . We should unbind if the socket exists
    let list01 = UnixListener::bind(&addr).unwrap();

    let mut i = 0;
    let mut current_pointer: usize = 0;
    let mut rewind: usize = 0;
    let mut new_buffer = Bytes::new();
    for stream in list01.incoming() {
        match stream {
            Ok(stream) => {
                let reference = std::io::Read::by_ref(&mut stream);
                loop {
                    let mut chunk = Vec::with_capacity(chunk_size);
                    let bytes_read = reference.take(chunk_size as u64).read_to_e
nd(&mut chunk)?;
                    match bytes_read {
                        0 => {
                            info!("bytes_read ==0 Ending file with iteration {:?
}", i);
                            break;
                        }

                        _ => {
                            info!("bytes read == {:?} for iteration {:?}", bytes
_read, i);
                            /* Align the pointer to the previous frame */
                            let buf1 = Bytes::from(chunk);
                            info!("Buffer read from stream is : {:#?}", buf1);
                        }
                    }
                }
            }
            _ => {
                error!("Error {:?}", stream);
            }
        }
    }

    Ok(())
}
~

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.