mirror of
https://github.com/fhmq/hmq.git
synced 2026-05-04 07:08:32 +00:00
fixed
This commit is contained in:
@@ -18,9 +18,9 @@ func (c *client) CheckTopicAuth(typ int, topic string) bool {
|
|||||||
access := "sub"
|
access := "sub"
|
||||||
switch typ {
|
switch typ {
|
||||||
case 1:
|
case 1:
|
||||||
access = "pub"
|
access = "2"
|
||||||
case 2:
|
case 2:
|
||||||
access = "sub"
|
access = "1"
|
||||||
}
|
}
|
||||||
username := string(c.info.username)
|
username := string(c.info.username)
|
||||||
return authhttp.CheckACL(username, access, topic)
|
return authhttp.CheckACL(username, access, topic)
|
||||||
|
|||||||
@@ -114,23 +114,18 @@ func CheckSuper(clientID, username, password string) bool {
|
|||||||
|
|
||||||
//CheckACL check mqtt connect
|
//CheckACL check mqtt connect
|
||||||
func CheckACL(username, access, topic string) bool {
|
func CheckACL(username, access, topic string) bool {
|
||||||
data := url.Values{}
|
req, err := http.NewRequest("GET", config.ACLURL, nil)
|
||||||
data.Add("username", username)
|
|
||||||
data.Add("topic", topic)
|
|
||||||
data.Add("access", access)
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", config.ACLURL, strings.NewReader(data.Encode()))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("get acl: ", zap.Error(err))
|
log.Error("get acl: ", zap.Error(err))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// data := req.URL.Query()
|
data := req.URL.Query()
|
||||||
|
|
||||||
// data.Add("username", username)
|
data.Add("username", username)
|
||||||
// data.Add("topic", topic)
|
data.Add("topic", topic)
|
||||||
// data.Add("access", access)
|
data.Add("access", access)
|
||||||
// req.URL.RawQuery = data.Encode()
|
req.URL.RawQuery = data.Encode()
|
||||||
// fmt.Println("req:", req)
|
// fmt.Println("req:", req)
|
||||||
resp, err := httpClient.Do(req)
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user