p2p: prevent connections from same ip

This commit is contained in:
Ethan Buchman
2018-04-28 16:45:08 -04:00
committed by Alexander Simmerl
parent 68a0b3f95b
commit 1fe41be929
4 changed files with 71 additions and 20 deletions

View File

@ -1,14 +1,32 @@
package p2p
import (
"errors"
"fmt"
)
var (
ErrSwitchDuplicatePeer = errors.New("Duplicate peer")
ErrSwitchConnectToSelf = errors.New("Connect to self")
)
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)
}
type ErrSwitchAuthenticationFailure struct {
Dialed *NetAddress