sum7
/
yaja
Archived
1
0
Fork 0

implements some XEP in xmpp struct library

This commit is contained in:
Martin/Geno 2018-02-15 20:56:04 +01:00
parent e2a59cb3ba
commit 02ee2f2087
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
13 changed files with 151 additions and 58 deletions

View File

@ -8,9 +8,6 @@
## Features ## Features
- XMPP Library (first version - PR are welcome) - XMPP Library (first version - PR are welcome)
- RFC 6120 (XMPP - Core)
- XEP 0030: Service Discovery
- XEP-0199: XMPP Ping
- Client Library (WIP) - Client Library (WIP)
- Stream: TLS Required - Stream: TLS Required
- SASL-Auth (PLAIN, DIGEST-MD5) - SASL-Auth (PLAIN, DIGEST-MD5)
@ -34,9 +31,12 @@
all implementation of all comman (RFCs and XEPs) xml element all implementation of all comman (RFCs and XEPs) xml element
**Version** **Version**
- RFC 6120 (XMPP - Core) - [RFC 6120 (XMPP - Core)](https://xmpp.org/rfcs/rfc3920.html)
- XEP 0030: Service Discovery - [XEP 0030: Service Discovery](https://xmpp.org/extensions/xep-0030.html)
- XEP-0199: XMPP Ping - [XEP-0049: Private XML Storage](https://xmpp.org/extensions/xep-0049.html)
- [XEP-0092: Software Version](https://xmpp.org/extensions/xep-0092.html)
- [XEP-0138: Stream Compression](https://xmpp.org/extensions/xep-0138.html)
- [XEP-0199: XMPP Ping](https://xmpp.org/extensions/xep-0199.html)
### Client ### Client

View File

@ -16,10 +16,14 @@ type IQClient struct {
Type IQType `xml:"type,attr"` // required Type IQType `xml:"type,attr"` // required
Error *ErrorClient Error *ErrorClient
Bind *Bind // RFC 6120 A.7 Resource binding namespace (But in a IQ?) Bind *Bind // RFC 6120 A.7 Resource binding namespace (But in a IQ?)
Ping *xmppiq.Ping // XEP-0199: XMPP Ping (see iq/ping.go) DiscoQueryInfo *xmppiq.DiscoQueryInfo // XEP-0030: XMPP Service Discovery (see iq/service_discovery.go)
PrivateQuery *xmppiq.IQPrivateQuery // which XEP ? DiscoQueryItem *xmppiq.DiscoQueryItem // XEP-0030: XMPP Service Discovery (see iq/service_discovery.go)
PrivateRegister *xmppiq.IQPrivateRegister // which XEP ? PrivateXMLStorage *xmppiq.PrivateXMLStorage // XEP-0049: Private XML Storage (see iq/private_xml_storage.go)
VCard *xmppiq.VCard // XEP-0054: vcard-temp (see iq/vcard.go) - WIP
Register *xmppiq.Register // XEP-0077: In-Band Registration - 14.1 (see iq/register.go) - WIP
Version *xmppiq.Version // XEP-0092: Software Version (see iq/version.go)
Ping *xmppiq.Ping // XEP-0199: XMPP Ping (see iq/ping.go)
// Any hasn't matched element // Any hasn't matched element
Other []XMLElement `xml:",any"` Other []XMLElement `xml:",any"`

30
xmpp/compression.go Normal file
View File

@ -0,0 +1,30 @@
package xmpp
import "encoding/xml"
// CompressionFeature implements XEP-0138: Stream Compression - 10.1 Stream Feature
type CompressionFeature struct {
XMLName xml.Name `xml:"http://jabber.org/features/compress compression"`
Methods []string `xml:"method"`
}
// CompressionCompress implements XEP-0138: Stream Compression - 10.2 Protocol Namespace
type CompressionCompress struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/compress compress"`
Methods []string `xml:"method"`
}
// CompressionCompressed implements XEP-0138: Stream Compression - 10.2 Protocol Namespace
type CompressionCompressed struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/compress compressed"`
}
// CompressionFailure implements XEP-0138: Stream Compression - 10.2 Protocol Namespace
type CompressionFailure struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/compress failure"`
SetupFailed *xml.Name `xml:"http://jabber.org/protocol/compress setup-failed"`
ProcessingFailed *xml.Name `xml:"http://jabber.org/protocol/compress processing-failed"`
UnsupportedFailed *xml.Name `xml:"http://jabber.org/protocol/compress unsupported-failed"`
Text *Text
StanzaErrorGroup
}

View File

@ -8,11 +8,12 @@ import (
// StreamFeatures implements RFC 6120 - A.1 Stream Namespace // StreamFeatures implements RFC 6120 - A.1 Stream Namespace
type StreamFeatures struct { type StreamFeatures struct {
XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"` XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"`
StartTLS *TLSStartTLS StartTLS *TLSStartTLS
Mechanisms SASLMechanisms Mechanisms SASLMechanisms // RFC 6120 - A.4 SASL Namespace (see sasl.go)
Bind *Bind Compression *CompressionFeature // XEP-0138: Stream Compression (see compression.go)
Session bool Bind *Bind
Session bool
} }
// TLSStartTLS implements RFC 6120 - A.3 StartTLS Namespace // TLSStartTLS implements RFC 6120 - A.3 StartTLS Namespace

View File

@ -1,18 +1,27 @@
package xmppiq package xmppiq
const ( const (
// NSIQPing implements XEP-0199: XMPP Ping - 10 // NSDiscoInfo implements XEP 0030: Service Discovery - 11.1 disco#info
NSIQPing = "urn:xmpp:ping" NSDiscoInfo = "http://jabber.org/protocol/disco#info"
// NSIQDiscoInfo implements XEP 0030: Service Discovery - 11.1 disco#info // NSDiscoItems implements XEP 0030: Service Discovery - 11.2 disco#items
NSIQDiscoInfo = "http://jabber.org/protocol/disco#info" NSDiscoItems = "http://jabber.org/protocol/disco#items"
// NSIQDiscoItems implements XEP 0030: Service Discovery - 11.2 disco#items // NSPrivateXMLStorage implements XEP-0049: Private XML Storage - 7
NSIQDiscoItems = "http://jabber.org/protocol/disco#items" NSPrivateXMLStorage = "jabber:iq:private"
// NSIQRegister implements which XEP ? // NSVCard implements XEP-0054: vcard-temp - 14 (WIP)
NSIQRegister = "jabber:iq:register" NSVCard = "vcard-temp"
// NSFeaturesIQRegister implements which XEP ? // NSVersion implements XEP-0092: Software Version - 4
NSFeaturesIQRegister = "http://jabber.org/features/iq-register" NSVersion = "jabber:iq:version"
// NSPing implements XEP-0199: XMPP Ping - 10
NSPing = "urn:xmpp:ping"
// NSRegister implements XEP-0077: In-Band Registration - 14.1 jabber:iq:register
NSRegister = "jabber:iq:register"
// NSFeatureRegister implements XEP-0077: In-Band Registration - 14.2 Stream Feature
NSFeatureRegister = "http://jabber.org/features/iq-register"
) )

View File

@ -4,7 +4,7 @@ import (
"encoding/xml" "encoding/xml"
) )
// XEP-0199: XMPP Ping // Ping implements XEP-0199: XMPP Ping - 10
type Ping struct { type Ping struct {
XMLName xml.Name `xml:"urn:xmpp:ping ping"` XMLName xml.Name `xml:"urn:xmpp:ping ping"`
} }

View File

@ -0,0 +1,9 @@
package xmppiq
import "encoding/xml"
// PrivateXMLStorage implements XEP-0049: Private XML Storage - 7
type PrivateXMLStorage struct {
XMLName xml.Name `xml:"jabber:iq:private query"`
Body []byte `xml:",innerxml"`
}

21
xmpp/iq/register.go Normal file
View File

@ -0,0 +1,21 @@
package xmppiq
import (
"encoding/xml"
)
// WARNING WIP
// Register implements XEP-0077: In-Band Registration - 14.1 jabber:iq:register
//TODO
type Register struct {
XMLName xml.Name `xml:"jabber:iq:register query"`
Instructions string `xml:"instructions"`
Username string `xml:"username"`
Password string `xml:"password"`
}
// FeatureRegister implements XEP-0077: In-Band Registration - 14.2 Stream Feature
type FeatureRegister struct {
XMLName xml.Name `xml:"http://jabber.org/features/iq-register register"`
}

View File

@ -6,37 +6,37 @@ import (
"dev.sum7.eu/genofire/yaja/xmpp/base" "dev.sum7.eu/genofire/yaja/xmpp/base"
) )
// IQDiscoQueryInfo implements XEP 0030: Service Discovery - 11.1 disco#info // DiscoQueryInfo implements XEP 0030: Service Discovery - 11.1 disco#info
type IQDiscoQueryInfo struct { type DiscoQueryInfo struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"` XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"`
Node *string `xml:"node,attr"` Node *string `xml:"node,attr"`
Identities []*IQDiscoIdentity Identities []*DiscoIdentity
Features []*IQDiscoFeature Features []*DiscoFeature
} }
// IQDiscoIdentity implements XEP 0030: Service Discovery - 11.1 disco#info // DiscoIdentity implements XEP 0030: Service Discovery - 11.1 disco#info
type IQDiscoIdentity struct { type DiscoIdentity struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info identity"` XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info identity"`
Category string `xml:"category"` //required Category string `xml:"category"` //required
Name *string `xml:"name"` Name *string `xml:"name"`
Type string `xml:"type"` //required Type string `xml:"type"` //required
} }
// IQDiscoFeature implements XEP 0030: Service Discovery - 11.1 disco#info // DiscoFeature implements XEP 0030: Service Discovery - 11.1 disco#info
type IQDiscoFeature struct { type DiscoFeature struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info feature"` XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info feature"`
Var string `xml:"var"` //required Var string `xml:"var"` //required
} }
// IQDiscoQueryItem implements XEP 0030: Service Discovery - 11.2 disco#items // DiscoQueryItem implements XEP 0030: Service Discovery - 11.2 disco#items
type IQDiscoQueryItem struct { type DiscoQueryItem struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"` XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"`
Node *string `xml:"node,attr"` Node *string `xml:"node,attr"`
Items []*IQDiscoItem Items []*DiscoItem
} }
// IQDiscoItem implements XEP 0030: Service Discovery - 11.2 disco#items // DiscoItem implements XEP 0030: Service Discovery - 11.2 disco#items
type IQDiscoItem struct { type DiscoItem struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items item"` XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items item"`
JID *xmppbase.JID `xml:"jid"` JID *xmppbase.JID `xml:"jid"`
Node *string `xml:"node"` Node *string `xml:"node"`

14
xmpp/iq/vcard.go Normal file
View File

@ -0,0 +1,14 @@
package xmppiq
import (
"encoding/xml"
)
// WARNING WIP
// VCard implements XEP-0054: vcard-temp - 14
//TODO
type VCard struct {
XMLName xml.Name `xml:"vcard-temp vCard"`
Body []byte `xml:",innerxml"`
}

13
xmpp/iq/version.go Normal file
View File

@ -0,0 +1,13 @@
package xmppiq
import (
"encoding/xml"
)
// Version implements XEP-0092: Software Version - 4
type Version struct {
XMLName xml.Name `xml:"jabber:iq:version query"`
Name string `xml:"name"` //required
Version string `xml:"version"` //required
OS *string `xml:"os"`
}

View File

@ -1,19 +0,0 @@
package xmppiq
import (
"encoding/xml"
)
// which XEP ????
// where to put: (server part debug? is it part)
type IQPrivateQuery struct {
XMLName xml.Name `xml:"jabber:iq:private query"`
Body []byte `xml:",innerxml"`
}
type IQPrivateRegister struct {
XMLName xml.Name `xml:"jabber:iq:register query"`
Instructions string `xml:"instructions"`
Username string `xml:"username"`
Password string `xml:"password"`
}

11
xmpp/wip.go Normal file
View File

@ -0,0 +1,11 @@
package xmpp
const (
// NSDiscoOfflineMessages implements XEP-0160: Best Practices for Handling Offline Messages - 7
//TODO where to put??
NSDiscoOfflineMessages = "msgoffline"
// NSDiscoSocks5Bytestreams implements XEP-0065: SOCKS5 Bytestreams - 14
//TODO where to put WIP iq implemention
NSDiscoSocks5Bytestreams = "http://jabber.org/protocol/bytestreams"
)