Skip to content

Commit

Permalink
add allowCustomTags
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed Sep 8, 2022
1 parent 9df1d0c commit 06f5c56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions network/wsNetwork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ import (

const sendBufferLength = 1000

func init() {
allowCustomTags = true
}

func TestMain(m *testing.M) {
logging.Base().SetLevel(logging.Debug)
os.Exit(m.Run())
Expand Down
6 changes: 6 additions & 0 deletions network/wsPeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const msgsInReadBufferPerPeer = 10

var tagStringList []string

// allowCustomTags is set by tests to allow non-protocol-defined message tags.
var allowCustomTags bool

func init() {
tagStringList = make([]string, len(protocol.TagList))
for i, t := range protocol.TagList {
Expand Down Expand Up @@ -500,6 +503,9 @@ func (wp *wsPeer) readLoop() {
case protocol.VoteBundleTag:
default: // unrecognized tag
wp.OutOfProtocol = true
if !allowCustomTags {
continue // drop message, skip adding it to queue
}
}
if len(msg.Data) > 0 && wp.incomingMsgFilter != nil && dedupSafeTag(msg.Tag) {
if wp.incomingMsgFilter.CheckIncomingMessage(msg.Tag, msg.Data, true, true) {
Expand Down

0 comments on commit 06f5c56

Please sign in to comment.