Decode basic milter packet structure

This commit is contained in:
Jan Philipp Timme 2019-11-23 19:47:03 +01:00
parent 19e4cf14ae
commit 41b78f0b58
2 changed files with 15 additions and 0 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
# Ignore .vagrant folder
.vagrant
# Ignore build result
milter-experiment

11
main.go
View File

@ -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))
}
}
}