mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 02:03:40 -05:00
config: make origin patterns configurable
This commit is contained in:
parent
68f8d4d372
commit
cd4655ac38
2 changed files with 12 additions and 7 deletions
|
@ -48,6 +48,7 @@ type WebConfig struct {
|
|||
TokenKey string `yaml:"token_key"`
|
||||
DebugEndpoints bool `yaml:"debug_endpoints"`
|
||||
EventBufferSize int `yaml:"event_buffer_size"`
|
||||
OriginPatterns []string `yaml:"origin_patterns"`
|
||||
}
|
||||
|
||||
var defaultFileWriter = zeroconfig.WriterConfig{
|
||||
|
@ -120,6 +121,10 @@ func (gmx *Gomuks) LoadConfig() error {
|
|||
gmx.Config.Web.EventBufferSize = 512
|
||||
changed = true
|
||||
}
|
||||
if len(gmx.Config.Web.OriginPatterns) == 0 {
|
||||
gmx.Config.Web.OriginPatterns = []string{"localhost:*", "*.localhost:*"}
|
||||
changed = true
|
||||
}
|
||||
if changed {
|
||||
err = gmx.SaveConfig()
|
||||
if err != nil {
|
||||
|
|
|
@ -86,7 +86,7 @@ func (gmx *Gomuks) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
|||
defer recoverPanic("read loop")
|
||||
|
||||
conn, acceptErr := websocket.Accept(w, r, &websocket.AcceptOptions{
|
||||
OriginPatterns: []string{"localhost:*"},
|
||||
OriginPatterns: gmx.Config.Web.OriginPatterns,
|
||||
})
|
||||
if acceptErr != nil {
|
||||
log.Warn().Err(acceptErr).Msg("Failed to accept websocket connection")
|
||||
|
|
Loading…
Add table
Reference in a new issue