@@ -32,11 +32,15 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) {
|
|||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
if info.RelayMode == constant.RelayModeRealtime {
|
if info.RelayMode == constant.RelayModeRealtime {
|
||||||
// trim https
|
if strings.HasPrefix(info.BaseUrl, "https://") {
|
||||||
baseUrl := strings.TrimPrefix(info.BaseUrl, "https://")
|
baseUrl := strings.TrimPrefix(info.BaseUrl, "https://")
|
||||||
baseUrl = strings.TrimPrefix(baseUrl, "http://")
|
baseUrl = "wss://" + baseUrl
|
||||||
baseUrl = "wss://" + baseUrl
|
info.BaseUrl = baseUrl
|
||||||
info.BaseUrl = baseUrl
|
} else if strings.HasPrefix(info.BaseUrl, "http://") {
|
||||||
|
baseUrl := strings.TrimPrefix(info.BaseUrl, "http://")
|
||||||
|
baseUrl = "ws://" + baseUrl
|
||||||
|
info.BaseUrl = baseUrl
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch info.ChannelType {
|
switch info.ChannelType {
|
||||||
case common.ChannelTypeAzure:
|
case common.ChannelTypeAzure:
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func PreWssConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, usag
|
|||||||
return errors.New(fmt.Sprintf("用户额度不足,剩余额度为 %d", userQuota))
|
return errors.New(fmt.Sprintf("用户额度不足,剩余额度为 %d", userQuota))
|
||||||
}
|
}
|
||||||
|
|
||||||
if token.RemainQuota < quota {
|
if !token.UnlimitedQuota && token.RemainQuota < quota {
|
||||||
return errors.New(fmt.Sprintf("令牌额度不足,剩余额度为 %d", token.RemainQuota))
|
return errors.New(fmt.Sprintf("令牌额度不足,剩余额度为 %d", token.RemainQuota))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user