github.com/geph-official/geph2@v0.22.6-0.20210211030601-f527cb59b0df/cmd/geph-exit/connmanager.go (about) 1 package main 2 3 import ( 4 "net" 5 "time" 6 7 lru "github.com/hashicorp/golang-lru" 8 log "github.com/sirupsen/logrus" 9 "golang.org/x/time/rate" 10 ) 11 12 var reportRL = rate.NewLimiter(20, 10) 13 14 var connlru, _ = lru.NewWithEvict(5000, func(k, v interface{}) { 15 if statClient != nil && reportRL.Allow() { 16 statClient.Timing(hostname+".lruLifetime", time.Since(v.(time.Time)).Milliseconds()) 17 } 18 log.Println("lasted", time.Since(v.(time.Time))) 19 k.(net.Conn).Close() 20 }) 21 22 func regConn(conn net.Conn) { 23 //connlru.Add(conn, time.Now()) 24 }