diff --git a/neutrino.go b/neutrino.go index 7ee45edd..387db8b1 100644 --- a/neutrino.go +++ b/neutrino.go @@ -1081,6 +1081,24 @@ func (s *ChainService) BanPeer(addr string, reason banman.Reason) error { return s.banStore.BanIPNet(ipNet, reason, BanDuration) } +// UnbanPeer connects and unbans a previously banned peer. +func (s *ChainService) UnbanPeer(addr string, parmanent bool) error { + log.Infof("UnBanning peer %v", addr) + + ipNet, err := banman.ParseIPNet(addr, nil) + if err != nil { + return fmt.Errorf("unable to parse IP network for peer %v: %v", + addr, err) + } + + err = s.banStore.UnbanIPNet(ipNet) + if err != nil { + return fmt.Errorf("unable to unban peer: %v", err) + } + + return s.ConnectNode(addr, parmanent) +} + // IsBanned returns true if the peer is banned, and false otherwise. func (s *ChainService) IsBanned(addr string) bool { ipNet, err := banman.ParseIPNet(addr, nil)