Documentation ¶
Index ¶
- Constants
- Variables
- func CanListen(addr ma.Multiaddr) bool
- func IsGMPrivateKey(sk crypto.PrivateKey) bool
- func NewNetwork(ctx context.Context, logger api.Logger, opt ...Option) (network.Network, error)
- func NewQConn(nw *qNetwork, sess quic.Session, direction network.Direction, ...) (*qConn, error)
- func NewQReceiveStream(qc *qConn, qs quic.ReceiveStream) network.ReceiveStream
- func NewQSendStream(qc *qConn, qs quic.SendStream) network.SendStream
- func NewQStream(qc *qConn, qs quic.Stream, direction network.Direction) network.Stream
- func ParseCMTLSCertsToGoTLSCerts(cmCerts []cmTls.Certificate) ([]tls.Certificate, error)
- func ParseCMX509CertsToGoX509Certs(cmCerts []*cmx509.Certificate) ([]*x509.Certificate, error)
- func ParseQX509CertsToCMX509Certs(qCerts []*qx509.Certificate) ([]*cmx509.Certificate, error)
- type ConnectionState
- type Option
Constants ¶
View Source
const ( // ErrCodeCloseConn is a quic.ApplicationErrorCode means the connection closed. ErrCodeCloseConn quic.ApplicationErrorCode = 0 // ErrCodeCloseStream is a quic.StreamErrorCode means the stream closed. ErrCodeCloseStream quic.StreamErrorCode = 0 // ErrMsgCloseConn is a message for connection closing. ErrMsgCloseConn = "closed" )
View Source
const (
// QuicNetworkVersion is the current version of quic network .
QuicNetworkVersion = "v0.0.1"
)
Variables ¶
View Source
var ( // ErrNilTlsCfg will be returned if tls config is nil when network starting. ErrNilTlsCfg = errors.New("nil tls config") // ErrEmptyTlsCerts will be returned if no tls cert given when network starting with tls enabled. ErrEmptyTlsCerts = errors.New("empty tls certs") // ErrNilAddr will be returned if the listening address is empty. ErrNilAddr = errors.New("nil addr") // ErrListenerRequired will be returned if no listening address given. ErrListenerRequired = errors.New("at least one listener is required") // ErrConnRejectedByConnHandler will be returned if connection handler reject a connection when establishing. ErrConnRejectedByConnHandler = errors.New("connection rejected by conn handler") // ErrNotTheSameNetwork will be returned if the connection disconnected is not created by current network. ErrNotTheSameNetwork = errors.New("not the same network") // ErrPidMismatch will be returned if the remote peer id is not the expected one. ErrPidMismatch = errors.New("pid mismatch") // ErrNilLoadPidFunc will be returned if loadPidFunc is nil. ErrNilLoadPidFunc = errors.New("load peer id function required") // ErrWrongQuicAddr will be returned if the address is wrong when calling Dial method. ErrWrongQuicAddr = errors.New("wrong quic address format") // ErrEmptyLocalPeerId will be returned if load local peer id failed. ErrEmptyLocalPeerId = errors.New("empty local peer id") // ErrNoUsableLocalAddress will be returned if no usable local address found // when the local listening address is an unspecified address. ErrNoUsableLocalAddress = errors.New("no usable local address found") )
Functions ¶
func IsGMPrivateKey ¶
func IsGMPrivateKey(sk crypto.PrivateKey) bool
IsGMPrivateKey return true if it is a sm2.PrivateKey.
func NewNetwork ¶
NewNetwork create a new network instance with QUIC transport.
func NewQConn ¶
func NewQConn(nw *qNetwork, sess quic.Session, direction network.Direction, loadPidFunc types.LoadPeerIdFromCMTlsCertFunc) (*qConn, error)
NewQConn create a new qConn.
func NewQReceiveStream ¶
func NewQReceiveStream(qc *qConn, qs quic.ReceiveStream) network.ReceiveStream
func NewQSendStream ¶
func NewQSendStream(qc *qConn, qs quic.SendStream) network.SendStream
func NewQStream ¶
func ParseCMTLSCertsToGoTLSCerts ¶
func ParseCMTLSCertsToGoTLSCerts(cmCerts []cmTls.Certificate) ([]tls.Certificate, error)
func ParseCMX509CertsToGoX509Certs ¶
func ParseCMX509CertsToGoX509Certs(cmCerts []*cmx509.Certificate) ([]*x509.Certificate, error)
func ParseQX509CertsToCMX509Certs ¶
func ParseQX509CertsToCMX509Certs(qCerts []*qx509.Certificate) ([]*cmx509.Certificate, error)
Types ¶
type ConnectionState ¶
type ConnectionState struct { TLS connectionState SupportsDatagrams bool }
ConnectionState records basic details about a QUIC connection
type Option ¶
type Option func(n *qNetwork) error
Option is a function to set option value for quic network.
func WithLoadPidFunc ¶
func WithLoadPidFunc(f types.LoadPeerIdFromCMTlsCertFunc) Option
WithLoadPidFunc set a types.LoadPeerIdFromTlsCertFunc for loading peer.ID from x509 certs when tls handshaking.
func WithLocalPeerId ¶
WithLocalPeerId will set the local peer.ID for the network. If LoadPidFunc option set, the local peer.ID set by this method will be overwritten, probably.
func WithTlsCfg ¶
WithTlsCfg set a tls.Config option value.
Click to show internal directories.
Click to hide internal directories.