net

package
v0.0.0-...-2af547a Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: AGPL-3.0 Imports: 9 Imported by: 2

Documentation

Overview

Package net is a collection of network listeners for use with an HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadPlugin

func LoadPlugin()

LoadPlugin being called forces the package to be loaded in order to ensure that the resource types are registered during the package's Init.

Types

type AcmeConfig

type AcmeConfig struct {
	AcceptTOS bool
	Domains   []string
	// contains filtered or unexported fields
}

AcmeConfig represents the configuration details to be used with x/crypto/acme/autocert. It can also act as a wrapper around the autocert.Manager and net.Listener it generates.

func (*AcmeConfig) Accept

func (a *AcmeConfig) Accept() (net.Conn, error)

Accept implements net.Listener.

func (*AcmeConfig) Addr

func (a *AcmeConfig) Addr() net.Addr

Addr implements net.Listener.

func (*AcmeConfig) Close

func (a *AcmeConfig) Close() error

Close implements net.Listener.

func (*AcmeConfig) GetCertificate

func (a *AcmeConfig) GetCertificate(
	hello *tls.ClientHelloInfo,
) (*tls.Certificate, error)

GetCertificate implements TlsCertificateGetter so that this object can be used as part of another net.Listener in case behavior other than what is provided by AcmeConfig.Listener is desired.

func (*AcmeConfig) GetManager

func (a *AcmeConfig) GetManager() (*autocert.Manager, error)

GetManager retrieves an x/crypto/acme/autocert.Manager with the previously defined config values. Subsequent calls return the same autocert.Manager object which has been preserved.

func (*AcmeConfig) Listener

func (a *AcmeConfig) Listener() (net.Listener, error)

Listener retrieves a net.Listener from the autocert.Manager given by AcmeConfig.GetManager. Subsequent calls return the same net.Listener object which has been preserved.

func (*AcmeConfig) UnmarshalJSON

func (a *AcmeConfig) UnmarshalJSON(d []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type BasicListener

type BasicListener struct {
	Listener net.Listener
}

BasicListener augments the functionality of a net.Listen call by wrapping it in an encoding/json.Unmarshaler (and thereby making it be configurable).

func (*BasicListener) Accept

func (b *BasicListener) Accept() (net.Conn, error)

Accept implements net.Listener.

func (*BasicListener) Addr

func (b *BasicListener) Addr() net.Addr

Addr implements net.Listener.

func (*BasicListener) Close

func (b *BasicListener) Close() error

Close implements net.Listener.

func (*BasicListener) UnmarshalJSON

func (b *BasicListener) UnmarshalJSON(d []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type BasicTLSListener

type BasicTLSListener struct {
	Listener   net.Listener
	CertGetter TLSCertificateGetter
	// contains filtered or unexported fields
}

BasicTLSListener combines the certificate retrieval process abstracted by a TLSCertificateGetter with a supplied net.Listener to give a simple configurable wrapper around a call to crypto/tls.NewListener.

func (*BasicTLSListener) Accept

func (b *BasicTLSListener) Accept() (net.Conn, error)

Accept implements net.Listener.

func (*BasicTLSListener) Addr

func (b *BasicTLSListener) Addr() net.Addr

Addr implements net.Listener.

func (*BasicTLSListener) Close

func (b *BasicTLSListener) Close() error

Close implements net.Listener.

func (*BasicTLSListener) UnmarshalJSON

func (b *BasicTLSListener) UnmarshalJSON(d []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type PemConfig

type PemConfig struct {
	Cert []byte
	Key  []byte
}

PemConfig implements a TlsCertificateGetter using a single PEM encoded key and certificate pair.

func (*PemConfig) GetCertificate

func (p *PemConfig) GetCertificate(
	*tls.ClientHelloInfo,
) (*tls.Certificate, error)

GetCertificate implements TlsCertificateGetter.

func (*PemConfig) UnmarshalJSON

func (p *PemConfig) UnmarshalJSON(d []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type TLSCertificateGetter

type TLSCertificateGetter interface {
	GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)
}

TLSCertificateGetter provides a mechanism by which the assignment of the crypto/tls.Config.GetCertificate method can be abstracted independently from other aspects of the creation of the net.Listener returned from a call to crypto/tls.NewListener.

Jump to

Keyboard shortcuts

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