From c7b6a4a00047c0784a5ff4f46700cc99a5e0a052 Mon Sep 17 00:00:00 2001 From: tigerbot Date: Wed, 22 Mar 2017 17:45:47 -0600 Subject: [PATCH] changed GetState and State to State and SetState https://golang.org/doc/effective_go.html#Getters --- rvpn/genericlistener/connection.go | 16 ++++++++-------- rvpn/genericlistener/connection_table.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rvpn/genericlistener/connection.go b/rvpn/genericlistener/connection.go index 882c8f7..d2134ee 100755 --- a/rvpn/genericlistener/connection.go +++ b/rvpn/genericlistener/connection.go @@ -92,7 +92,7 @@ func NewConnection(connectionTable *Table, conn *websocket.Conn, remoteAddress s p.AddTrackedDomain(string(domain.(string))) } - p.State(true) + p.SetState(true) p.connectionID = connectionID return } @@ -155,16 +155,16 @@ func (c *Connection) ConnectionTable() *Table { return c.connectionTable } -//GetState -- Get state of Socket...this is a high level state. -func (c *Connection) GetState() bool { +//State -- Get state of Socket...this is a high level state. +func (c *Connection) State() bool { c.mutex.Lock() defer c.mutex.Unlock() return c.wssState } -//State -- Set the set of the high level connection -func (c *Connection) State(state bool) { +//SetState -- Set the set of the high level connection +func (c *Connection) SetState(state bool) { c.mutex.Lock() defer c.mutex.Unlock() @@ -193,7 +193,7 @@ func (c *Connection) ConnectionID() int64 { //The libary failes if client abends during write-cycle. a fast moving write is not caught before socket state bubbles up //A synchronised state is maintained func (c *Connection) NextWriter(wssMessageType int) (io.WriteCloser, error) { - if c.GetState() == true { + if c.State() { return c.conn.NextWriter(wssMessageType) } @@ -204,7 +204,7 @@ func (c *Connection) NextWriter(wssMessageType int) (io.WriteCloser, error) { //Write -- Wrapper to allow a high level state check before allowing a write to the socket. func (c *Connection) Write(w io.WriteCloser, message []byte) (int, error) { - if c.GetState() == true { + if c.State() { return w.Write(message) } @@ -234,7 +234,7 @@ func (c *Connection) Reader(ctx context.Context) { if err != nil { if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) { - c.State(false) + c.SetState(false) loginfo.Printf("error: %v", err) } break diff --git a/rvpn/genericlistener/connection_table.go b/rvpn/genericlistener/connection_table.go index 3312e08..94ae5ee 100755 --- a/rvpn/genericlistener/connection_table.go +++ b/rvpn/genericlistener/connection_table.go @@ -57,7 +57,7 @@ func (c *Table) reaper(delay int, idle int) { loginfo.Println("Running scanning ", len(c.connections)) for d := range c.connections { - if d.GetState() == false { + if !d.State() { if time.Since(d.lastUpdate).Seconds() > float64(idle) { loginfo.Println("reaper removing ", d.lastUpdate, time.Since(d.lastUpdate).Seconds()) delete(c.connections, d)