From 41b78f0b5872a18257efede76e0c78fe76ef4af6 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 23 Nov 2019 19:47:03 +0100 Subject: [PATCH] Decode basic milter packet structure --- .gitignore | 4 ++++ main.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 0570206..2f4396f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ +# Ignore .vagrant folder +.vagrant + +# Ignore build result milter-experiment diff --git a/main.go b/main.go index 50fb88b..32ea9b4 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,17 @@ func handleMtaConnection(clientConnection *bufio.ReadWriter) { logger.Errorln(err.Error()) } logger.Debugf("Parsed length: %d\n", packetLength) + + // Next up is a character, indicating the milter command + logger.Debugf("Parsing command from byte: %X\n", buf[4]) + command := string(buf[4]) + logger.Debugf("Parsed packet command: %s\n", command) + + // Last part is data with lenght len-1 + data := make([]byte, packetLength) + data = buf[5 : 5+packetLength-1] + logger.Debugf("Hexdump of packet payload read:\n%s", hex.Dump(data)) + } } }