Browse Source

key: interface{} -> string

pull/15/head
Jason 5 years ago
parent
commit
2b3d1e2575
  1. 2
      common/stats/session/session.go
  2. 7
      proxy/socks/tcp.go
  3. 11
      proxy/socks/udp.go

2
common/stats/session/session.go

@ -131,6 +131,6 @@ func (s *simpleSessionStater) RemoveSession(key interface{}) {
s.sessions.Delete(key)
} else {
log.Warnf("session key [%v] not found", key)
log.Warnf("cannot found session key: [%v] ", key)
}
}

7
proxy/socks/tcp.go

@ -1,6 +1,7 @@
package socks
import (
"fmt"
"io"
"net"
"strconv"
@ -109,7 +110,8 @@ func (h *tcpHandler) relay(localConn, remoteConn net.Conn, sess *stats.Session)
<-upCh // Wait for uplink done.
if h.sessionStater != nil {
h.sessionStater.RemoveSession(localConn)
key := fmt.Sprintf("%s:%s", localConn.LocalAddr().Network(), localConn.LocalAddr().String())
h.sessionStater.RemoveSession(key)
}
}
@ -154,7 +156,8 @@ func (h *tcpHandler) Handle(localConn net.Conn, target *net.TCPAddr) error {
DownloadBytes: 0,
SessionStart: time.Now(),
}
h.sessionStater.AddSession(localConn, sess)
key := fmt.Sprintf("%s:%s", localConn.LocalAddr().Network(), localConn.LocalAddr().String())
h.sessionStater.AddSession(key, sess)
}
// set keepalive

11
proxy/socks/udp.go

@ -187,17 +187,19 @@ func (h *udpHandler) connectInternal(conn core.UDPConn, targetAddr string) error
process = "N/A"
}
localConn := conn
sess := &stats.Session{
ProcessName: process,
Network: conn.LocalAddr().Network(),
Network: localConn.LocalAddr().Network(),
DialerAddr: remoteConn.LocalAddr().String(),
ClientAddr: conn.LocalAddr().String(),
ClientAddr: localConn.LocalAddr().String(),
TargetAddr: targetAddr,
UploadBytes: 0,
DownloadBytes: 0,
SessionStart: time.Now(),
}
h.sessionStater.AddSession(conn, sess)
key := fmt.Sprintf("%s:%s", localConn.LocalAddr().Network(), localConn.LocalAddr().String())
h.sessionStater.AddSession(key, sess)
}
log.Access(process, "proxy", "udp", conn.LocalAddr().String(), targetAddr)
}
@ -256,6 +258,7 @@ func (h *udpHandler) Close(conn core.UDPConn) {
delete(h.remoteAddrs, conn)
if h.sessionStater != nil {
h.sessionStater.RemoveSession(conn)
key := fmt.Sprintf("%s:%s", conn.LocalAddr().Network(), conn.LocalAddr().String())
h.sessionStater.RemoveSession(key)
}
}

Loading…
Cancel
Save