mirror of
				https://gogs.blitter.com/RLabs/xs
				synced 2024-08-14 10:26:42 +00:00 
			
		
		
		
	Server-side client hangup working; TODO - client-side handling of post-exit EOF (broken pipe)
This commit is contained in:
		
							parent
							
								
									65b7af8063
								
							
						
					
					
						commit
						cb0ce956b9
					
				
					 1 changed files with 21 additions and 9 deletions
				
			
		
							
								
								
									
										30
									
								
								hkexnet.go
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								hkexnet.go
									
										
									
									
									
								
							|  | @ -300,6 +300,7 @@ func (hl HKExListener) Accept() (hc Conn, err error) { | |||
| func (c Conn) Read(b []byte) (n int, err error) { | ||||
| 	//log.Printf("[Decrypting...]\r\n") | ||||
| 	log.Printf("Read() requests %d bytes\n", len(b)) | ||||
| 
 | ||||
| 	for { | ||||
| 		//log.Printf("c.dBuf.Len(): %d\n", c.dBuf.Len()) | ||||
| 		if c.dBuf.Len() > 0 /* len(b) */ { | ||||
|  | @ -311,21 +312,32 @@ func (c Conn) Read(b []byte) (n int, err error) { | |||
| 
 | ||||
| 		// Read the hmac LSB and payload len first | ||||
| 		err = binary.Read(c.c, binary.BigEndian, &hmacIn) | ||||
| 		if err != nil { | ||||
| 			if err.Error() != "EOF" { | ||||
| 				log.Println("Error was:", err.Error()) | ||||
| 		// Normal client 'exit' from interactive session will cause | ||||
| 		// (on server side) err.Error() == "<iface/addr info ...>: use of closed network connection" | ||||
| 		if err != nil && err.Error() != "EOF" { | ||||
| 			if !strings.HasSuffix(err.Error(), "use of closed network connection") { | ||||
| 				log.Println("unexpected Read() err:", err) | ||||
| 			} else { | ||||
| 				return 0, err | ||||
| 				log.Println("[Client hung up]") | ||||
| 				return 0, io.EOF | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		//if err != nil { | ||||
| 		//	if err.Error() != "EOF" { | ||||
| 		//		log.Println("Error was:", err.Error()) | ||||
| 		//	} else { | ||||
| 		//		return 0, err | ||||
| 		//	} | ||||
| 		//} | ||||
| 
 | ||||
| 		err = binary.Read(c.c, binary.BigEndian, &payloadLen) | ||||
| 		if err != nil { | ||||
| 			//			if err.Error() != "EOF" { | ||||
| 			panic(err) | ||||
| 			//			} else { | ||||
| 			//				return 0, err | ||||
| 			//			} | ||||
| 			if err.Error() != "EOF" { | ||||
| 				panic(err) | ||||
| 			} // else { | ||||
| 			//	return 0, err | ||||
| 			//} | ||||
| 		} | ||||
| 		if payloadLen > 16384 { | ||||
| 			panic("Insane payloadLen") | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue