This commit is contained in:
chowyu08
2017-08-26 21:08:25 +08:00
parent 202a8f349d
commit 393dfaa1c8
9 changed files with 387 additions and 8 deletions

View File

@@ -146,11 +146,16 @@ func (c *client) ProcessPublish(buf []byte) {
c.Close()
return
}
topic := msg.Topic()
if c.typ != CLIENT || !c.CheckTopicAuth(PUB, string(topic)) {
return
}
c.ProcessPublishMessage(buf, msg)
if msg.Retain() {
if b := c.broker; b != nil {
err := b.rl.Insert(msg.Topic(), buf)
err := b.rl.Insert(topic, buf)
if err != nil {
log.Error("Insert Retain Message error: ", err)
}
@@ -246,12 +251,13 @@ func (c *client) ProcessSubscribe(buf []byte) {
for i, t := range topics {
topic := string(t)
//check topic auth for client
// if !c.CheckTopicAuth(topic, SUB) {
// log.Error("CheckSubAuth failed")
// retcodes = append(retcodes, message.QosFailure)
// continue
// }
if c.typ == CLIENT {
if !c.CheckTopicAuth(SUB, topic) {
log.Error("CheckSubAuth failed")
retcodes = append(retcodes, message.QosFailure)
continue
}
}
if _, exist := c.subs[topic]; !exist {
queue := false
if strings.HasPrefix(topic, "$queue/") {