github.com/annwntech/go-micro/v2@v2.9.5/tunnel/transport/listener.go (about) 1 package transport 2 3 import ( 4 "github.com/annwntech/go-micro/v2/transport" 5 "github.com/annwntech/go-micro/v2/tunnel" 6 ) 7 8 type tunListener struct { 9 l tunnel.Listener 10 } 11 12 func (t *tunListener) Addr() string { 13 return t.l.Channel() 14 } 15 16 func (t *tunListener) Close() error { 17 return t.l.Close() 18 } 19 20 func (t *tunListener) Accept(fn func(socket transport.Socket)) error { 21 for { 22 // accept connection 23 c, err := t.l.Accept() 24 if err != nil { 25 return err 26 } 27 // execute the function 28 go fn(c) 29 } 30 }