connect_controller

package
v1.10.1-sdk Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2020 License: LGPL-3.0 Imports: 17 Imported by: 0

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/>.

Index

Constants

View Source
const INBOUND_INDEX = 0
View Source
const OUTBOUND_INDEX = 1

Variables

This section is empty.

Functions

func NewListener

func NewListener(port uint16, config *config.P2PNodeConfig) (net.Listener, error)

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is a net.Conn wrapper to do some clean up when Close.

func (*Conn) Close

func (self *Conn) Close() error

Close overwrite net.Conn warning: this method will try to lock the controller, be carefull to avoid deadlock

type ConnCtrlOption

type ConnCtrlOption struct {
	MaxConnOutBound     uint
	MaxConnInBound      uint
	MaxConnInBoundPerIP uint
	ReservedPeers       []string // enabled if not empty
	// contains filtered or unexported fields
}

func ConnCtrlOptionFromConfig

func ConnCtrlOptionFromConfig(config *config.P2PNodeConfig) (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) *ConnectController

func (*ConnectController) AcceptConnect

func (self *ConnectController) AcceptConnect(conn net.Conn) (*peer.PeerInfo, net.Conn, error)

func (*ConnectController) Connect

func (self *ConnectController) Connect(addr string) (*peer.PeerInfo, net.Conn, error)

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

type Dialer

type Dialer interface {
	Dial(nodeAddr string) (net.Conn, error)
}

func NewDialer

func NewDialer(config *config.P2PNodeConfig) (Dialer, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL