From 7ccb485b50c93b12700cada73974ae9767997ae1 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 15 Oct 2017 18:01:59 -0400 Subject: [PATCH] add two getters --- irc/gateways.go | 8 ++------ irc/getters.go | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/irc/gateways.go b/irc/gateways.go index 7aa72628..1e5d5ed9 100644 --- a/irc/gateways.go +++ b/irc/gateways.go @@ -67,9 +67,7 @@ func webircHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { clientAddress := utils.IPString(client.socket.conn.RemoteAddr()) clientHostname := client.hostname - server.configurableStateMutex.RLock() - defer server.configurableStateMutex.RUnlock() - for _, info := range server.webirc { + for _, info := range server.WebIRCConfig() { for _, address := range info.Hosts { if clientHostname == address || clientAddress == address { // confirm password and/or fingerprint @@ -101,9 +99,7 @@ func proxyHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { clientAddress := utils.IPString(client.socket.conn.RemoteAddr()) clientHostname := client.hostname - server.configurableStateMutex.RLock() - defer server.configurableStateMutex.RUnlock() - for _, address := range server.proxyAllowedFrom { + for _, address := range server.ProxyAllowedFrom() { if clientHostname == address || clientAddress == address { proxiedIP := msg.Params[1] diff --git a/irc/getters.go b/irc/getters.go index df6fd405..e76938d4 100644 --- a/irc/getters.go +++ b/irc/getters.go @@ -23,6 +23,18 @@ func (server *Server) getPassword() []byte { return server.password } +func (server *Server) ProxyAllowedFrom() []string { + server.configurableStateMutex.RLock() + defer server.configurableStateMutex.RUnlock() + return server.proxyAllowedFrom +} + +func (server *Server) WebIRCConfig() []webircConfig { + server.configurableStateMutex.RLock() + defer server.configurableStateMutex.RUnlock() + return server.webirc +} + func (client *Client) getNick() string { client.stateMutex.RLock() defer client.stateMutex.RUnlock()