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:
parent
970321b92a
commit
5c1fbe2a0b
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
@ -24,7 +25,11 @@ func (cc *chatConnection) WriteData(data interface{}) error {
|
||||||
defer cc.mutex.Unlock()
|
defer cc.mutex.Unlock()
|
||||||
cc.mutex.Lock()
|
cc.mutex.Lock()
|
||||||
stats.msgOutInc()
|
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 {
|
func (cc *chatConnection) Host() string {
|
||||||
|
|
Loading…
Reference in New Issue