2018-01-21 00:33:53 -05:00
|
|
|
package p2p
|
2018-01-20 21:12:04 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-04-28 16:45:08 -04:00
|
|
|
type ErrSwitchDuplicatePeerID struct {
|
|
|
|
ID ID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrSwitchDuplicatePeerID) Error() string {
|
|
|
|
return fmt.Errorf("Duplicate peer ID %v", e.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ErrSwitchDuplicatePeerIP struct {
|
|
|
|
Addr string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrSwitchDuplicatePeerIP) Error() string {
|
|
|
|
return fmt.Errorf("Duplicate peer IP %v", e.Addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ErrSwitchConnectToSelf struct {
|
|
|
|
Addr *NetAddress
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrSwitchConnectToSelf) Error() string {
|
|
|
|
return fmt.Errorf("Connect to self: %v", e.Addr)
|
|
|
|
}
|
2018-01-20 21:12:04 -05:00
|
|
|
|
|
|
|
type ErrSwitchAuthenticationFailure struct {
|
|
|
|
Dialed *NetAddress
|
|
|
|
Got ID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrSwitchAuthenticationFailure) Error() string {
|
|
|
|
return fmt.Sprintf("Failed to authenticate peer. Dialed %v, but got peer with ID %s", e.Dialed, e.Got)
|
|
|
|
}
|
2018-04-28 14:48:51 -04:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
type ErrNetAddressNoID struct {
|
|
|
|
Addr string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrNetAddressNoID) Error() string {
|
2018-04-28 15:39:09 -04:00
|
|
|
return fmt.Sprintf("Address (%s) does not contain ID", e.Addr)
|
2018-04-28 14:48:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type ErrNetAddressInvalid struct {
|
|
|
|
Addr string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrNetAddressInvalid) Error() string {
|
2018-04-28 15:39:09 -04:00
|
|
|
return fmt.Sprintf("Invalid address (%s): %v", e.Addr, e.Err)
|
2018-04-28 14:48:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type ErrNetAddressLookup struct {
|
|
|
|
Addr string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ErrNetAddressLookup) Error() string {
|
2018-04-28 15:39:09 -04:00
|
|
|
return fmt.Sprintf("Error looking up host (%s): %v", e.Addr, e.Err)
|
2018-04-28 14:48:51 -04:00
|
|
|
}
|