This commit is contained in:
joy.zhou
2019-07-15 18:29:45 +08:00
parent e945b35c91
commit 9fef7b668d
2 changed files with 8 additions and 13 deletions

View File

@@ -18,9 +18,9 @@ func (c *client) CheckTopicAuth(typ int, topic string) bool {
access := "sub"
switch typ {
case 1:
access = "pub"
access = "2"
case 2:
access = "sub"
access = "1"
}
username := string(c.info.username)
return authhttp.CheckACL(username, access, topic)

View File

@@ -114,23 +114,18 @@ func CheckSuper(clientID, username, password string) bool {
//CheckACL check mqtt connect
func CheckACL(username, access, topic string) bool {
data := url.Values{}
data.Add("username", username)
data.Add("topic", topic)
data.Add("access", access)
req, err := http.NewRequest("GET", config.ACLURL, strings.NewReader(data.Encode()))
req, err := http.NewRequest("GET", config.ACLURL, nil)
if err != nil {
log.Error("get acl: ", zap.Error(err))
return false
}
// data := req.URL.Query()
data := req.URL.Query()
// data.Add("username", username)
// data.Add("topic", topic)
// data.Add("access", access)
// req.URL.RawQuery = data.Encode()
data.Add("username", username)
data.Add("topic", topic)
data.Add("access", access)
req.URL.RawQuery = data.Encode()
// fmt.Println("req:", req)
resp, err := httpClient.Do(req)
if err != nil {