|
|
- package p2p
-
- import (
- "fmt"
- "net"
- )
-
- // ErrSwitchDuplicatePeerID to be raised when a peer is connecting with a known
- // ID.
- type ErrSwitchDuplicatePeerID struct {
- ID ID
- }
-
- func (e ErrSwitchDuplicatePeerID) Error() string {
- return fmt.Sprintf("Duplicate peer ID %v", e.ID)
- }
-
- // ErrSwitchDuplicatePeerIP to be raised whena a peer is connecting with a known
- // IP.
- type ErrSwitchDuplicatePeerIP struct {
- IP net.IP
- }
-
- func (e ErrSwitchDuplicatePeerIP) Error() string {
- return fmt.Sprintf("Duplicate peer IP %v", e.IP.String())
- }
-
- // ErrSwitchConnectToSelf to be raised when trying to connect to itself.
- type ErrSwitchConnectToSelf struct {
- Addr *NetAddress
- }
-
- func (e ErrSwitchConnectToSelf) Error() string {
- return fmt.Sprintf("Connect to self: %v", e.Addr)
- }
-
- 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,
- )
- }
-
- //-------------------------------------------------------------------
-
- type ErrNetAddressNoID struct {
- Addr string
- }
-
- func (e ErrNetAddressNoID) Error() string {
- return fmt.Sprintf("Address (%s) does not contain ID", e.Addr)
- }
-
- type ErrNetAddressInvalid struct {
- Addr string
- Err error
- }
-
- func (e ErrNetAddressInvalid) Error() string {
- return fmt.Sprintf("Invalid address (%s): %v", e.Addr, e.Err)
- }
-
- type ErrNetAddressLookup struct {
- Addr string
- Err error
- }
-
- func (e ErrNetAddressLookup) Error() string {
- return fmt.Sprintf("Error looking up host (%s): %v", e.Addr, e.Err)
- }
|