From aca6a0dfa4358da7b1c3d589c35f9b24a1d479d5 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 20 Apr 2017 17:47:33 -0400 Subject: [PATCH 1/4] fix --- contrib/backends/srndv2/src/srnd/mod.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/backends/srndv2/src/srnd/mod.go b/contrib/backends/srndv2/src/srnd/mod.go index c22a164..da576f7 100644 --- a/contrib/backends/srndv2/src/srnd/mod.go +++ b/contrib/backends/srndv2/src/srnd/mod.go @@ -89,7 +89,11 @@ func (self simpleModEvent) Reason() string { } func (self simpleModEvent) Target() string { - return strings.Split(string(self), " ")[1] + parts := strings.Split(string(self), " ") + if len(parts) > 1 { + return parts[1] + } + return "" } func (self simpleModEvent) Scope() string { From db03367945870dd4b4c1e1f114d5e263114baf39 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 20 Apr 2017 18:00:59 -0400 Subject: [PATCH 2/4] fix --- contrib/backends/srndv2/src/srnd/mod.go | 8 +++++--- contrib/backends/srndv2/src/srnd/store.go | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/mod.go b/contrib/backends/srndv2/src/srnd/mod.go index da576f7..6b5fec5 100644 --- a/contrib/backends/srndv2/src/srnd/mod.go +++ b/contrib/backends/srndv2/src/srnd/mod.go @@ -315,8 +315,10 @@ func (mod *modEngine) HandleMessage(msgid string) { pubkey := nntp.Pubkey() for _, line := range strings.Split(nntp.Message(), "\n") { line = strings.Trim(line, "\r\t\n ") - ev := ParseModEvent(line) - mod.Execute(ev, pubkey) + if len(line) > 0 { + ev := ParseModEvent(line) + mod.Execute(ev, pubkey) + } } } } @@ -325,7 +327,7 @@ func (mod *modEngine) Do(ev ModEvent) { action := ev.Action() target := ev.Target() if action == ModDelete || action == ModDeleteAlt { - msgid := ev.Target() + msgid := target if !ValidMessageID(msgid) { // invalid message-id log.Println("invalid message-id", msgid) diff --git a/contrib/backends/srndv2/src/srnd/store.go b/contrib/backends/srndv2/src/srnd/store.go index 6325601..06a0d0b 100644 --- a/contrib/backends/srndv2/src/srnd/store.go +++ b/contrib/backends/srndv2/src/srnd/store.go @@ -469,11 +469,11 @@ func (self *articleStore) GetMessage(msgid string) (nntp NNTPMessage) { R: msg.Body, N: MaxMessageSize, } - err = read_message_body(body, hdr, nil, nil, true, func(nntp NNTPMessage) { + err = read_message_body(body, hdr, nil, nil, true, func(n NNTPMessage) { c := chnl // inject pubkey for mod - nntp.Headers().Set("X-PubKey-Ed25519", hdr.Get("X-PubKey-Ed25519")) - c <- nntp + n.Headers().Set("X-PubKey-Ed25519", hdr.Get("X-PubKey-Ed25519")) + c <- n close(c) }) if err == nil { From cff94dc8d8dba8e37469a398909944872929061c Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 20 Apr 2017 18:07:07 -0400 Subject: [PATCH 3/4] fug --- contrib/backends/srndv2/src/srnd/mod.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/mod.go b/contrib/backends/srndv2/src/srnd/mod.go index 6b5fec5..2f77a1b 100644 --- a/contrib/backends/srndv2/src/srnd/mod.go +++ b/contrib/backends/srndv2/src/srnd/mod.go @@ -51,7 +51,7 @@ type ModUI interface { type ModAction string const ModInetBan = ModAction("overchan-inet-ban") -const ModDelete = ModAction("overchan-delete") +const ModDelete = ModAction("delete") const ModRemoveAttachment = ModAction("overchan-del-attachment") const ModStick = ModAction("overchan-stick") const ModLock = ModAction("overchan-lock") @@ -81,7 +81,14 @@ func (self simpleModEvent) String() string { } func (self simpleModEvent) Action() ModAction { - return ModAction(strings.Split(string(self), " ")[0]) + switch strings.Split(string(self), " ")[0] { + case "delete": + return ModDelete + + case "overchan-inet-ban": + return ModInetBan + } + return "" } func (self simpleModEvent) Reason() string { From f370a4ccbdb83a62ac0bd66efa524ce8760c6164 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 20 Apr 2017 18:08:32 -0400 Subject: [PATCH 4/4] fug --- contrib/backends/srndv2/src/srnd/mod.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/mod.go b/contrib/backends/srndv2/src/srnd/mod.go index 2f77a1b..c3ad8c0 100644 --- a/contrib/backends/srndv2/src/srnd/mod.go +++ b/contrib/backends/srndv2/src/srnd/mod.go @@ -84,7 +84,6 @@ func (self simpleModEvent) Action() ModAction { switch strings.Split(string(self), " ")[0] { case "delete": return ModDelete - case "overchan-inet-ban": return ModInetBan } @@ -425,7 +424,6 @@ func (mod *modEngine) Execute(ev ModEvent, pubkey string) { action := ev.Action() target := ev.Target() switch action { - case ModDeleteAlt: case ModDelete: if mod.AllowDelete(pubkey, target) { mod.Do(ev)