From 8fd1f4a30f1a6a17f1cd60947e97bfd6f04953f6 Mon Sep 17 00:00:00 2001 From: cathugger Date: Sun, 27 Jan 2019 14:42:35 +0200 Subject: [PATCH] srnd: use some of headers from outer message --- contrib/backends/srndv2/src/srnd/message.go | 10 +++++----- contrib/backends/srndv2/src/srnd/store.go | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/message.go b/contrib/backends/srndv2/src/srnd/message.go index 20473f0..fc910bf 100644 --- a/contrib/backends/srndv2/src/srnd/message.go +++ b/contrib/backends/srndv2/src/srnd/message.go @@ -262,7 +262,7 @@ func (self *nntpArticle) Pubkey() string { } func (self *nntpArticle) MessageID() (msgid string) { - for _, h := range []string{"Message-ID", "Messageid", "MessageID", "Message-Id"} { + for _, h := range []string{"Message-ID", "Message-Id"} { mid := self.headers.Get(h, "") if mid != "" { msgid = string(mid) @@ -485,7 +485,7 @@ func (self *nntpArticle) WriteBody(wr io.Writer, limit int64) (err error) { // verify a signed message's body // innerHandler must close reader when done // returns error if one happens while verifying article -func verifyMessageSHA512(pk, sig string, body io.Reader, innerHandler func(map[string][]string, io.Reader)) (err error) { +func verifyMessageSHA512(pk, sig string, body io.Reader, innerHandler func(ArticleHeaders, io.Reader)) (err error) { log.Println("unwrapping signed message from", pk) pk_bytes := unhex(pk) sig_bytes := unhex(sig) @@ -497,7 +497,7 @@ func verifyMessageSHA512(pk, sig string, body io.Reader, innerHandler func(map[s r := bufio.NewReader(hdr_reader) msg, err := readMIMEHeader(r) if err == nil { - innerHandler(msg.Header, msg.Body) + innerHandler(ArticleHeaders(msg.Header), msg.Body) } hdr_reader.Close() }(pr) @@ -520,7 +520,7 @@ func verifyMessageSHA512(pk, sig string, body io.Reader, innerHandler func(map[s return } -func verifyMessageBLAKE2B(pk, sig string, body io.Reader, innerHandler func(map[string][]string, io.Reader)) (err error) { +func verifyMessageBLAKE2B(pk, sig string, body io.Reader, innerHandler func(ArticleHeaders, io.Reader)) (err error) { log.Println("unwrapping signed message from", pk) pk_bytes := unhex(pk) sig_bytes := unhex(sig) @@ -532,7 +532,7 @@ func verifyMessageBLAKE2B(pk, sig string, body io.Reader, innerHandler func(map[ r := bufio.NewReader(hdr_reader) msg, err := readMIMEHeader(r) if err == nil { - innerHandler(msg.Header, msg.Body) + innerHandler(ArticleHeaders(msg.Header), msg.Body) } hdr_reader.Close() }(pr) diff --git a/contrib/backends/srndv2/src/srnd/store.go b/contrib/backends/srndv2/src/srnd/store.go index 6e553a4..853009f 100644 --- a/contrib/backends/srndv2/src/srnd/store.go +++ b/contrib/backends/srndv2/src/srnd/store.go @@ -700,7 +700,14 @@ func read_message_body(body io.Reader, hdr map[string][]string, store ArticleSto } // process inner body // verify message - f := func(h map[string][]string, innerBody io.Reader) { + f := func(h ArticleHeaders, innerBody io.Reader) { + // override some of headers of inner message + msgid := nntp.MessageID() + if msgid != "" { + h.Set("Message-Id", msgid) + } + h.Set("Path", nntp.headers.Get("Path", "")) + h.Set("X-Pubkey-Ed25519", pk) // handle inner message e := read_message_body(innerBody, h, store, nil, true, callback) if e != nil {