mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	add the relevant error to the default logging when a connection is closed
This commit is contained in:
		
							parent
							
								
									042adb0516
								
							
						
					
					
						commit
						bb3edd5e55
					
				
					 1 changed files with 7 additions and 5 deletions
				
			
		| 
						 | 
					@ -162,8 +162,6 @@ func (intf *linkInterface) handler() error {
 | 
				
			||||||
	themString := fmt.Sprintf("%s@%s", themAddrString, intf.info.remote)
 | 
						themString := fmt.Sprintf("%s@%s", themAddrString, intf.info.remote)
 | 
				
			||||||
	intf.link.core.log.Infof("Connected %s: %s, source %s",
 | 
						intf.link.core.log.Infof("Connected %s: %s, source %s",
 | 
				
			||||||
		strings.ToUpper(intf.info.linkType), themString, intf.info.local)
 | 
							strings.ToUpper(intf.info.linkType), themString, intf.info.local)
 | 
				
			||||||
	defer intf.link.core.log.Infof("Disconnected %s: %s, source %s",
 | 
					 | 
				
			||||||
		strings.ToUpper(intf.info.linkType), themString, intf.info.local)
 | 
					 | 
				
			||||||
	// Start the link loop
 | 
						// Start the link loop
 | 
				
			||||||
	go intf.peer.linkLoop()
 | 
						go intf.peer.linkLoop()
 | 
				
			||||||
	// Start the writer
 | 
						// Start the writer
 | 
				
			||||||
| 
						 | 
					@ -304,12 +302,13 @@ func (intf *linkInterface) handler() error {
 | 
				
			||||||
	}()
 | 
						}()
 | 
				
			||||||
	// Run reader loop
 | 
						// Run reader loop
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
		msg, err := intf.msgIO.readMsg()
 | 
							var msg []byte
 | 
				
			||||||
 | 
							msg, err = intf.msgIO.readMsg()
 | 
				
			||||||
		if len(msg) > 0 {
 | 
							if len(msg) > 0 {
 | 
				
			||||||
			intf.peer.handlePacket(msg)
 | 
								intf.peer.handlePacket(msg)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								break
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		select {
 | 
							select {
 | 
				
			||||||
		case signalAlive <- len(msg) > 0:
 | 
							case signalAlive <- len(msg) > 0:
 | 
				
			||||||
| 
						 | 
					@ -317,5 +316,8 @@ func (intf *linkInterface) handler() error {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	////////////////////////////////////////////////////////////////////////////////
 | 
						////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
	return nil
 | 
						// Remember to set `err` to something useful before returning
 | 
				
			||||||
 | 
						intf.link.core.log.Infof("Disconnected %s: %s, source %s, reason: %s",
 | 
				
			||||||
 | 
							strings.ToUpper(intf.info.linkType), themString, intf.info.local, err)
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue