Documentation ¶
Index ¶
- func Client(conn *dtls.Conn, opts ...DialOption) *client.ClientConn
- func Dial(target string, dtlsCfg *dtls.Config, opts ...DialOption) (*client.ClientConn, error)
- type BlockwiseFactoryFunc
- type BlockwiseOpt
- type CloseSocketOpt
- type ContextOpt
- type DialOption
- type DialerOpt
- type ErrorFunc
- type ErrorsOpt
- type EventFunc
- type GetMIDFunc
- type GoPoolFunc
- type GoPoolOpt
- type HandlerFunc
- type HandlerFuncOpt
- type InactivityMonitorOpt
- type KeepAliveOpt
- type Listener
- type MaxMessageSizeOpt
- type MessagePoolOpt
- type NetOpt
- type OnNewClientConnFunc
- type OnNewClientConnOpt
- type PeriodicRunnerOpt
- type Server
- type ServerOption
- type Session
- func (s *Session) AddOnClose(f EventFunc)
- func (s *Session) Close() error
- func (s *Session) Context() context.Context
- func (s *Session) Done() <-chan struct{}
- func (s *Session) LocalAddr() net.Addr
- func (s *Session) MaxMessageSize() uint32
- func (s *Session) RemoteAddr() net.Addr
- func (s *Session) Run(cc *client.ClientConn) (err error)
- func (s *Session) SetContextValue(key interface{}, val interface{})
- func (s *Session) WriteMessage(req *pool.Message) error
- func (s *Session) WriteMulticastMessage(req *pool.Message, address *net.UDPAddr, opts ...coapNet.MulticastOption) error
- type TransmissionOpt
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Client ¶
func Client(conn *dtls.Conn, opts ...DialOption) *client.ClientConn
Client creates client over dtls connection.
func Dial ¶
func Dial(target string, dtlsCfg *dtls.Config, opts ...DialOption) (*client.ClientConn, error)
Dial creates a client connection to the given target.
Types ¶
type BlockwiseFactoryFunc ¶
type BlockwiseOpt ¶
type BlockwiseOpt struct {
// contains filtered or unexported fields
}
BlockwiseOpt network option.
func WithBlockwise ¶
WithBlockwise configure's blockwise transfer.
type CloseSocketOpt ¶
type CloseSocketOpt struct{}
CloseSocketOpt close socket option.
func WithCloseSocket ¶
func WithCloseSocket() CloseSocketOpt
WithCloseSocket closes socket at the close connection.
type ContextOpt ¶
type ContextOpt struct {
// contains filtered or unexported fields
}
ContextOpt handler function option.
func WithContext ¶
func WithContext(ctx context.Context) ContextOpt
WithContext set's parent context of server.
type DialOption ¶
type DialOption interface {
// contains filtered or unexported methods
}
A DialOption sets options such as credentials, keepalive parameters, etc.
type DialerOpt ¶
type DialerOpt struct {
// contains filtered or unexported fields
}
DialerOpt dialer option.
type ErrorsOpt ¶
type ErrorsOpt struct {
// contains filtered or unexported fields
}
ErrorsOpt errors option.
func WithErrors ¶
WithErrors set function for logging error.
type GetMIDFunc ¶
type GetMIDFunc = func() uint16
type GoPoolFunc ¶
type GoPoolFunc = func(func()) error
type GoPoolOpt ¶
type GoPoolOpt struct {
// contains filtered or unexported fields
}
GoPoolOpt gopool option.
func WithGoPool ¶
func WithGoPool(goPool GoPoolFunc) GoPoolOpt
WithGoPool sets function for managing spawning go routines for handling incoming request's. Eg: https://github.com/panjf2000/ants.
type HandlerFunc ¶
type HandlerFunc = func(*client.ResponseWriter, *pool.Message)
The HandlerFunc type is an adapter to allow the use of ordinary functions as COAP handlers.
type HandlerFuncOpt ¶
type HandlerFuncOpt struct {
// contains filtered or unexported fields
}
HandlerFuncOpt handler function option.
func WithHandlerFunc ¶
func WithHandlerFunc(h HandlerFunc) HandlerFuncOpt
WithHandlerFunc set handle for handling request's.
func WithMux ¶
func WithMux(m mux.Handler) HandlerFuncOpt
WithMux set's multiplexer for handle requests.
type InactivityMonitorOpt ¶
type InactivityMonitorOpt struct {
// contains filtered or unexported fields
}
InactivityMonitorOpt notifies when a connection was inactive for a given duration.
func WithInactivityMonitor ¶
func WithInactivityMonitor(duration time.Duration, onInactive inactivity.OnInactiveFunc) InactivityMonitorOpt
WithInactivityMonitor set deadline's for read operations over client connection.
type KeepAliveOpt ¶
type KeepAliveOpt struct {
// contains filtered or unexported fields
}
KeepAliveOpt keepalive option.
func WithKeepAlive ¶
func WithKeepAlive(maxRetries uint32, timeout time.Duration, onInactive inactivity.OnInactiveFunc) KeepAliveOpt
WithKeepAlive monitoring's client connection's.
type MaxMessageSizeOpt ¶
type MaxMessageSizeOpt struct {
// contains filtered or unexported fields
}
MaxMessageSizeOpt handler function option.
func WithMaxMessageSize ¶
func WithMaxMessageSize(maxMessageSize uint32) MaxMessageSizeOpt
WithMaxMessageSize limit size of processed message.
type MessagePoolOpt ¶
type MessagePoolOpt struct {
// contains filtered or unexported fields
}
MessagePoolOpt network option.
func WithMessagePool ¶
func WithMessagePool(messagePool *pool.Pool) MessagePoolOpt
WithMessagePool configure's message pool for acquire/releasing coap messages
type NetOpt ¶
type NetOpt struct {
// contains filtered or unexported fields
}
NetOpt network option.
func WithNetwork ¶
WithNetwork define's udp version (udp4, udp6, udp) for client.
type OnNewClientConnFunc ¶
type OnNewClientConnFunc = func(cc *client.ClientConn, dtlsConn *dtls.Conn)
OnNewClientConnFunc is the callback for new connections.
Note: Calling `dtlsConn.Close()` is forbidden, and `dtlsConn` should be treated as a "read-only" parameter, mainly used to get the peer certificate from the underlining connection
type OnNewClientConnOpt ¶
type OnNewClientConnOpt struct {
// contains filtered or unexported fields
}
OnNewClientConnOpt network option.
func WithOnNewClientConn ¶
func WithOnNewClientConn(onNewClientConn OnNewClientConnFunc) OnNewClientConnOpt
WithOnNewClientConn server's notify about new client connection.
Note: Calling `dtlsConn.Close()` is forbidden, and `dtlsConn` should be treated as a "read-only" parameter, mainly used to get the peer certificate from the underlining connection
type PeriodicRunnerOpt ¶
type PeriodicRunnerOpt struct {
// contains filtered or unexported fields
}
PeriodicRunnerOpt function which is executed in every ticks
func WithPeriodicRunner ¶
func WithPeriodicRunner(periodicRunner periodic.Func) PeriodicRunnerOpt
WithPeriodicRunner set function which is executed in every ticks.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opt ...ServerOption) *Server
func (*Server) Serve ¶
Example ¶
package main import ( "fmt" "log" piondtls "github.com/pion/dtls/v2" "github.com/plgd-dev/go-coap/v2/dtls" "github.com/plgd-dev/go-coap/v2/net" ) func main() { dtlsCfg := &piondtls.Config{ PSK: func(hint []byte) ([]byte, error) { fmt.Printf("Hint: %s \n", hint) return []byte{0xAB, 0xC1, 0x23}, nil }, PSKIdentityHint: []byte("Pion DTLS Server"), CipherSuites: []piondtls.CipherSuiteID{piondtls.TLS_PSK_WITH_AES_128_CCM_8}, } l, err := net.NewDTLSListener("udp", "0.0.0.0:5683", dtlsCfg) if err != nil { log.Fatal(err) } defer l.Close() s := dtls.NewServer() defer s.Stop() log.Fatal(s.Serve(l)) }
Output:
type ServerOption ¶
type ServerOption interface {
// contains filtered or unexported methods
}
A ServerOption sets options such as credentials, codec and keepalive parameters, etc.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) AddOnClose ¶
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done signalizes that connection is not more processed.
func (*Session) MaxMessageSize ¶
func (*Session) RemoteAddr ¶
func (*Session) Run ¶
func (s *Session) Run(cc *client.ClientConn) (err error)
Run reads and process requests from a connection, until the connection is not closed.
func (*Session) SetContextValue ¶
func (s *Session) SetContextValue(key interface{}, val interface{})
SetContextValue stores the value associated with key to context of connection.
func (*Session) WriteMulticastMessage ¶
func (s *Session) WriteMulticastMessage(req *pool.Message, address *net.UDPAddr, opts ...coapNet.MulticastOption) error
WriteMulticastMessage sends multicast to the remote multicast address. Currently it is not implemented - is is just satisfy golang udp/client/Session interface.
type TransmissionOpt ¶
type TransmissionOpt struct {
// contains filtered or unexported fields
}
TransmissionOpt transmission options.
func WithTransmission ¶
func WithTransmission(transmissionNStart time.Duration, transmissionAcknowledgeTimeout time.Duration, transmissionMaxRetransmit uint32, ) TransmissionOpt
WithTransmission set options for (re)transmission for Confirmable message-s.