blob: c6d9c9b8b4ce3728865b4aa06f0ef5f86306f585 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package websockets
import (
"strings"
)
func isOriginAllowed(origin string, cfg *Config) bool {
if cfg.allowedAll {
return true
}
origin = strings.ToLower(origin)
// simple case
origin = strings.ToLower(origin)
for _, o := range cfg.allowedOrigins {
if o == origin {
return true
}
}
// check wildcards
for _, w := range cfg.allowedWOrigins {
if w.match(origin) {
return true
}
}
return false
}
|