From 3d516cdf4ef2b295ed15ee6e5b9f43d38258a9e8 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 26 Mar 2017 15:26:59 -0700 Subject: [PATCH] tun2: Connection is an Fer now --- lib/tun2/server.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/tun2/server.go b/lib/tun2/server.go index e8144c6..241bf0e 100644 --- a/lib/tun2/server.go +++ b/lib/tun2/server.go @@ -56,6 +56,17 @@ type Connection struct { cancel context.CancelFunc } +func (c *Connection) Fer() ln.F { + return map[string]interface{}{ + "id": c.id, + "remote": c.conn.RemoteAddr(), + "local": c.conn.LocalAddr(), + "isKCP": c.isKCP, + "user": c.user, + "domain": c.domain, + } +} + func NewServer(cfg *ServerConfig) (*Server, error) { if cfg == nil { return nil, errors.New("tun2: config must be specified") @@ -274,12 +285,7 @@ func (s *Server) HandleConn(c net.Conn, isKCP bool) { ln.Log(ln.F{ "action": "backend_connected", - "remote": c.RemoteAddr().String(), - "kcp": isKCP, - "domain": auth.Domain, - "user": connection.user, - "id": connection.id, - }) + }, connection) s.connlock.Lock() s.conns[c] = connection @@ -308,10 +314,7 @@ func (s *Server) HandleConn(c net.Conn, isKCP bool) { ln.Log(ln.F{ "action": "client_disconnecting", - "remote": c.RemoteAddr(), - "domain": auth.Domain, - "id": connection.id, - }) + }, connection) controlStream.Close() session.Close() @@ -335,11 +338,10 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) { if err != nil { ln.Error(err, ln.F{ "action": "opening_session_stream", - "backend": c.conn.RemoteAddr().String(), "remote_addr": req.RemoteAddr, "host": req.Host, "uri": req.RequestURI, - }) + }, c) c.cancel() @@ -351,11 +353,10 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) { if err != nil { ln.Error(err, ln.F{ "action": "request_writing", - "backend": c.conn.RemoteAddr().String(), "remote_addr": req.RemoteAddr, "host": req.Host, "uri": req.RequestURI, - }) + }, c) c.cancel() @@ -368,11 +369,10 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) { if err != nil { ln.Error(err, ln.F{ "action": "response_reading", - "backend": c.conn.RemoteAddr().String(), "remote_addr": req.RemoteAddr, "host": req.Host, "uri": req.RequestURI, - }) + }, c) c.cancel()