mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	fix crash when starting in tun mode
This commit is contained in:
		
							parent
							
								
									b3887e554c
								
							
						
					
					
						commit
						1b1b776097
					
				
					 1 changed files with 16 additions and 14 deletions
				
			
		| 
						 | 
					@ -51,21 +51,23 @@ func (tun *tunDevice) start(ifname string, iftapmode bool, addr string, mtu int)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	go func() { panic(tun.read()) }()
 | 
						go func() { panic(tun.read()) }()
 | 
				
			||||||
	go func() { panic(tun.write()) }()
 | 
						go func() { panic(tun.write()) }()
 | 
				
			||||||
	go func() {
 | 
						if iftapmode {
 | 
				
			||||||
		for {
 | 
							go func() {
 | 
				
			||||||
			if _, ok := tun.icmpv6.peermacs[tun.core.router.addr]; ok {
 | 
								for {
 | 
				
			||||||
				break
 | 
									if _, ok := tun.icmpv6.peermacs[tun.core.router.addr]; ok {
 | 
				
			||||||
 | 
										break
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									request, err := tun.icmpv6.create_ndp_tap(tun.core.router.addr)
 | 
				
			||||||
 | 
									if err != nil {
 | 
				
			||||||
 | 
										panic(err)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if _, err := tun.iface.Write(request); err != nil {
 | 
				
			||||||
 | 
										panic(err)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									time.Sleep(time.Second)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			request, err := tun.icmpv6.create_ndp_tap(tun.core.router.addr)
 | 
							}()
 | 
				
			||||||
			if err != nil {
 | 
						}
 | 
				
			||||||
				panic(err)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if _, err := tun.iface.Write(request); err != nil {
 | 
					 | 
				
			||||||
				panic(err)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			time.Sleep(time.Second)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}()
 | 
					 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue