mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-10-20 06:04:43 +08:00
feat: optimize code (#149)
Co-authored-by: wencaiwulue <895703375@qq.com>
This commit is contained in:
@@ -142,8 +142,8 @@ func (h *tunHandler) Handle(ctx context.Context, tun net.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h tunHandler) printRoute() {
|
||||
for {
|
||||
func (h *tunHandler) printRoute(ctx context.Context) {
|
||||
for ctx.Err() == nil {
|
||||
select {
|
||||
case <-time.Tick(time.Second * 5):
|
||||
var i int
|
||||
@@ -370,7 +370,7 @@ func (d *Device) SetTunInboundHandler(handler func(tunInbound <-chan *DataElem,
|
||||
}
|
||||
|
||||
func (h *tunHandler) HandleServer(ctx context.Context, tun net.Conn) {
|
||||
go h.printRoute()
|
||||
go h.printRoute(ctx)
|
||||
|
||||
device := &Device{
|
||||
tun: tun,
|
||||
|
Reference in New Issue
Block a user