Documentation ¶
Overview ¶
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func NewListener(port uint16, config *config.P2PNodeConfig) (net.Listener, error)
- type Conn
- type ConnCtrlOption
- func (self ConnCtrlOption) MaxInBound(n uint) ConnCtrlOption
- func (self ConnCtrlOption) MaxInBoundPerIp(n uint) ConnCtrlOption
- func (self ConnCtrlOption) MaxOutBound(n uint) ConnCtrlOption
- func (self ConnCtrlOption) ReservedOnly(peers []string) ConnCtrlOption
- func (self ConnCtrlOption) WithDialer(dialer Dialer) ConnCtrlOption
- type ConnectController
- func (self *ConnectController) AcceptConnect(conn net.Conn) (*peer.PeerInfo, net.Conn, error)
- func (self *ConnectController) Connect(addr string) (*peer.PeerInfo, net.Conn, error)
- func (self *ConnectController) InboundsCount() uint
- func (self *ConnectController) OutboundsCount() uint
- func (self *ConnectController) OwnAddress() string
- func (self *ConnectController) SetOwnAddress(listenAddr string)
- type Dialer
- type StaticReserveFilter
Constants ¶
const INBOUND_INDEX = 0
const OUTBOUND_INDEX = 1
Variables ¶
var ErrHandshakeSelf = errors.New("the node handshake with itself")
Functions ¶
func NewListener ¶
Types ¶
type ConnCtrlOption ¶
type ConnCtrlOption struct { MaxConnOutBound uint MaxConnInBound uint MaxConnInBoundPerIP uint ReservedPeers p2p.AddressFilter // enabled if not empty // contains filtered or unexported fields }
func ConnCtrlOptionFromConfig ¶
func ConnCtrlOptionFromConfig(config *config.P2PNodeConfig, reserveFilter p2p.AddressFilter) (option ConnCtrlOption, err error)
func NewConnCtrlOption ¶
func NewConnCtrlOption() ConnCtrlOption
func (ConnCtrlOption) MaxInBound ¶
func (self ConnCtrlOption) MaxInBound(n uint) ConnCtrlOption
func (ConnCtrlOption) MaxInBoundPerIp ¶
func (self ConnCtrlOption) MaxInBoundPerIp(n uint) ConnCtrlOption
func (ConnCtrlOption) MaxOutBound ¶
func (self ConnCtrlOption) MaxOutBound(n uint) ConnCtrlOption
func (ConnCtrlOption) ReservedOnly ¶
func (self ConnCtrlOption) ReservedOnly(peers []string) ConnCtrlOption
func (ConnCtrlOption) WithDialer ¶
func (self ConnCtrlOption) WithDialer(dialer Dialer) ConnCtrlOption
type ConnectController ¶
type ConnectController struct { ConnCtrlOption // contains filtered or unexported fields }
func NewConnectController ¶
func NewConnectController(peerInfo *peer.PeerInfo, keyid *common.PeerKeyId, option ConnCtrlOption, logger common.Logger) *ConnectController
func (*ConnectController) AcceptConnect ¶
func (*ConnectController) Connect ¶
Connect used to connect net address under sync or cons mode need call Peer.Close to clean up resource.
func (*ConnectController) InboundsCount ¶
func (self *ConnectController) InboundsCount() uint
func (*ConnectController) OutboundsCount ¶
func (self *ConnectController) OutboundsCount() uint
func (*ConnectController) OwnAddress ¶
func (self *ConnectController) OwnAddress() string
func (*ConnectController) SetOwnAddress ¶
func (self *ConnectController) SetOwnAddress(listenAddr string)
type StaticReserveFilter ¶
type StaticReserveFilter struct { //format: host or ip ReservedPeers []string }
func NewStaticReserveFilter ¶
func NewStaticReserveFilter(peers []string) *StaticReserveFilter
func (*StaticReserveFilter) Contains ¶
func (self *StaticReserveFilter) Contains(remoteIPPort string) bool
remoteAddr format 192.168.1.1:61234 if reserved peers is empty, we should handle this case in subnet now since for gov node, reserve_result = in_subnet_set || in_static_set for normal node, reserve_result = in_static_set || static_set_is_empty because the information of whether self node is gov or not is in subnet module