mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
use consistent spelling of WebSocket
This commit is contained in:
parent
3d3aec6979
commit
620e30293d
@ -478,7 +478,7 @@ type Config struct {
|
||||
Listeners map[string]listenerConfigBlock
|
||||
UnixBindMode os.FileMode `yaml:"unix-bind-mode"`
|
||||
TorListeners TorListenersConfig `yaml:"tor-listeners"`
|
||||
Websockets struct {
|
||||
WebSockets struct {
|
||||
AllowedOrigins []string `yaml:"allowed-origins"`
|
||||
allowedOriginRegexps []*regexp.Regexp
|
||||
}
|
||||
@ -844,12 +844,12 @@ func LoadConfig(filename string) (config *Config, err error) {
|
||||
return nil, fmt.Errorf("failed to prepare listeners: %v", err)
|
||||
}
|
||||
|
||||
for _, glob := range config.Server.Websockets.AllowedOrigins {
|
||||
for _, glob := range config.Server.WebSockets.AllowedOrigins {
|
||||
globre, err := utils.CompileGlob(glob)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid websocket allowed-origin expression: %s", glob)
|
||||
}
|
||||
config.Server.Websockets.allowedOriginRegexps = append(config.Server.Websockets.allowedOriginRegexps, globre)
|
||||
config.Server.WebSockets.allowedOriginRegexps = append(config.Server.WebSockets.allowedOriginRegexps, globre)
|
||||
}
|
||||
|
||||
if config.Server.STS.Enabled {
|
||||
|
@ -164,14 +164,14 @@ func (wl *WSListener) handle(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
wsUpgrader := websocket.Upgrader{
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
if len(config.Server.Websockets.allowedOriginRegexps) == 0 {
|
||||
if len(config.Server.WebSockets.allowedOriginRegexps) == 0 {
|
||||
return true
|
||||
}
|
||||
origin := strings.TrimSpace(r.Header.Get("Origin"))
|
||||
if len(origin) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, re := range config.Server.Websockets.allowedOriginRegexps {
|
||||
for _, re := range config.Server.WebSockets.allowedOriginRegexps {
|
||||
if re.MatchString(origin) {
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user