Skip to content

Commit

Permalink
server: add uri Path to address
Browse files Browse the repository at this point in the history
For #1415
  • Loading branch information
wdvxdr1123 committed Mar 23, 2022
1 parent f63c59f commit d42d8dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,19 @@ func runHTTP(bot *coolq.CQBot, node yaml.Node) {
return
}

network, addr := "tcp", ""
network, addr := "tcp", conf.Address
s := &httpServer{accessToken: conf.AccessToken}
if conf.Address != "" {
switch {
case conf.Address != "":
uri, err := url.Parse(conf.Address)
if err == nil && uri.Scheme != "" {
network = uri.Scheme
addr = uri.Host
addr = uri.Host + uri.Path
}
} else if conf.Host != "" || conf.Port != 0 {
case conf.Host != "" || conf.Port != 0:
addr = fmt.Sprintf("%s:%d", conf.Host, conf.Port)
log.Warnln("HTTP 服务器使用了过时的配置格式,请更新配置文件!")
} else {
default:
goto client
}
s.api = api.NewCaller(bot)
Expand Down
8 changes: 4 additions & 4 deletions server/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ func runWSServer(b *coolq.CQBot, node yaml.Node) {
log.Warn("正向 Websocket 使用了过时的配置格式,请更新配置文件")
address = fmt.Sprintf("%s:%d", conf.Host, conf.Port)
} else {
addr, err := url.Parse(conf.Address)
if err == nil && addr.Scheme != "" {
network = addr.Scheme
address = addr.Host
uri, err := url.Parse(conf.Address)
if err == nil && uri.Scheme != "" {
network = uri.Scheme
address = uri.Host + uri.Path
}
}
s := &webSocketServer{
Expand Down

0 comments on commit d42d8dd

Please sign in to comment.