func (s *Conngater) InterceptPeerDial(p peer.ID) (allow bool) {
	if !s.checkWhitePeerList(p) {
		return false
	}
	if s.blacklist.Has(p.Pretty()) {
		return false
	}
	return !s.isPeerAtLimit(network.DirOutbound)
}
InterceptPeerDial tests whether we're permitted to Dial the specified peer.
package manage
import (
	"container/list"
	"context"
	"runtime"
	"sort"
	"sync"
	"time"
	"github.com/33cn/chain33/types"
	"github.com/kevinms/leakybucket-go"
	"github.com/libp2p/go-libp2p-core/control"
	"github.com/libp2p/go-libp2p-core/host"
	"github.com/libp2p/go-libp2p-core/network"
	"github.com/libp2p/go-libp2p-core/peer"
	"github.com/multiformats/go-multiaddr"
	net "github.com/multiformats/go-multiaddr/net"
)
const (
	ipLimit = 4
	ipBurst = 8
)
var CacheLimit int32 = 20
type Conngater struct {
	host          *host.Host
	maxConnectNum int32
	ipLimiter     *leakybucket.Collector
	blacklist     *TimeCache
	whitPeerList  map[peer.ID]multiaddr.Multiaddr
}
func NewConnGater(h *host.Host, limit int32, cache *TimeCache, whitPeers []*peer.AddrInfo) *Conngater {
	gater := &Conngater{}
	gater.host = h
	if limit == 0 {
		limit = 4096
	}
	gater.maxConnectNum = limit
	gater.blacklist = cache
	if gater.blacklist == nil {
		gater.blacklist = NewTimeCache(context.Background(), time.Minute*5)
	}
	gater.ipLimiter = leakybucket.NewCollector(ipLimit, ipBurst, true)
	for _, pr := range whitPeers {
		if gater.whitPeerList == nil {
			gater.whitPeerList = make(map[peer.ID]multiaddr.Multiaddr)
		}
		gater.whitPeerList[pr.ID] = pr.Addrs[0]
	}
	return gater
}