Merge pull request #175 from cathugger/master
srnd: use some of headers from outer message
This commit is contained in:
commit
29e6d12967
@ -262,7 +262,7 @@ func (self *nntpArticle) Pubkey() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *nntpArticle) MessageID() (msgid 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, "")
|
mid := self.headers.Get(h, "")
|
||||||
if mid != "" {
|
if mid != "" {
|
||||||
msgid = string(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
|
// verify a signed message's body
|
||||||
// innerHandler must close reader when done
|
// innerHandler must close reader when done
|
||||||
// returns error if one happens while verifying article
|
// 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)
|
log.Println("unwrapping signed message from", pk)
|
||||||
pk_bytes := unhex(pk)
|
pk_bytes := unhex(pk)
|
||||||
sig_bytes := unhex(sig)
|
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)
|
r := bufio.NewReader(hdr_reader)
|
||||||
msg, err := readMIMEHeader(r)
|
msg, err := readMIMEHeader(r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
innerHandler(msg.Header, msg.Body)
|
innerHandler(ArticleHeaders(msg.Header), msg.Body)
|
||||||
}
|
}
|
||||||
hdr_reader.Close()
|
hdr_reader.Close()
|
||||||
}(pr)
|
}(pr)
|
||||||
@ -520,7 +520,7 @@ func verifyMessageSHA512(pk, sig string, body io.Reader, innerHandler func(map[s
|
|||||||
return
|
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)
|
log.Println("unwrapping signed message from", pk)
|
||||||
pk_bytes := unhex(pk)
|
pk_bytes := unhex(pk)
|
||||||
sig_bytes := unhex(sig)
|
sig_bytes := unhex(sig)
|
||||||
@ -532,7 +532,7 @@ func verifyMessageBLAKE2B(pk, sig string, body io.Reader, innerHandler func(map[
|
|||||||
r := bufio.NewReader(hdr_reader)
|
r := bufio.NewReader(hdr_reader)
|
||||||
msg, err := readMIMEHeader(r)
|
msg, err := readMIMEHeader(r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
innerHandler(msg.Header, msg.Body)
|
innerHandler(ArticleHeaders(msg.Header), msg.Body)
|
||||||
}
|
}
|
||||||
hdr_reader.Close()
|
hdr_reader.Close()
|
||||||
}(pr)
|
}(pr)
|
||||||
|
@ -700,7 +700,14 @@ func read_message_body(body io.Reader, hdr map[string][]string, store ArticleSto
|
|||||||
}
|
}
|
||||||
// process inner body
|
// process inner body
|
||||||
// verify message
|
// 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
|
// handle inner message
|
||||||
e := read_message_body(innerBody, h, store, nil, true, callback)
|
e := read_message_body(innerBody, h, store, nil, true, callback)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
Reference in New Issue
Block a user