Documentation ¶
Overview ¶
Package location contains a common interface for interacting with various Location types and every Location TLV type in the moneysocket protocol
Index ¶
Constants ¶
const ( // DefaultBluetoothPlaceholder temporarily defines an hrp header // for the as-of-yet unused BluetoothLocation type. DefaultBluetoothPlaceholder = "bluetooth herpader" // BluetoothType defines the name of the BluetoothLocation type. BluetoothType = "Bluetooth" )
const ( // DefaultNFCPlaceholder defines the default value used by a placeholder. DefaultNFCPlaceholder = "nfc herpader" // NFCType defines the name of the NFCLocation type. NFCType = "NFC" )
const ( // DefaultWebRTCPlaceholder temporarily defines an hrp header // for the as-of-yet unused WebRTCLocation type. DefaultWebRTCPlaceholder = "webrtc herpader" // WebRTCType defines a type. WebRTCType = "WebRTC" )
const ( // WebsocketType is the type of WebsocketLocation. WebsocketType = "WebSocket" // HostTlvType position when encoding the TLV. HostTlvType = 0 // UseTLSTLVType position when encoding the TLV // bool, corollary to use_tls_enum_value https://git.io/JLgWa UseTLSTLVType = 1 // UseTLSEnumValueTrue indicates tls is used. UseTLSEnumValueTrue = 0 // UseTLSEnumFalse indicates tls is not used. UseTLSEnumFalse = 1 // PortTLVType is the position of the port in the encoded tlv. PortTLVType = 2 // DefaultTLSPort defined the default wss (secure websocket, see: https://tools.ietf.org/html/rfc6455#page-55 ) port. DefaultTLSPort = 443 // DefaultNoTLSPort is the default ws port (unsecure websocket, see; https://tools.ietf.org/html/rfc6455#page-54 ). DefaultNoTLSPort = 80 )
const PlaceholderTLVType = 0
PlaceholderTLVType is the default tlv type for unimplemented location beacons.
Variables ¶
This section is empty.
Functions ¶
func EncodedPlaceHolderTLV ¶ added in v0.40.0
EncodedPlaceHolderTLV generates a placeholder tlv, return a byte slice representing tlv.
func PlaceHolderTLV ¶ added in v0.40.0
PlaceHolderTLV encodes a placeholder tlv for python-parity tests.
Types ¶
type BluetoothLocation ¶
type BluetoothLocation struct { // PlaceholderString is the PlaceholderString string }
BluetoothLocation beacon - this is not currently implemented and is reserved for future use.
func BluetoothLocationFromTLV ¶ added in v0.40.0
func BluetoothLocationFromTLV(tlv beaconUtil.TLV) (loc BluetoothLocation, err error)
BluetoothLocationFromTLV converts a util.TLV from a tlv object.
func NewBluetoothLocation ¶
func NewBluetoothLocation() BluetoothLocation
NewBluetoothLocation Creates a new bluetooth location with the default header.
func (BluetoothLocation) EncodedTLV ¶ added in v0.40.0
func (loc BluetoothLocation) EncodedTLV() []byte
EncodedTLV gets the encoded tlv of a given BluetoothLocation.
func (BluetoothLocation) TLV ¶ added in v0.40.0
func (loc BluetoothLocation) TLV() []tlvHelper.Record
TLV gets the tlv of a given BluetoothLocation.
func (BluetoothLocation) ToObject ¶
func (loc BluetoothLocation) ToObject() map[string]interface{}
ToObject converts the BluetoothLocation to a json-serializable map.
func (BluetoothLocation) Type ¶
func (loc BluetoothLocation) Type() tlvHelper.Type
Type gets the BluetoothLocation tlv type.
type Location ¶
type Location interface { // Type gets the tlv.Type for a given location Type() tlv.Type // TLV returns the encoded tlv.Record for a given location TLV() []tlv.Record // EncodedTLV gets the encoded tlv as a byte slice for a given location EncodedTLV() []byte // ToObject gets a json-serializable object from the Location ToObject() map[string]interface{} }
Location defines an interface for various Location types.
type NFCLocation ¶ added in v0.40.0
type NFCLocation struct {
PlaceholderString string
}
NFCLocation defines a Location type for nfc.
func NewNFCLocation ¶ added in v0.40.0
func NewNFCLocation() NFCLocation
NewNFCLocation creates a new NFCLocation.
func NfcLocationFromTLV ¶ added in v0.40.0
func NfcLocationFromTLV(tlv beaconUtil.TLV) (loc NFCLocation, err error)
NfcLocationFromTLV converts a util.TLV from a tlv object.
func (NFCLocation) EncodedTLV ¶ added in v0.40.0
func (loc NFCLocation) EncodedTLV() []byte
EncodedTLV gets the encoded tlv of a given NFCLocation.
func (NFCLocation) TLV ¶ added in v0.40.0
func (loc NFCLocation) TLV() []tlv.Record
TLV gets the tlv of a given NFCLocation.
func (NFCLocation) ToObject ¶ added in v0.40.0
func (loc NFCLocation) ToObject() map[string]interface{}
ToObject converts the NFCLocation to a json-serializable map.
func (NFCLocation) Type ¶ added in v0.40.0
func (loc NFCLocation) Type() tlv.Type
Type gets the type of NFCLocation.
type WebRTCLocation ¶ added in v0.40.0
type WebRTCLocation struct { // PlaceholderString defines what gets encoded PlaceholderString string }
WebRTCLocation is a beacon location type placeholder.
func NewWebRTCLocation ¶ added in v0.40.0
func NewWebRTCLocation() WebRTCLocation
NewWebRTCLocation creates a new WebRTCLocation.
func WebRTCLocationFromTLV ¶ added in v0.40.0
func WebRTCLocationFromTLV(tlv util.TLV) (loc WebRTCLocation, err error)
WebRTCLocationFromTLV returns a WebRTCLocation based on an input tlv returns an error.
func (WebRTCLocation) EncodedTLV ¶ added in v0.40.0
func (loc WebRTCLocation) EncodedTLV() []byte
EncodedTLV gets the encoded tlv of a WebRTCLocation.
func (WebRTCLocation) TLV ¶ added in v0.40.0
func (loc WebRTCLocation) TLV() []tlv.Record
TLV gets the tlv for a WebRTCLocation.
func (WebRTCLocation) ToObject ¶ added in v0.40.0
func (loc WebRTCLocation) ToObject() map[string]interface{}
ToObject converts WebRTCLocation to a json-serializable map.
func (WebRTCLocation) Type ¶ added in v0.40.0
func (loc WebRTCLocation) Type() tlv.Type
Type gets the WebRTCLocation tlv.Type.
type WebsocketLocation ¶
type WebsocketLocation struct {
// contains filtered or unexported fields
}
WebsocketLocation is a Location type for websocket beacons.
func NewWebsocketLocation ¶
func NewWebsocketLocation(host string, useTLS bool) WebsocketLocation
NewWebsocketLocation generates a WebsocketLocation from a host/tls param.
func NewWebsocketLocationPort ¶
func NewWebsocketLocationPort(host string, useTLS bool, port int) WebsocketLocation
NewWebsocketLocationPort generates a WebsocketLocation from a host/tls/port params.
func WebsocketLocationFromTLV ¶ added in v0.40.0
func WebsocketLocationFromTLV(tlv beaconUtil.TLV) (wsl WebsocketLocation, err error)
WebsocketLocationFromTLV gets the WebsocketLocation from a tlv returns error if this cannot be done.
func (WebsocketLocation) EncodedTLV ¶ added in v0.40.0
func (ws WebsocketLocation) EncodedTLV() []byte
EncodedTLV encodes a TLV for a WebsocketLocation.
func (WebsocketLocation) IsTLS ¶ added in v0.54.0
func (ws WebsocketLocation) IsTLS() bool
IsTLS determines wether or not the WebsocketLocation should use wss:// or ws://.
func (WebsocketLocation) TLV ¶ added in v0.40.0
func (ws WebsocketLocation) TLV() []tlvHelper.Record
TLV gets the tlv for the WebsocketLocation.
func (WebsocketLocation) ToObject ¶
func (ws WebsocketLocation) ToObject() map[string]interface{}
ToObject converts WebsocketLocation to a json-serializable map.
func (WebsocketLocation) ToString ¶
func (ws WebsocketLocation) ToString() string
ToString converts a WebsocketLocation to an address to connect ot.
func (WebsocketLocation) Type ¶
func (ws WebsocketLocation) Type() tlvHelper.Type
Type is the tlv type of a WebsocketLocation.