Documentation ¶
Index ¶
- Constants
- Variables
- func Handle(backend *Backend, peer *p2p.Peer, rw p2p.MsgReadWriter) error
- func MakeProtocols(backend *Backend) []p2p.Protocol
- func SendJson(w p2p.MsgWriter, msgcode uint64, data interface{}) error
- type Backend
- func (b *Backend) Decrypt(pubkey *ecdsa.PublicKey, ciphertext []byte) ([]byte, error)
- func (b *Backend) Encrypt(pubkey *ecdsa.PublicKey, plaintext []byte) ([]byte, error)
- func (b *Backend) PeersInfo() *[]peersInfo
- func (b *Backend) SelfID() enode.ID
- func (b *Backend) SendP2PMessage(nodeID [32]byte, message types.Message) error
- func (b *Backend) SessionID(nodeID [32]byte) [32]byte
- func (b *Backend) Start()
- func (b *Backend) Stop()
- func (b *Backend) Verify(pubkey *ecdsa.PublicKey, gatewaySelf, gatewayTarget string) ([]string, error)
- type BackendConfig
- type Peer
Constants ¶
View Source
const ( StatusMsg = 0x00 P2PMessageEventMsg = 0x01 ChannelMessageEventMsg = 0x02 )
uint64 MsgCode
View Source
const ProtocolName = "p2pchat"
View Source
const ProtocolVersion = 1
Variables ¶
View Source
var DefaultBackendConfig = BackendConfig{ MaxPeers: 50, Locally: true, NAT: nat.Any(), Address: "127.0.0.1:0", }
Functions ¶
func MakeProtocols ¶
MakeProtocols always returns latest protocol and drop support for old protocol version.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend defines events trigger
func NewBackend ¶
func NewBackend(config BackendConfig) *Backend
func (*Backend) SendP2PMessage ¶
type BackendConfig ¶
type BackendConfig struct { Key *ecdsa.PrivateKey MaxPeers int // default to 50 NAT nat.Interface // p2p.nat.Parse Address string // default to "127.0.0.1:0" Locally bool // restrict local request BootstrapNodes []*enode.Node // enode.MustParse // for test NetRestrict *netutil.Netlist // p2p.netutil.ParseNetlist }
Click to show internal directories.
Click to hide internal directories.