Define tunnel errors
This commit is contained in:
		| @@ -384,7 +384,7 @@ func (t *tun) process() { | |||||||
| 				// if the link is not connected skip it | 				// if the link is not connected skip it | ||||||
| 				if !connected { | 				if !connected { | ||||||
| 					log.Debugf("Link for node %s not connected", id) | 					log.Debugf("Link for node %s not connected", id) | ||||||
| 					err = errors.New("link not connected") | 					err = ErrLinkDisconnected | ||||||
| 					continue | 					continue | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| @@ -392,14 +392,14 @@ func (t *tun) process() { | |||||||
| 				// and the message is being sent outbound via | 				// and the message is being sent outbound via | ||||||
| 				// a dialled connection don't use this link | 				// a dialled connection don't use this link | ||||||
| 				if loopback && msg.outbound { | 				if loopback && msg.outbound { | ||||||
| 					err = errors.New("link is loopback") | 					err = ErrLinkLoopback | ||||||
| 					continue | 					continue | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				// if the message was being returned by the loopback listener | 				// if the message was being returned by the loopback listener | ||||||
| 				// send it back up the loopback link only | 				// send it back up the loopback link only | ||||||
| 				if msg.loopback && !loopback { | 				if msg.loopback && !loopback { | ||||||
| 					err = errors.New("link is not loopback") | 					err = ErrLinkRemote | ||||||
| 					continue | 					continue | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| @@ -414,7 +414,7 @@ func (t *tun) process() { | |||||||
| 					// this is where we explicitly set the link | 					// this is where we explicitly set the link | ||||||
| 					// in a message received via the listen method | 					// in a message received via the listen method | ||||||
| 					if len(msg.link) > 0 && id != msg.link { | 					if len(msg.link) > 0 && id != msg.link { | ||||||
| 						err = errors.New("link not found") | 						err = ErrLinkNotFound | ||||||
| 						continue | 						continue | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
|   | |||||||
| @@ -26,6 +26,12 @@ var ( | |||||||
| 	ErrDiscoverChan = errors.New("failed to discover channel") | 	ErrDiscoverChan = errors.New("failed to discover channel") | ||||||
| 	// ErrLinkNotFound is returned when a link is specified at dial time and does not exist | 	// ErrLinkNotFound is returned when a link is specified at dial time and does not exist | ||||||
| 	ErrLinkNotFound = errors.New("link not found") | 	ErrLinkNotFound = errors.New("link not found") | ||||||
|  | 	// ErrLinkDisconnected is returned when a link we attempt to send to is disconnected | ||||||
|  | 	ErrLinkDisconnected = errors.New("link not connected") | ||||||
|  | 	// ErrLinkLoppback is returned when attempting to send an outbound message over loopback link | ||||||
|  | 	ErrLinkLoopback = errors.New("link is loopback") | ||||||
|  | 	// ErrLinkRemote is returned when attempting to send a loopback message over remote link | ||||||
|  | 	ErrLinkRemote = errors.New("link is remote") | ||||||
| 	// ErrReadTimeout is a timeout on session.Recv | 	// ErrReadTimeout is a timeout on session.Recv | ||||||
| 	ErrReadTimeout = errors.New("read timeout") | 	ErrReadTimeout = errors.New("read timeout") | ||||||
| 	// ErrDecryptingData is for when theres a nonce error | 	// ErrDecryptingData is for when theres a nonce error | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user