3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00

WEBIRC: Export fields so the config loads properly

This commit is contained in:
Daniel Oaks 2017-10-15 18:15:18 +10:00
parent 34987ba53a
commit e1868f8a47
2 changed files with 8 additions and 8 deletions

View File

@ -398,7 +398,7 @@ func LoadConfig(filename string) (config *Config, err error) {
var newWebIRC []webircConfig var newWebIRC []webircConfig
for _, webirc := range config.Server.WebIRC { for _, webirc := range config.Server.WebIRC {
// skip webirc blocks with no hosts (such as the example one) // skip webirc blocks with no hosts (such as the example one)
if len(webirc.hosts) == 0 { if len(webirc.Hosts) == 0 {
continue continue
} }

View File

@ -16,15 +16,15 @@ import (
) )
type webircConfig struct { type webircConfig struct {
passwordString string `yaml:"password"` PasswordString string `yaml:"password"`
password []byte `yaml:"password-bytes"` Password []byte `yaml:"password-bytes"`
hosts []string Hosts []string
} }
// ProcessPassword populates our password. // ProcessPassword populates our password.
func (wc *webircConfig) ProcessPassword() error { func (wc *webircConfig) ProcessPassword() error {
password, error := passwd.DecodePasswordHash(wc.passwordString) password, error := passwd.DecodePasswordHash(wc.PasswordString)
wc.password = password wc.Password = password
return error return error
} }
@ -40,11 +40,11 @@ func webircHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
server.configurableStateMutex.RLock() server.configurableStateMutex.RLock()
defer server.configurableStateMutex.RUnlock() defer server.configurableStateMutex.RUnlock()
for _, info := range server.webirc { for _, info := range server.webirc {
for _, address := range info.hosts { for _, address := range info.Hosts {
if clientHostname == address || clientAddress == address { if clientHostname == address || clientAddress == address {
// confirm password // confirm password
givenPassword := msg.Params[0] givenPassword := msg.Params[0]
if passwd.ComparePasswordString(info.password, givenPassword) == nil { if passwd.ComparePasswordString(info.Password, givenPassword) == nil {
proxiedIP := msg.Params[3] proxiedIP := msg.Params[3]
return client.ApplyProxiedIP(proxiedIP) return client.ApplyProxiedIP(proxiedIP)