diff --git a/README.md b/README.md index 4096519..fd5e360 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,9 @@ all implementation of all comman (RFCs and XEPs) xml element **Version** -- [RFC 6120 (XMPP - Core)](https://xmpp.org/rfcs/rfc3920.html) -- [XEP 0030: Service Discovery](https://xmpp.org/extensions/xep-0030.html) +- [RFC 6120 (XMPP - Core)](https://xmpp.org/rfcs/rfc6120.html) +- [RFC 6121 (XMPP - Instant Messaging and Presence)](https://xmpp.org/rfcs/rfc6121.html) +- [XEP-0030: Service Discovery](https://xmpp.org/extensions/xep-0030.html) - [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) diff --git a/xmpp/base/jid.go b/xmpp/base/jid.go index d1e318e..b6a193d 100644 --- a/xmpp/base/jid.go +++ b/xmpp/base/jid.go @@ -11,7 +11,7 @@ func init() { jidRegex = regexp.MustCompile(`^(?:([^@/<>'\" ]+)@)?([^@/<>'\"]+)(?:/([^<>'\" ][^<>'\"]*))?$`) } -// JID implements RFC6122: XMPP - Address Format +// JID implements RFC 6122: XMPP - Address Format type JID struct { Local string Domain string diff --git a/xmpp/base/jid_test.go b/xmpp/base/jid_test.go index a99d28e..a34a6c3 100644 --- a/xmpp/base/jid_test.go +++ b/xmpp/base/jid_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" ) -// Test Values for NewJID from RFC7622 +// Test Values for NewJID from RFC 7622 // https://tools.ietf.org/html/rfc7622 func TestNewJID(t *testing.T) { assert := assert.New(t) diff --git a/xmpp/client_error.go b/xmpp/client_error.go index 6168539..98365b7 100644 --- a/xmpp/client_error.go +++ b/xmpp/client_error.go @@ -9,8 +9,7 @@ type ErrorClient struct { Type ErrorType `xml:"type,attr"` // required Text *Text - // RFC 6120 A.8 Resource binding namespace - StanzaErrorGroup + StanzaErrorGroup // RFC 6120: A.8 Resource binding namespace // Any hasn't matched element Other []XMLElement `xml:",any"` diff --git a/xmpp/client_iq.go b/xmpp/client_iq.go index feaa07c..0548231 100644 --- a/xmpp/client_iq.go +++ b/xmpp/client_iq.go @@ -16,7 +16,8 @@ type IQClient struct { Type IQType `xml:"type,attr"` // required 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?) + Roster *xmppiq.RosterQuery // RFC 6121: Appendix D. DiscoQueryInfo *xmppiq.DiscoQueryInfo // XEP-0030: XMPP Service Discovery (see iq/service_discovery.go) DiscoQueryItem *xmppiq.DiscoQueryItem // XEP-0030: XMPP Service Discovery (see iq/service_discovery.go) PrivateXMLStorage *xmppiq.PrivateXMLStorage // XEP-0049: Private XML Storage (see iq/private_xml_storage.go) diff --git a/xmpp/connection.go b/xmpp/connection.go index 9758622..611b976 100644 --- a/xmpp/connection.go +++ b/xmpp/connection.go @@ -10,7 +10,7 @@ import ( type StreamFeatures struct { XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"` StartTLS *TLSStartTLS - Mechanisms SASLMechanisms // RFC 6120 - A.4 SASL Namespace (see sasl.go) + Mechanisms SASLMechanisms // RFC 6120: A.4 SASL Namespace (see sasl.go) Compression *CompressionFeature // XEP-0138: Stream Compression (see compression.go) Bind *Bind Session bool @@ -32,7 +32,7 @@ type TLSFailure struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"` } -// Bind implements RFC 6120 A.7 Resource binding namespace +// Bind implements RFC 6120 - A.7 Resource binding namespace type Bind struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"` Resource string `xml:"resource"` diff --git a/xmpp/enum_error.go b/xmpp/enum_error.go index 2da169c..b89b925 100644 --- a/xmpp/enum_error.go +++ b/xmpp/enum_error.go @@ -3,7 +3,7 @@ package xmpp // ErrorType is a Enum of error attribute type type ErrorType string -// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace +// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace const ( ErrorTypeAuth ErrorType = "auth" ErrorTypeCancel ErrorType = "cancel" diff --git a/xmpp/enum_iq.go b/xmpp/enum_iq.go index 27fe528..30a64b7 100644 --- a/xmpp/enum_iq.go +++ b/xmpp/enum_iq.go @@ -3,7 +3,7 @@ package xmpp // IQType is a Enum of iq attribute type type IQType string -// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace +// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace const ( IQTypeError IQType = "error" IQTypeGet IQType = "get" diff --git a/xmpp/enum_message.go b/xmpp/enum_message.go index 49125bb..b8e2fc4 100644 --- a/xmpp/enum_message.go +++ b/xmpp/enum_message.go @@ -3,7 +3,7 @@ package xmpp // MessageType is a Enum of message attribute type type MessageType string -// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace +// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace const ( MessageTypeChat MessageType = "chat" MessageTypeError MessageType = "error" diff --git a/xmpp/enum_presence.go b/xmpp/enum_presence.go index bb5fb6a..1f7aba3 100644 --- a/xmpp/enum_presence.go +++ b/xmpp/enum_presence.go @@ -3,7 +3,7 @@ package xmpp // PresenceType is a Enum of presence attribute type type PresenceType string -// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace +// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace const ( PresenceTypeError PresenceType = "error" PresenceTypeProbe PresenceType = "probe" @@ -17,7 +17,7 @@ const ( // PresenceShow is a Enum of presence element show type PresenceShow string -// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace +// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace const ( PresenceShowAway PresenceShow = "away" PresenceShowChat PresenceShow = "chat" diff --git a/xmpp/error_stanze.go b/xmpp/error_stanze.go index 64e2d32..341c973 100644 --- a/xmpp/error_stanze.go +++ b/xmpp/error_stanze.go @@ -2,7 +2,7 @@ package xmpp import "encoding/xml" -// StanzaErrorGroup implements RFC 6120 A.8 Resource binding namespace +// StanzaErrorGroup implements RFC 6120 - A.8 Resource binding namespace type StanzaErrorGroup struct { BadRequest *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas bad-request"` Conflict *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas conflict"` diff --git a/xmpp/error_stream.go b/xmpp/error_stream.go index 3a47325..f6f9f5b 100644 --- a/xmpp/error_stream.go +++ b/xmpp/error_stream.go @@ -2,7 +2,7 @@ package xmpp import "encoding/xml" -// StreamErrorGroup implements RFC 6120 A.2 Stream Error Namespace +// StreamErrorGroup implements RFC 6120 - A.2 Stream Error Namespace type StreamErrorGroup struct { BadFormat *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams bad-format"` BadNamespacePrefix *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams bad-namespace-prefix"` @@ -31,7 +31,7 @@ type StreamErrorGroup struct { UnsupportedVersion *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-version"` } -// StreamError implements RFC 6120 A.2 Stream Error Namespace +// StreamError implements RFC 6120 - A.2 Stream Error Namespace type StreamError struct { XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"` Text *Text diff --git a/xmpp/global.go b/xmpp/global.go index e99ff27..e97966a 100644 --- a/xmpp/global.go +++ b/xmpp/global.go @@ -2,7 +2,7 @@ package xmpp import "encoding/xml" -// Text implements RFC 6120 part of A.2 Stream Error Namespace, A.4 SASL Namespace and A.8 Stanza Error Namespace +// Text implements RFC 6120 - part of A.2 Stream Error Namespace, A.4 SASL Namespace and A.8 Stanza Error Namespace type Text struct { // `xml:"urn:ietf:params:xml:ns:xmpp-streams text"` // `xml:"urn:ietf:params:xml:ns:xmpp-sasl text"` diff --git a/xmpp/iq/namespaces.go b/xmpp/iq/namespaces.go index 2040f10..b26aece 100644 --- a/xmpp/iq/namespaces.go +++ b/xmpp/iq/namespaces.go @@ -1,10 +1,10 @@ package xmppiq const ( - // NSDiscoInfo implements XEP 0030: Service Discovery - 11.1 disco#info + // NSDiscoInfo implements XEP-0030: Service Discovery - 11.1 disco#info NSDiscoInfo = "http://jabber.org/protocol/disco#info" - // NSDiscoItems implements XEP 0030: Service Discovery - 11.2 disco#items + // NSDiscoItems implements XEP-0030: Service Discovery - 11.2 disco#items NSDiscoItems = "http://jabber.org/protocol/disco#items" // NSPrivateXMLStorage implements XEP-0049: Private XML Storage - 7 diff --git a/xmpp/iq/roster.go b/xmpp/iq/roster.go new file mode 100644 index 0000000..9c526a4 --- /dev/null +++ b/xmpp/iq/roster.go @@ -0,0 +1,45 @@ +package xmppiq + +import ( + "encoding/xml" + + "dev.sum7.eu/genofire/yaja/xmpp/base" +) + +// RosterQuery implements RFC 6121 - Appendix D. XML Schema for jabber:iq:roster +type RosterQuery struct { + XMLName xml.Name `xml:"jabber:iq:roster query"` + Version string `xml:"ver,attr,omitempty"` + Items []RosterItem `xml:"item"` +} + +// RosterAskType is a Enum of item attribute ask +type RosterAskType string + +// RFC 6121: Appendix D. XML Schema for jabber:iq:roster +const ( + RosterAskSubscribe RosterAskType = "subscribe" + RosterAskNone RosterAskType = "" +) + +// RosterAskType is a Enum of item attribute subscription +type RosterSubscriptionType string + +// RFC 6121: Appendix D. XML Schema for jabber:iq:roster +const ( + RosterSubscriptionBoth RosterSubscriptionType = "both" + RosterSubscriptionFrom RosterSubscriptionType = "from" + RosterSubscriptionNone RosterSubscriptionType = "none" + RosterSubscriptionRemove RosterSubscriptionType = "remove" + RosterSubscriptionTo RosterSubscriptionType = "to" +) + +// RosterItem implements RFC 6121 - Appendix D. XML Schema for jabber:iq:roster +type RosterItem struct { + JID *xmppbase.JID `xml:"jid,attr"` + Approved *bool `xml:"approved,attr,omitempty"` + Ask RosterAskType `xml:"ask,attr,omitempty"` + Name string `xml:"name,attr,omitempty"` + Subscription RosterSubscriptionType `xml:"subscription,attr"` + Group []string `xml:"group"` +} diff --git a/xmpp/iq/service_discovery.go b/xmpp/iq/service_discovery.go index 593852e..49ec174 100644 --- a/xmpp/iq/service_discovery.go +++ b/xmpp/iq/service_discovery.go @@ -6,7 +6,7 @@ import ( "dev.sum7.eu/genofire/yaja/xmpp/base" ) -// DiscoQueryInfo implements XEP 0030: Service Discovery - 11.1 disco#info +// DiscoQueryInfo implements XEP-0030: Service Discovery - 11.1 disco#info type DiscoQueryInfo struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"` Node string `xml:"node,attr,omitempty"` @@ -14,7 +14,7 @@ type DiscoQueryInfo struct { Features []*DiscoFeature } -// DiscoIdentity implements XEP 0030: Service Discovery - 11.1 disco#info +// DiscoIdentity implements XEP-0030: Service Discovery - 11.1 disco#info type DiscoIdentity struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info identity"` Category string `xml:"category"` //required @@ -22,20 +22,20 @@ type DiscoIdentity struct { Type string `xml:"type"` //required } -// DiscoFeature implements XEP 0030: Service Discovery - 11.1 disco#info +// DiscoFeature implements XEP-0030: Service Discovery - 11.1 disco#info type DiscoFeature struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info feature"` Var string `xml:"var"` //required } -// DiscoQueryItem implements XEP 0030: Service Discovery - 11.2 disco#items +// DiscoQueryItem implements XEP-0030: Service Discovery - 11.2 disco#items type DiscoQueryItem struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"` Node string `xml:"node,attr,omitempty"` Items []*DiscoItem } -// DiscoItem implements XEP 0030: Service Discovery - 11.2 disco#items +// DiscoItem implements XEP-0030: Service Discovery - 11.2 disco#items type DiscoItem struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items item"` JID *xmppbase.JID `xml:"jid"` diff --git a/xmpp/roster.go b/xmpp/roster.go deleted file mode 100644 index ecee152..0000000 --- a/xmpp/roster.go +++ /dev/null @@ -1,21 +0,0 @@ -package xmpp - -import ( - "encoding/xml" - - "dev.sum7.eu/genofire/yaja/xmpp/base" -) - -// ClientQuery implements which XEP ???? -type ClientQuery struct { - Item []RosterItem -} - -// RosterItem implements which XEP ???? -type RosterItem struct { - XMLName xml.Name `xml:"jabber:iq:roster item"` - JID *xmppbase.JID `xml:",attr"` - Name string `xml:",attr"` - Subscription string `xml:",attr"` - Group []string -} diff --git a/xmpp/server_error.go b/xmpp/server_error.go index 258c925..297dea3 100644 --- a/xmpp/server_error.go +++ b/xmpp/server_error.go @@ -9,8 +9,7 @@ type ErrorServer struct { Type ErrorType `xml:"type,attr"` // required Text *Text - // RFC 6120 A.8 Resource binding namespace - StanzaErrorGroup + StanzaErrorGroup // RFC 6120: A.8 - Resource binding namespace // Any hasn't matched element Other []XMLElement `xml:",any"` diff --git a/xmpp/server_iq.go b/xmpp/server_iq.go index 81ddcac..6acdc41 100644 --- a/xmpp/server_iq.go +++ b/xmpp/server_iq.go @@ -16,7 +16,7 @@ type IQServer struct { Type IQType `xml:"type,attr"` // required Error *ErrorServer - 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) // Any hasn't matched element