fix: check if the custom channel's server address is valid
This commit is contained in:
@@ -3,6 +3,7 @@ package channel
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"message-pusher/common"
|
||||||
"message-pusher/model"
|
"message-pusher/model"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -13,6 +14,9 @@ func SendCustomMessage(message *model.Message, user *model.User, channel_ *model
|
|||||||
if strings.HasPrefix(url, "http:") {
|
if strings.HasPrefix(url, "http:") {
|
||||||
return errors.New("自定义通道必须使用 HTTPS 协议")
|
return errors.New("自定义通道必须使用 HTTPS 协议")
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(url, common.ServerAddress) {
|
||||||
|
return errors.New("自定义通道不能使用本服务地址")
|
||||||
|
}
|
||||||
template := channel_.Other
|
template := channel_.Other
|
||||||
template = strings.Replace(template, "$url", message.URL, -1)
|
template = strings.Replace(template, "$url", message.URL, -1)
|
||||||
template = strings.Replace(template, "$to", message.To, -1)
|
template = strings.Replace(template, "$to", message.To, -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user