tun2: Connection is an Fer now
This commit is contained in:
parent
919e160273
commit
3d516cdf4e
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue