github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/net/netapi/errors.go (about)

     1  package netapi
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	"github.com/Asutorufa/yuhaiin/pkg/protos/statistic"
     8  )
     9  
    10  var ErrBlocked = errors.New("BLOCK")
    11  
    12  type errorBlockedImpl struct {
    13  	network statistic.Type
    14  	h       string
    15  }
    16  
    17  func NewBlockError(network statistic.Type, hostname string) error {
    18  	return &errorBlockedImpl{network, hostname}
    19  }
    20  func (e *errorBlockedImpl) Error() string {
    21  	return fmt.Sprintf("blocked address %v[%s]", e.network, e.h)
    22  }
    23  func (e *errorBlockedImpl) Is(err error) bool { return err == ErrBlocked }