Write correct IP in WriteData() error

Return the correct IP address on error during
chatConnection.WirteData().  If the server is behind a reverse proxy,
the connection object will have "127.0.0.1" as the remote address.
This commit is contained in:
Zorchenhimer 2019-03-23 13:30:04 -04:00
parent f36a51bf2b
commit c0d3731b84
1 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"net"
"sync"
@ -26,7 +27,11 @@ func (cc *chatConnection) WriteData(data interface{}) error {
defer cc.mutex.Unlock()
stats.msgOutInc()
return cc.WriteJSON(data)
err := cc.WriteJSON(data)
if err != nil {
return fmt.Errorf("Error writing data to %s: %v", cc.Host(), err)
}
return nil
}
func (cc *chatConnection) Host() string {