Documentation ¶
Index ¶
- func NewStringPullParser(xmpp string) (*xpp.XMLPullParser, error)
- type InitialStreamTag
- type KikInitialStreamResponse
- type LoggingBufferedReader
- type Node
- func (n Node) Find(name string) *Node
- func (n Node) FindAll(name string) iter.Seq2[int, Node]
- func (n Node) FindLast(name string) *Node
- func (n Node) FindText(name string) *string
- func (n Node) FindTextSafe(name string) string
- func (n Node) Get(key string) string
- func (n Node) GetOptional(key string) *string
- func (n Node) HasAttribute(key string) bool
- func (n Node) HasTag(name string) bool
- func (n Node) IndentedString() string
- func (n Node) String() string
- type NodeInputStream
- type NodeWriter
- func (w NodeWriter) Attribute(name string, value string) NodeWriter
- func (w NodeWriter) AttributeIf(name string, value *string) NodeWriter
- func (w NodeWriter) EmptyTag(name string) NodeWriter
- func (w NodeWriter) EndAllFlush()
- func (w NodeWriter) EndTag(name string) NodeWriter
- func (w NodeWriter) IsIos() bool
- func (w NodeWriter) StartTag(name string) NodeWriter
- func (w NodeWriter) String() string
- func (w NodeWriter) TagText(name string, value string) NodeWriter
- func (w NodeWriter) TagTextIf(name string, value *string) NodeWriter
- func (w NodeWriter) Text(text string) NodeWriter
- func (w NodeWriter) WriteKikTag(push bool, qos bool, timestamp string) NodeWriter
- func (w NodeWriter) WriteNode(n Node)
- func (w NodeWriter) WriteRaw(xml string) NodeWriter
- func (w NodeWriter) WriteRequestTag(requestDelivered bool, requestRead bool) NodeWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStringPullParser ¶
func NewStringPullParser(xmpp string) (*xpp.XMLPullParser, error)
Creates a new XMLPullParser for a given string.
Types ¶
type InitialStreamTag ¶
type InitialStreamTag struct { // The IP address of the connected client ClientIp string // The attributes in the <k stanza Attributes map[string]string // The raw stanza received from the client RawStanza string // True if the client is authenticating with Kik using credentials IsAuth bool // if IsAuth == true, this is not nil, otherwise it is nil Jid *datatypes.FullJid // The device ID in use by the client, not nil DeviceId datatypes.KikDeviceId // The version name in use by the client, not nil Version string // Optional interface IP specified by the client InterfaceIp *string // Optional API key specified by the client ApiKey *string }
Describes a bind request from the client
func ParseInitialStreamTag ¶
func ParseInitialStreamTag(conn net.Conn) (*InitialStreamTag, bool, error)
Parses and verifies the initial stream tag from the client. If the error returned is nil, the parsing succeeded, and the other return values must be ignored. Returns: InitialStreamTag, shouldBanIp, error
func (InitialStreamTag) KikHost ¶
func (k InitialStreamTag) KikHost() (*string, error)
Returns the corresponding XMPP host name based on the connecting client info. Kik uses different host names dependent on the OS and client version. error is not nil if the client supplies an invalid version number.
func (InitialStreamTag) UserId ¶
func (k InitialStreamTag) UserId() string
Returns a unique identifier for the connecting client. For authed connections, this is the JID For anon connections, this is the Device ID (with prefix)
type KikInitialStreamResponse ¶
type KikInitialStreamResponse struct { // True if Kik returned success on bind IsOk bool // The timestamp of the Kik server, used to sync the local time of our server and connecting clients. // If the client is binding pre-auth (anon="1"), the timestamp will be 0 and should be ignored. Timestamp int64 // The raw stanza received from Kik. RawStanza string }
Describes a bind response from Kik
func ParseInitialStreamResponse ¶
func ParseInitialStreamResponse(input NodeInputStream) (*KikInitialStreamResponse, error)
func (KikInitialStreamResponse) GenerateServerResponse ¶
func (response KikInitialStreamResponse) GenerateServerResponse(customBanner bool) string
type LoggingBufferedReader ¶
type LoggingBufferedReader struct {
// contains filtered or unexported fields
}
Sits on top of the real reader so we can log the raw XMPP
func (*LoggingBufferedReader) ClearBuffer ¶
func (r *LoggingBufferedReader) ClearBuffer()
func (*LoggingBufferedReader) GetBuffer ¶
func (r *LoggingBufferedReader) GetBuffer() []byte
type Node ¶
func ParseNextNode ¶
func ParseNextNode(parser *xpp.XMLPullParser) (*Node, error)
Reads the next Node from the XMLPull Parser. Parser must be positioned on a StartTag.
func ParseStreamHeader ¶
Parses an initial stream header from a string. Stream headers must not be self-closing.
func ParseXmppString ¶
Parse an XMPP string Note that this will return an error if all tags are not properly closed.
func (Node) FindAll ¶
Finds all matching children by name. For the iter.Seq2, the first item is the position of the child element, the second item is the element.
func (Node) FindText ¶
Finds the text of the first matching child by its name. Returns nil if not found.
func (Node) FindTextSafe ¶
Finds the text of the first matching child by its name. Returns an empty string if not found.
func (Node) GetOptional ¶
Finds an attribute value by its name. Returns nil if not found.
func (Node) HasAttribute ¶
Returns true if the Node contains the attribute key.
func (Node) IndentedString ¶
Converts the node to an XML representation. Pretty printed for visual parsing.
type NodeInputStream ¶
type NodeInputStream struct { Reader *LoggingBufferedReader Parser xpp.XMLPullParser }
func NewNodeInputStream ¶
func NewNodeInputStream(connection net.Conn) NodeInputStream
Create a XMLPullParser for a long-lived input stream.
func (NodeInputStream) ReadNextStanza ¶
func (input NodeInputStream) ReadNextStanza() (node *Node, xml *[]byte, err error)
Read the next stanza from the input stream.
If an error is encountered, node and string will be nil.
If successful, the node object and the raw stanza will be returned in the first two values.
type NodeWriter ¶
type NodeWriter struct {
// contains filtered or unexported fields
}
Simplifies stanza creation.
func NewIndentedNodeWriter ¶
func NewIndentedNodeWriter() NodeWriter
Creates a new NodeWriter that pretty prints the XML as it writes events.
func NewIosWriter ¶
func NewIosWriter() NodeWriter
Creates a new NodeWriter that writes in iOS style.
func NewNodeWriter ¶
func NewNodeWriter() NodeWriter
Creates a new NodeWriter that writes in default (Android) style.
func (NodeWriter) Attribute ¶
func (w NodeWriter) Attribute(name string, value string) NodeWriter
Writes an attribute. Writer must be positioned on a StartTag.
func (NodeWriter) AttributeIf ¶
func (w NodeWriter) AttributeIf(name string, value *string) NodeWriter
Writes an attribute. Writer must be positioned on a StartTag. No-op if value is nil.
func (NodeWriter) EmptyTag ¶
func (w NodeWriter) EmptyTag(name string) NodeWriter
Writes StartTag, empty text, then EndTag. Serialized as <foo></foo>
func (NodeWriter) EndTag ¶
func (w NodeWriter) EndTag(name string) NodeWriter
Ends a tag that was previously opened via StartTag.
func (NodeWriter) IsIos ¶
func (w NodeWriter) IsIos() bool
Returns true if the writer is currently in iOS style. When true, it can be assumed that the packet must emulate iOS output.
func (NodeWriter) StartTag ¶
func (w NodeWriter) StartTag(name string) NodeWriter
Begins (opens) a tag.
func (NodeWriter) String ¶
func (w NodeWriter) String() string
Returns the serialized XML. This function panics if the xmlwriter encountered an error when writing, which occurs if the caller uses functions in a wrong order (i.e. end tag without start tag)
func (NodeWriter) TagText ¶
func (w NodeWriter) TagText(name string, value string) NodeWriter
Writes StartTag, Text, then EndTag.
func (NodeWriter) TagTextIf ¶
func (w NodeWriter) TagTextIf(name string, value *string) NodeWriter
Writes StartTag, Text, then EndTag. Does nothing if value is nil.
func (NodeWriter) Text ¶
func (w NodeWriter) Text(text string) NodeWriter
Writes text. Caller must have called StartTag or Attribute prior to calling this.
func (NodeWriter) WriteKikTag ¶
func (w NodeWriter) WriteKikTag(push bool, qos bool, timestamp string) NodeWriter
Writes a <kik/> element, required for all outgoing message stanzas
func (NodeWriter) WriteNode ¶
func (w NodeWriter) WriteNode(n Node)
Writes the contents of a Node into the NodeWriter.
func (NodeWriter) WriteRaw ¶
func (w NodeWriter) WriteRaw(xml string) NodeWriter
Writes a raw string, not escaped.
func (NodeWriter) WriteRequestTag ¶
func (w NodeWriter) WriteRequestTag(requestDelivered bool, requestRead bool) NodeWriter
Writes a request element, required for outgoing messages containing user facing content