2026-03-11 16:28:15 +01:00
|
|
|
package node
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/libp2p/go-libp2p/core/control"
|
|
|
|
|
"github.com/libp2p/go-libp2p/core/host"
|
|
|
|
|
"github.com/libp2p/go-libp2p/core/network"
|
|
|
|
|
pp "github.com/libp2p/go-libp2p/core/peer"
|
|
|
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-17 11:57:22 +01:00
|
|
|
// OCConnectionGater allows all connections unconditionally.
|
|
|
|
|
// Peer validation (local DB + DHT by peer_id) is enforced at the stream level
|
|
|
|
|
// in each handler, so ProtocolHeartbeat and ProtocolPublish — through which a
|
|
|
|
|
// node first registers itself — are never blocked.
|
2026-03-11 16:28:15 +01:00
|
|
|
type OCConnectionGater struct {
|
|
|
|
|
host host.Host
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newOCConnectionGater(h host.Host) *OCConnectionGater {
|
|
|
|
|
return &OCConnectionGater{host: h}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-17 11:57:22 +01:00
|
|
|
func (g *OCConnectionGater) InterceptPeerDial(_ pp.ID) bool { return true }
|
|
|
|
|
func (g *OCConnectionGater) InterceptAddrDial(_ pp.ID, _ ma.Multiaddr) bool { return true }
|
|
|
|
|
func (g *OCConnectionGater) InterceptAccept(_ network.ConnMultiaddrs) bool { return true }
|
|
|
|
|
func (g *OCConnectionGater) InterceptSecured(_ network.Direction, _ pp.ID, _ network.ConnMultiaddrs) bool {
|
2026-03-11 16:28:15 +01:00
|
|
|
return true
|
|
|
|
|
}
|
2026-03-17 11:57:22 +01:00
|
|
|
func (g *OCConnectionGater) InterceptUpgraded(_ network.Conn) (bool, control.DisconnectReason) {
|
|
|
|
|
return true, 0
|
2026-03-11 16:28:15 +01:00
|
|
|
}
|