Add helper to print message with hash as a header.

Broke out email.go's Hash() in to multiple functions to make this easier, and
update tools that used it.
This commit is contained in:
2014-03-28 21:46:34 -07:00
parent 4c906e9f49
commit 12199604c1
5 changed files with 193 additions and 31 deletions

View File

@@ -0,0 +1,36 @@
package main
import (
"flag"
"fmt"
"io"
"net/mail"
"os"
"github.com/golang/glog"
"xinu.tv/email"
)
func main() {
flag.Parse()
defer glog.Flush()
msg, err := mail.ReadMessage(os.Stdin)
if err != nil {
glog.Fatal(err)
}
h, err := email.HashMessage(msg)
if err != nil {
glog.Fatal(err)
}
for k, vs := range msg.Header {
for _, v := range vs {
fmt.Printf("%s: %s\n", k, v)
}
}
fmt.Println("X-Xinu-Hash:", h)
fmt.Println()
io.Copy(os.Stdout, msg.Body)
}