Documentation ¶
Index ¶
- Constants
- Variables
- type ALPNListener
- type ALPNListenerConfig
- type Agent
- type AgentAuthenticationInfo
- type AgentConfig
- type AgentInfo
- type AgentRole
- type AgentState
- type AuthenticationRole
- type Connection
- func (c *Connection) AcceptDataChannel(ctx context.Context) (*DataChannel, error)
- func (c *Connection) AcceptTransport(ctx context.Context) (*Transport, error)
- func (c *Connection) Close() error
- func (c *Connection) LocalAgent() *Agent
- func (c *Connection) NewTransport(ctx context.Context) (*Transport, error)
- func (c *Connection) NewTransportListener() (*Transport, error)
- func (c *Connection) OpenDataChannel(ctx context.Context, params DataChannelParameters) (*DataChannel, error)
- func (c *Connection) RemoteAgent() *Agent
- type DataChannel
- func (c *DataChannel) Close() error
- func (c *DataChannel) Read(p []byte) (int, error)
- func (c *DataChannel) ReadDataChannel(p []byte) (int, DataEncoding, error)
- func (c *DataChannel) ReceiveMessage() ([]byte, error)
- func (c *DataChannel) ReceiveMessageWithEncoding() ([]byte, DataEncoding, error)
- func (c *DataChannel) SendMessage(payload []byte) error
- func (c *DataChannel) SendMessageWithEncoding(payload []byte, enc DataEncoding) error
- func (c *DataChannel) Write(p []byte) (n int, err error)
- func (c *DataChannel) WriteDataChannel(p []byte, enc DataEncoding) (n int, err error)
- type DataChannelParameters
- type DataEncoding
- type DiscoveredAgent
- type Discoverer
- type Listener
- type PSKConfig
- type PeerID
- type QuicStream
- type TXTRecordSet
- type Transport
- type TransportListener
- type TypeKey
- type UnauthenticatedConnection
- func (c *UnauthenticatedConnection) AcceptAuthenticate(ctx context.Context) (role AuthenticationRole, err error)
- func (c *UnauthenticatedConnection) AuthenticatePSK(ctx context.Context, psk []byte) (*Connection, error)
- func (c *UnauthenticatedConnection) Close() error
- func (c *UnauthenticatedConnection) GeneratePSK() ([]byte, error)
- func (c *UnauthenticatedConnection) GetAuthenticationRole() AuthenticationRole
- func (c *UnauthenticatedConnection) LocalAgent() *Agent
- func (c *UnauthenticatedConnection) RemoteAgent() *Agent
- func (c *UnauthenticatedConnection) RequestAuthenticatePSK() error
Constants ¶
const ( DataEncodingBinary = iota DataEncodingString DataEncodingArrayBuffer )
const ( MdnsServiceType = "_openscreen._udp" MdnsDomain = "local" )
const (
ALPN_OSP = "OSP"
)
Variables ¶
var ErrConnectionClosed = errors.New("connection closed")
var ErrDiscovererClosed = errors.New("discoverer closed")
var ErrHandedOff = errors.New("connection handed off")
var ErrListenerClosed = errors.New("listener closed")
Functions ¶
This section is empty.
Types ¶
type ALPNListener ¶
type ALPNListener struct {
// contains filtered or unexported fields
}
ALPNListener allows listening for application protocols on the same port as OSP.
func (*ALPNListener) Accept ¶
func (l *ALPNListener) Accept(ctx context.Context) (quic.Connection, error)
func (*ALPNListener) Close ¶
func (l *ALPNListener) Close() error
type ALPNListenerConfig ¶
type ALPNListenerConfig struct {
VerifyConnection func(cs tls.ConnectionState) error
}
type Agent ¶
type Agent struct { PeerID PeerID Certificate *tls.Certificate CertificateSNBase uint32 CertificateSNCounter uint32 // contains filtered or unexported fields }
func NewAgent ¶
func NewAgent(c AgentConfig) (*Agent, error)
func (*Agent) AuthenticationInfo ¶
func (a *Agent) AuthenticationInfo() *AgentAuthenticationInfo
func (*Agent) CertificateFingerPrint ¶
func (*Agent) HasAuthenticationInfo ¶
func (*Agent) NewRemoteAgent ¶
type AgentAuthenticationInfo ¶
type AgentAuthenticationInfo struct {
PSKConfig PSKConfig
}
type AgentConfig ¶
type AgentConfig struct { // ID PeerID PeerID Certificate *tls.Certificate CertificateSNBase uint32 // Info DisplayName string ModelName string Locales []string // AuthInfo PSKConfig PSKConfig }
func NewAgentConfig ¶
func NewAgentConfig(nickname string) AgentConfig
func (*AgentConfig) WithCertificateSNBase ¶
func (c *AgentConfig) WithCertificateSNBase(snBase uint32)
func (*AgentConfig) WithModelName ¶
func (c *AgentConfig) WithModelName(easeOfInput, entropy int)
func (*AgentConfig) WithPSKConfig ¶
func (c *AgentConfig) WithPSKConfig(easeOfInput, entropy int)
type AgentState ¶
type AuthenticationRole ¶
type AuthenticationRole int
const ( AuthenticationRolePresenter AuthenticationRole = 0 AuthenticationRoleConsumer AuthenticationRole = 1 )
func (AuthenticationRole) String ¶
func (t AuthenticationRole) String() string
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection
func (*Connection) AcceptDataChannel ¶
func (c *Connection) AcceptDataChannel(ctx context.Context) (*DataChannel, error)
AcceptStream accepts a data channel
func (*Connection) AcceptTransport ¶
func (c *Connection) AcceptTransport(ctx context.Context) (*Transport, error)
func (*Connection) Close ¶
func (c *Connection) Close() error
Close the connection and all associated steams.
func (*Connection) LocalAgent ¶
func (c *Connection) LocalAgent() *Agent
func (*Connection) NewTransport ¶
func (c *Connection) NewTransport(ctx context.Context) (*Transport, error)
NewTransport
func (*Connection) NewTransportListener ¶
func (c *Connection) NewTransportListener() (*Transport, error)
func (*Connection) OpenDataChannel ¶
func (c *Connection) OpenDataChannel(ctx context.Context, params DataChannelParameters) (*DataChannel, error)
OpenDataChannel opens a data channel
func (*Connection) RemoteAgent ¶
func (c *Connection) RemoteAgent() *Agent
type DataChannel ¶
type DataChannel struct { DataChannelParameters // contains filtered or unexported fields }
func (*DataChannel) Close ¶
func (c *DataChannel) Close() error
Close closes the DataChannel and the underlying Quic stream.
func (*DataChannel) Read ¶
func (c *DataChannel) Read(p []byte) (int, error)
Read reads a packet of len(p) bytes as binary data
func (*DataChannel) ReadDataChannel ¶
func (c *DataChannel) ReadDataChannel(p []byte) (int, DataEncoding, error)
ReadDataChannel reads a packet of len(p) bytes
func (*DataChannel) ReceiveMessage ¶
func (c *DataChannel) ReceiveMessage() ([]byte, error)
ReceiveMessage
func (*DataChannel) ReceiveMessageWithEncoding ¶
func (c *DataChannel) ReceiveMessageWithEncoding() ([]byte, DataEncoding, error)
ReceiveMessageWithEncoding
func (*DataChannel) SendMessage ¶
func (c *DataChannel) SendMessage(payload []byte) error
SendMessage
func (*DataChannel) SendMessageWithEncoding ¶
func (c *DataChannel) SendMessageWithEncoding(payload []byte, enc DataEncoding) error
SendMessageWithEncoding
func (*DataChannel) Write ¶
func (c *DataChannel) Write(p []byte) (n int, err error)
Write writes len(p) bytes from p as binary data
func (*DataChannel) WriteDataChannel ¶
func (c *DataChannel) WriteDataChannel(p []byte, enc DataEncoding) (n int, err error)
WriteDataChannel writes len(p) bytes from p
type DataChannelParameters ¶
DataChannelParameters
type DataEncoding ¶
type DataEncoding uint64
DataEncoding represents pre-agreed EncodingIds used in exchange-data.
type DiscoveredAgent ¶
type DiscoveredAgent struct { PeerID PeerID TXT TXTRecordSet // contains filtered or unexported fields }
DiscoveredAgent represents a discovered remote agent that has not been contacted yet.
func (DiscoveredAgent) Dial ¶
func (ra DiscoveredAgent) Dial(ctx context.Context, la *Agent) (*UnauthenticatedConnection, error)
Dial opens a connection to the remote agent.
func (*DiscoveredAgent) Nickname ¶
func (a *DiscoveredAgent) Nickname() string
Nickname of the remote agent
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer is used to discover agents.
func (*Discoverer) Accept ¶
func (d *Discoverer) Accept(ctx context.Context) (*DiscoveredAgent, error)
Accept returns an a discovered agent. It should be called in a loop.
func (*Discoverer) Close ¶
func (d *Discoverer) Close() error
Close closes the discoverer. Any blocked Accept operations will be unblocked and return errors.
func (*Discoverer) WithNickname ¶
func (d *Discoverer) WithNickname(nickname string)
WithNickname defines a nickname of agents to discover.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener acts as an advertising OSP agent and listens for incoming connections.
func (*Listener) Accept ¶
func (l *Listener) Accept(ctx context.Context) (*UnauthenticatedConnection, error)
Accept returns an a discovered agent. It should be called in a loop.
func (*Listener) Close ¶
Close closes the listener. Any blocked Accept operations will be unblocked and return errors.
func (*Listener) ListenApplication ¶
func (l *Listener) ListenApplication(alpn string, config *ALPNListenerConfig) *ALPNListener
ListenApplication allows you to listen for quic connections on the same port but with a different ALPN. Only one per ALPN is allowed. Needs to be registered before starting the Listener.
type PeerID ¶
type PeerID string
PeerID is a unique identifier for a peer, it is equal tot the OSP agent fingerprint (FP) of the peer.
type QuicStream ¶
type QuicStream struct {
// contains filtered or unexported fields
}
Stream
func (*QuicStream) Close ¶
func (s *QuicStream) Close() error
func (*QuicStream) StreamID ¶
func (s *QuicStream) StreamID() int64
type TXTRecordSet ¶
func (TXTRecordSet) Add ¶
func (r TXTRecordSet) Add(key, value string)
func (TXTRecordSet) FromSlice ¶
func (r TXTRecordSet) FromSlice(in []string) error
func (TXTRecordSet) Get ¶
func (r TXTRecordSet) Get(key string) []string
func (TXTRecordSet) Set ¶
func (r TXTRecordSet) Set(key, value string)
func (TXTRecordSet) ToSlice ¶
func (r TXTRecordSet) ToSlice() []string
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements WebTransport pooled over an existing OpenScreenProtocol connection.
func (*Transport) AcceptStream ¶
func (t *Transport) AcceptStream(ctx context.Context) (*QuicStream, error)
func (*Transport) OpenStreamSync ¶
func (t *Transport) OpenStreamSync(ctx context.Context) (*QuicStream, error)
type TransportListener ¶
type TransportListener struct {
// contains filtered or unexported fields
}
func (*TransportListener) Accept ¶
func (l *TransportListener) Accept(ctx context.Context) (*Transport, error)
func (*TransportListener) Close ¶
func (l *TransportListener) Close() error
type UnauthenticatedConnection ¶
type UnauthenticatedConnection struct {
// contains filtered or unexported fields
}
UnauthenticatedConnection represents an OSPC connection that didn't pass authentication yet.
func (*UnauthenticatedConnection) AcceptAuthenticate ¶
func (c *UnauthenticatedConnection) AcceptAuthenticate(ctx context.Context) (role AuthenticationRole, err error)
AcceptAuthenticate is used to handle an incoming authentication request. It has to be called for every UnauthenticatedConnection.
func (*UnauthenticatedConnection) AuthenticatePSK ¶
func (c *UnauthenticatedConnection) AuthenticatePSK(ctx context.Context, psk []byte) (*Connection, error)
Authenticate is used to authenticate. It will block until authentication is complete or the context is closed.
func (*UnauthenticatedConnection) Close ¶
func (c *UnauthenticatedConnection) Close() error
Close the unauthenticated connection. If the connection has progressed to authenticated, it is not closed but an error is returned. This allows for defer closing regardless.
func (*UnauthenticatedConnection) GeneratePSK ¶
func (c *UnauthenticatedConnection) GeneratePSK() ([]byte, error)
GeneratePSK creates a PSK based on the negotiated config.
func (*UnauthenticatedConnection) GetAuthenticationRole ¶
func (c *UnauthenticatedConnection) GetAuthenticationRole() AuthenticationRole
GetAuthenticationRole determines if the agent should act as presenter or consumer of the PSK.
func (*UnauthenticatedConnection) LocalAgent ¶
func (c *UnauthenticatedConnection) LocalAgent() *Agent
LocalAgent provides info about local agent
func (*UnauthenticatedConnection) RemoteAgent ¶
func (c *UnauthenticatedConnection) RemoteAgent() *Agent
RemoteAgent provides info about remote agent
func (*UnauthenticatedConnection) RequestAuthenticatePSK ¶
func (c *UnauthenticatedConnection) RequestAuthenticatePSK() error
RequestAuthenticatePSK is used to request authentication as an initiating collector agent.