mirror of https://gogs.blitter.com/RLabs/xs
				
				
				
			Fixed tun reuse hang/error after closure
Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
		
							parent
							
								
									c4c2e24af1
								
							
						
					
					
						commit
						c327b2ec72
					
				|  | @ -157,6 +157,7 @@ func (hc *Conn) StartClientTunnel(lport, rport uint16) { | ||||||
| 												close((*hc.tuns)[rport].Data) | 												close((*hc.tuns)[rport].Data) | ||||||
| 												(*hc.tuns)[rport].Data = nil | 												(*hc.tuns)[rport].Data = nil | ||||||
| 											} | 											} | ||||||
|  | 											delete((*hc.tuns), rport) | ||||||
| 											break | 											break | ||||||
| 										} else if strings.Contains(e.Error(), "i/o timeout") { | 										} else if strings.Contains(e.Error(), "i/o timeout") { | ||||||
| 											if (*hc.tuns)[rport].Died { | 											if (*hc.tuns)[rport].Died { | ||||||
|  | @ -165,6 +166,7 @@ func (hc *Conn) StartClientTunnel(lport, rport uint16) { | ||||||
| 													close((*hc.tuns)[rport].Data) | 													close((*hc.tuns)[rport].Data) | ||||||
| 													(*hc.tuns)[rport].Data = nil | 													(*hc.tuns)[rport].Data = nil | ||||||
| 												} | 												} | ||||||
|  | 												delete((*hc.tuns), rport) | ||||||
| 												break | 												break | ||||||
| 											} | 											} | ||||||
| 										} else { | 										} else { | ||||||
|  | @ -177,6 +179,7 @@ func (hc *Conn) StartClientTunnel(lport, rport uint16) { | ||||||
| 												close((*hc.tuns)[rport].Data) | 												close((*hc.tuns)[rport].Data) | ||||||
| 												(*hc.tuns)[rport].Data = nil | 												(*hc.tuns)[rport].Data = nil | ||||||
| 											} | 											} | ||||||
|  | 											delete((*hc.tuns), rport) | ||||||
| 											break | 											break | ||||||
| 										} | 										} | ||||||
| 									} | 									} | ||||||
|  | @ -253,6 +256,10 @@ func (hc *Conn) StartServerTunnel(lport, rport uint16) { | ||||||
| 			defer wg.Done() | 			defer wg.Done() | ||||||
| 			for { | 			for { | ||||||
| 				time.Sleep(100 * time.Millisecond) | 				time.Sleep(100 * time.Millisecond) | ||||||
|  | 				if (*hc.tuns)[rport] == nil { | ||||||
|  | 					logger.LogDebug("[ServerTun] worker A: Client endpoint removed.") | ||||||
|  | 					break | ||||||
|  | 				} | ||||||
| 				(*hc.tuns)[rport].KeepAlive += 1 | 				(*hc.tuns)[rport].KeepAlive += 1 | ||||||
| 				if (*hc.tuns)[rport].KeepAlive > 25 { | 				if (*hc.tuns)[rport].KeepAlive > 25 { | ||||||
| 					(*hc.tuns)[rport].Died = true | 					(*hc.tuns)[rport].Died = true | ||||||
|  | @ -320,6 +327,7 @@ func (hc *Conn) StartServerTunnel(lport, rport uint16) { | ||||||
| 										close((*hc.tuns)[rport].Data) | 										close((*hc.tuns)[rport].Data) | ||||||
| 										(*hc.tuns)[rport].Data = nil | 										(*hc.tuns)[rport].Data = nil | ||||||
| 									} | 									} | ||||||
|  | 									delete((*hc.tuns), rport) | ||||||
| 									break | 									break | ||||||
| 								} else if strings.Contains(e.Error(), "i/o timeout") { | 								} else if strings.Contains(e.Error(), "i/o timeout") { | ||||||
| 									if (*hc.tuns)[rport].Died { | 									if (*hc.tuns)[rport].Died { | ||||||
|  | @ -328,6 +336,7 @@ func (hc *Conn) StartServerTunnel(lport, rport uint16) { | ||||||
| 											close((*hc.tuns)[rport].Data) | 											close((*hc.tuns)[rport].Data) | ||||||
| 											(*hc.tuns)[rport].Data = nil | 											(*hc.tuns)[rport].Data = nil | ||||||
| 										} | 										} | ||||||
|  | 										delete((*hc.tuns), rport) | ||||||
| 										break | 										break | ||||||
| 									} | 									} | ||||||
| 								} else { | 								} else { | ||||||
|  | @ -340,6 +349,7 @@ func (hc *Conn) StartServerTunnel(lport, rport uint16) { | ||||||
| 										close((*hc.tuns)[rport].Data) | 										close((*hc.tuns)[rport].Data) | ||||||
| 										(*hc.tuns)[rport].Data = nil | 										(*hc.tuns)[rport].Data = nil | ||||||
| 									} | 									} | ||||||
|  | 									delete((*hc.tuns), rport) | ||||||
| 									break | 									break | ||||||
| 								} | 								} | ||||||
| 							} | 							} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue