sum7
/
yaja
Archived
1
0
Fork 0

messages after RFC 6120 completed

This commit is contained in:
Martin/Geno 2018-02-13 20:05:18 +01:00
parent 4d4a201b1a
commit 81c8605477
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
52 changed files with 573 additions and 309 deletions

View File

@ -94,7 +94,10 @@ func (client *Client) auth(password string) error {
}
fail := messages.SASLFailure{}
if err := client.Decode(&fail, element); err == nil {
return errors.New(messages.XMLChildrenString(fail) + " : " + fail.Body)
if txt := fail.Text; txt != nil {
return errors.New(messages.XMLChildrenString(fail) + " : " + txt.Body)
}
return errors.New(messages.XMLChildrenString(fail))
}
if err := client.Decode(&messages.SASLSuccess{}, element); err != nil {
return errors.New("auth failed - with unexpected answer")

View File

@ -10,7 +10,7 @@ import (
log "github.com/sirupsen/logrus"
"dev.sum7.eu/genofire/yaja/model"
"dev.sum7.eu/genofire/yaja/messages"
)
// Client holds XMPP connection opitons
@ -23,10 +23,17 @@ type Client struct {
Logging *log.Logger
JID *model.JID
JID *messages.JID
reply map[string]chan *messages.IQClient
skipError bool
iq chan *messages.IQClient
presence chan *messages.PresenceClient
mesage chan *messages.MessageClient
}
func NewClient(jid *model.JID, password string) (*Client, error) {
func NewClient(jid *messages.JID, password string) (*Client, error) {
client := &Client{
Protocol: "tcp",
JID: jid,

View File

@ -99,7 +99,7 @@ func (client *Client) connect(password string) error {
}
if err := client.Send(&messages.IQClient{
Type: messages.IQTypeSet,
To: model.NewJID(client.JID.Domain),
To: messages.NewJID(client.JID.Domain),
Bind: bind,
}); err != nil {
return err

97
client/start.go Normal file
View File

@ -0,0 +1,97 @@
package client
import (
"fmt"
"dev.sum7.eu/genofire/yaja/messages"
)
var DefaultChannelSize = 30
func (client *Client) Start() error {
client.iq = make(chan *messages.IQClient, DefaultChannelSize)
client.presence = make(chan *messages.PresenceClient, DefaultChannelSize)
client.mesage = make(chan *messages.MessageClient, DefaultChannelSize)
client.reply = make(map[string]chan *messages.IQClient)
for {
element, err := client.Read()
if err != nil {
return err
}
errMSG := &messages.StreamError{}
err = client.Decode(errMSG, element)
if err == nil {
return fmt.Errorf("recv stream error: %s: %s -> %s", errMSG.Text, messages.XMLChildrenString(errMSG.StreamErrorGroup), messages.XMLChildrenString(errMSG.Other))
}
iq := &messages.IQClient{}
err = client.Decode(iq, element)
if err == nil {
if iq.Ping != nil {
client.Logging.Debug("answer ping")
iq.Type = messages.IQTypeResult
iq.To = iq.From
iq.From = client.JID
client.Send(iq)
} else {
if client.skipError && iq.Error != nil {
continue
}
if ch, ok := client.reply[iq.ID]; ok {
delete(client.reply, iq.ID)
ch <- iq
continue
}
client.iq <- iq
}
continue
}
pres := &messages.PresenceClient{}
err = client.Decode(pres, element)
if err == nil {
if client.skipError && pres.Error != nil {
continue
}
client.presence <- pres
continue
}
msg := &messages.MessageClient{}
err = client.Decode(msg, element)
if err == nil {
if client.skipError && msg.Error != nil {
continue
}
client.mesage <- msg
continue
}
client.Logging.Warnf("unsupport xml recv: %v", element)
}
}
func (client *Client) SendRecv(iq *messages.IQClient) *messages.IQClient {
if iq.ID == "" {
iq.ID = messages.CreateCookieString()
}
ch := make(chan *messages.IQClient, 1)
client.reply[iq.ID] = ch
client.Send(iq)
defer close(ch)
return <-ch
}
func (client *Client) RecvIQ() *messages.IQClient {
return <-client.iq
}
func (client *Client) RecvPresence() *messages.PresenceClient {
return <-client.presence
}
func (client *Client) RecvMessage() *messages.MessageClient {
return <-client.mesage
}

View File

@ -1,9 +1,9 @@
package tester
import "dev.sum7.eu/genofire/yaja/model"
import "dev.sum7.eu/genofire/yaja/messages"
type Account struct {
JID *model.JID `json:"jid"`
JID *messages.JID `json:"jid"`
Password string `json:"password"`
Admins map[string]interface{} `json:"admins"`
}

View File

@ -7,7 +7,6 @@ import (
log "github.com/sirupsen/logrus"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
)
func (t *Tester) StartBot(status *Status) {
@ -141,15 +140,15 @@ func (t *Tester) StartBot(status *Status) {
}
}
}
func botAllowed(list []*model.JID, toConvert map[string]interface{}) []*model.JID {
func botAllowed(list []*messages.JID, toConvert map[string]interface{}) []*messages.JID {
alist := list
for jid, _ := range toConvert {
alist = append(alist, model.NewJID(jid))
alist = append(alist, messages.NewJID(jid))
}
return alist
}
func botAdmin(cmd []string, log *log.Entry, status *Status, from *model.JID, allowed []*model.JID) {
func botAdmin(cmd []string, log *log.Entry, status *Status, from *messages.JID, allowed []*messages.JID) {
msg := ""
if len(cmd) == 2 {
isAdmin := false

View File

@ -1,7 +1,7 @@
package tester
import (
"dev.sum7.eu/genofire/yaja/model"
"dev.sum7.eu/genofire/yaja/messages"
"github.com/FreifunkBremen/yanic/lib/duration"
log "github.com/sirupsen/logrus"
)
@ -15,9 +15,9 @@ type Config struct {
LoggingBots log.Level `toml:"logging_bots"`
Timeout duration.Duration `toml:"timeout"`
Interval duration.Duration `toml:"interval"`
Admins []*model.JID `toml:"admins"`
Admins []*messages.JID `toml:"admins"`
Client struct {
JID *model.JID `toml:"jid"`
Password string `toml:"password"`
JID *messages.JID `toml:"jid"`
Password string `toml:"password"`
} `toml:"client"`
}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"dev.sum7.eu/genofire/yaja/model"
"dev.sum7.eu/genofire/yaja/messages"
"github.com/FreifunkBremen/yanic/lib/jsontime"
)
@ -53,7 +53,7 @@ func (t *Tester) Output() *Output {
}
continue
}
toJID := model.NewJID(to)
toJID := messages.NewJID(to)
link := &Link{
Source: status.JID.Domain,
SourceJID: status.JID.Bare(),

View File

@ -7,14 +7,13 @@ import (
"dev.sum7.eu/genofire/yaja/client"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
)
type Status struct {
backupClient *client.Client
client *client.Client
account *Account
JID *model.JID `json:"jid"`
JID *messages.JID `json:"jid"`
Domain string `json:"domain"`
Login bool `json:"is_online"`
MessageForConnection map[string]string `json:"-"`
@ -41,7 +40,7 @@ func (s *Status) Disconnect(reason string) {
Body: fmt.Sprintf("you recieve a notify that '%s' disconnect: %s", s.JID.Full(), reason),
}
for jid, _ := range s.account.Admins {
msg.To = model.NewJID(jid)
msg.To = messages.NewJID(jid)
if err := s.backupClient.Send(msg); err != nil {
s.client.Send(msg)
}
@ -59,7 +58,7 @@ func (s *Status) Update(timeout time.Duration) {
}
c := &client.Client{
JID: model.NewJID(s.account.JID.Bare()),
JID: messages.NewJID(s.account.JID.Bare()),
Protocol: "tcp4",
Logging: s.client.Logging,
Timeout: timeout / 2,
@ -72,7 +71,7 @@ func (s *Status) Update(timeout time.Duration) {
s.IPv4 = false
}
c.JID = model.NewJID(s.account.JID.Bare())
c.JID = messages.NewJID(s.account.JID.Bare())
c.Protocol = "tcp6"
if err := c.Connect(s.account.Password); err == nil {

View File

@ -8,7 +8,6 @@ import (
"dev.sum7.eu/genofire/yaja/client"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
)
type Tester struct {
@ -17,9 +16,9 @@ type Tester struct {
Accounts map[string]*Account `json:"accounts"`
Status map[string]*Status `json:"-"`
mux sync.Mutex
LoggingClients *log.Logger `json:"-"`
LoggingBots log.Level `json:"-"`
Admins []*model.JID `json:"-"`
LoggingClients *log.Logger `json:"-"`
LoggingBots log.Level `json:"-"`
Admins []*messages.JID `json:"-"`
}
func NewTester() *Tester {
@ -89,7 +88,7 @@ func (t *Tester) Connect(acc *Account) {
}
}
func (t *Tester) UpdateConnectionStatus(from, to *model.JID, recvmsg string) {
func (t *Tester) UpdateConnectionStatus(from, to *messages.JID, recvmsg string) {
logCTX := log.WithFields(log.Fields{
"jid": to.Full(),
"from": from.Full(),

View File

@ -4,6 +4,7 @@ import (
"errors"
"sync"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
log "github.com/sirupsen/logrus"
)
@ -48,7 +49,7 @@ func (s *State) AddAccount(a *model.Account) error {
return errors.New("no give domain")
}
func (s *State) Authenticate(jid *model.JID, password string) (bool, error) {
func (s *State) Authenticate(jid *messages.JID, password string) (bool, error) {
logger := log.WithField("database", "auth")
if domain, ok := s.Domains[jid.Domain]; ok {
@ -67,7 +68,7 @@ func (s *State) Authenticate(jid *model.JID, password string) (bool, error) {
return false, nil
}
func (s *State) GetAccount(jid *model.JID) *model.Account {
func (s *State) GetAccount(jid *messages.JID) *model.Account {
logger := log.WithField("database", "get")
if domain, ok := s.Domains[jid.Domain]; ok {

17
messages/client_error.go Normal file
View File

@ -0,0 +1,17 @@
package messages
import "encoding/xml"
// RFC 6120 - A.5 Client Namespace (a part)
type ErrorClient struct {
XMLName xml.Name `xml:"jabber:client error"`
Code string `xml:"code,attr,omitempty"`
Type ErrorType `xml:"type,attr"` // required
Text *Text
// RFC 6120 A.8 Resource binding namespace
StanzaErrorGroup
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

23
messages/client_iq.go Normal file
View File

@ -0,0 +1,23 @@
package messages
import (
"encoding/xml"
)
// RFC 6120 - A.5 Client Namespace (a part)
type IQClient struct {
XMLName xml.Name `xml:"jabber:client iq"`
From *JID `xml:"from,attr,omitempty"`
ID string `xml:"id,attr"` // required
To *JID `xml:"to,attr,omitempty"`
Type IQType `xml:"type,attr"` // required
Error *ErrorClient
Bind *Bind // which XEP ?
Ping *Ping // which XEP ?
PrivateQuery *IQPrivateQuery // which XEP ?
PrivateRegister *IQPrivateRegister // which XEP ?
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

View File

@ -0,0 +1,25 @@
package messages
import (
"encoding/xml"
)
// RFC 6120 - A.5 Client Namespace (a part)
type MessageClient struct {
XMLName xml.Name `xml:"jabber:client message"`
From *JID `xml:"from,attr,omitempty"`
ID string `xml:"id,attr,omitempty"`
To *JID `xml:"to,attr,omitempty"`
Type MessageType `xml:"type,attr,omitempty"` // default: normal
Lang string `xml:"lang,attr,omitempty"`
Subject string `xml:"subject,omitempty"`
Body string `xml:"body,omitempty"`
Thread string `xml:"thread,omitempty"`
Error *ErrorClient
Delay *Delay `xml:"delay"` // which XEP ?
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

View File

@ -0,0 +1,29 @@
package messages
import (
"encoding/xml"
)
// RFC 6120 - A.5 Client Namespace (a part)
type PresenceClient struct {
XMLName xml.Name `xml:"jabber:client presence"`
From *JID `xml:"from,attr,omitempty"`
ID string `xml:"id,attr,omitempty"`
To *JID `xml:"to,attr,omitempty"`
Type PresenceType `xml:"type,attr,omitempty"`
Lang string `xml:"lang,attr,omitempty"`
Show PresenceShow `xml:"show,omitempty"`
Status string `xml:"status,omitempty"`
Priority uint `xml:"priority,omitempty"` // default: 0
Error *ErrorClient
Delay *Delay `xml:"delay"` // which XEP ?
// which XEP ?
// Caps *ClientCaps `xml:"c"`
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

View File

@ -2,11 +2,9 @@ package messages
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/model"
)
// RFC 3920 C.1 Streams name space
// RFC 6120 - A.1 Stream Namespace
type StreamFeatures struct {
XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"`
StartTLS *TLSStartTLS
@ -15,23 +13,25 @@ type StreamFeatures struct {
Session bool
}
// RFC 3920 C.3 TLS name space
// RFC 6120 - A.3 StartTLS Namespace
type TLSStartTLS struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls starttls"`
Required *string `xml:"required"`
}
type TLSFailure struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"`
}
// RFC 6120 - A.3 StartTLS Namespace
type TLSProceed struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls proceed"`
}
// RFC 3920 C.5 Resource binding name space
type Bind struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
Resource string `xml:"resource"`
JID *model.JID `xml:"jid"`
// RFC 6120 - A.3 StartTLS Namespace
type TLSFailure struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"`
}
// 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"`
JID *JID `xml:"jid"`
}

12
messages/enum_error.go Normal file
View File

@ -0,0 +1,12 @@
package messages
type ErrorType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
const (
ErrorTypeAuth ErrorType = "auth"
ErrorTypeCancel ErrorType = "cancel"
ErrorTypeContinue ErrorType = "continue"
ErrorTypeModify ErrorType = "motify"
ErrorTypeWait ErrorType = "wait"
)

11
messages/enum_iq.go Normal file
View File

@ -0,0 +1,11 @@
package messages
type IQType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
const (
IQTypeError IQType = "error"
IQTypeGet IQType = "get"
IQTypeResult IQType = "result"
IQTypeSet IQType = "set"
)

12
messages/enum_message.go Normal file
View File

@ -0,0 +1,12 @@
package messages
type MessageType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
const (
MessageTypeChat MessageType = "chat"
MessageTypeError MessageType = "error"
MessageTypeGroupchat MessageType = "groupchat"
MessageTypeHeadline MessageType = "headline"
MessageTypeNormal MessageType = "normal"
)

24
messages/enum_presence.go Normal file
View File

@ -0,0 +1,24 @@
package messages
type PresenceType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
const (
PresenceTypeError PresenceType = "error"
PresenceTypeProbe PresenceType = "probe"
PresenceTypeSubscribe PresenceType = "subscribe"
PresenceTypeSubscribed PresenceType = "subscribed"
PresenceTypeUnavailable PresenceType = "unavailable"
PresenceTypeUnsubscribe PresenceType = "unsubscribe"
PresenceTypeUnsubscribed PresenceType = "unsubscribed"
)
type PresenceShow string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
const (
PresenceShowAway PresenceShow = "away"
PresenceShowChat PresenceShow = "chat"
PresenceShowDND PresenceShow = "dnd"
PresenceShowXA PresenceShow = "xa"
)

View File

@ -1,83 +0,0 @@
package messages
import "encoding/xml"
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"`
Conflict *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams conflict"`
ConnectionTimeout *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams connection-timeout"`
HostGone *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams host-gone"`
HostUnknown *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams host-unknown"`
ImproperAddressing *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams improper-addressing"`
InternalServerError *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams internal-server-error"`
InvalidFrom *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-from"`
InvalidID *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-id"`
InvalidNamespace *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-namespace"`
InvalidXML *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-xml"`
NotAuthorized *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams not-authorized"`
NotWellFormed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams not-well-formed"`
PolicyViolation *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams policy-violation"`
RemoteConnectionFailed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams remote-connection-failed"`
Reset *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams reset"`
ResourceConstraint *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams resource-constraint"`
RestrictedXML *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams restricted-xml"`
SeeOtherHost string `xml:"urn:ietf:params:xml:ns:xmpp-streams see-other-host"`
SystemShutdown *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams system-shutdown"`
UndefinedCondition *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams undefined-condition"`
UnsupportedEncoding *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-encoding"`
UnsupportedStanzaType *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-stanza-type"`
UnsupportedVersion *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-version"`
}
type StreamError struct {
XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"`
Text string `xml:"urn:ietf:params:xml:ns:xmpp-streams text"`
Other []XMLElement `xml:",any"`
StreamErrorGroup
}
type ErrorClientType string
const (
ErrorClientTypeAuth ErrorClientType = "auth"
ErrorClientTypeCancel ErrorClientType = "cancel"
ErrorClientTypeContinue ErrorClientType = "continue"
ErrorClientTypeModify ErrorClientType = "motify"
ErrorClientTypeWait ErrorClientType = "wait"
)
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"`
FeatureNotImplemented *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas feature-not-implemented"`
Forbidden *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas forbidden"`
Gone string `xml:"urn:ietf:params:xml:ns:xmpp-stanzas gone"`
InternalServerError *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas internal-server-error"`
ItemNotFound *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas item-not-found"`
JIDMalformed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas jid-malformed"`
NotAcceptable *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-acceptable"`
NotAllowed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-allowed"`
NotAuthorized *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-authorized"`
PolicyViolation *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas policy-violation"`
RecipientUnavailable *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas recipient-unavailable"`
Redirect string `xml:"urn:ietf:params:xml:ns:xmpp-stanzas redirect"`
RegistrationRequired *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas registration-required"`
RemoteServerNotFound *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas remote-server-not-found"`
RemoteServerTimeout *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas remote-server-timeout"`
ResourceConstraint *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas resource-constraint"`
ServiceUnavailable *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas service-unavailable"`
SubscriptionRequired *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas subscription-required"`
UndefinedCondition *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas undefined-condition"`
UnexpectedRequest *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas unexpected-request"`
}
// ErrorClient element
type ErrorClient struct {
XMLName xml.Name `xml:"jabber:client error"`
Code string `xml:"code,attr"`
Type ErrorClientType `xml:"type,attr"`
Text string `xml:"text"`
Other []XMLElement `xml:",any"`
StanzaErrorGroup
}

32
messages/error_stanze.go Normal file
View File

@ -0,0 +1,32 @@
package messages
import "encoding/xml"
// 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"`
FeatureNotImplemented *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas feature-not-implemented"`
Forbidden *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas forbidden"`
Gone string `xml:"urn:ietf:params:xml:ns:xmpp-stanzas gone"`
InternalServerError *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas internal-server-error"`
ItemNotFound *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas item-not-found"`
JIDMalformed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas jid-malformed"`
NotAcceptable *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-acceptable"`
NotAllowed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-allowed"`
NotAuthorized *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-authorized"`
PolicyViolation *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas policy-violation"`
RecipientUnavailable *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas recipient-unavailable"`
Redirect string `xml:"urn:ietf:params:xml:ns:xmpp-stanzas redirect"`
RegistrationRequired *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas registration-required"`
RemoteServerNotFound *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas remote-server-not-found"`
RemoteServerTimeout *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas remote-server-timeout"`
ResourceConstraint *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas resource-constraint"`
ServiceUnavailable *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas service-unavailable"`
SubscriptionRequired *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas subscription-required"`
UndefinedCondition *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas undefined-condition"`
UnexpectedRequest *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas unexpected-request"`
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

42
messages/error_stream.go Normal file
View File

@ -0,0 +1,42 @@
package messages
import "encoding/xml"
// 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"`
Conflict *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams conflict"`
ConnectionTimeout *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams connection-timeout"`
HostGone *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams host-gone"`
HostUnknown *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams host-unknown"`
ImproperAddressing *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams improper-addressing"`
InternalServerError *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams internal-server-error"`
InvalidFrom *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-from"`
InvalidID *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-id"`
InvalidNamespace *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-namespace"`
InvalidXML *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-xml"`
NotAuthorized *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams not-authorized"`
NotWellFormed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams not-well-formed"`
PolicyViolation *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams policy-violation"`
RemoteConnectionFailed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams remote-connection-failed"`
Reset *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams reset"`
ResourceConstraint *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams resource-constraint"`
RestrictedXML *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams restricted-xml"`
SeeOtherHost string `xml:"urn:ietf:params:xml:ns:xmpp-streams see-other-host"`
SystemShutdown *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams system-shutdown"`
UndefinedCondition *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams undefined-condition"`
UnsupportedEncoding *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-encoding"`
UnsupportedStanzaType *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-stanza-type"`
UnsupportedVersion *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-version"`
}
// RFC 6120 A.2 Stream Error Namespace
type StreamError struct {
XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"`
Text *Text
StreamErrorGroup
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

24
messages/global.go Normal file
View File

@ -0,0 +1,24 @@
package messages
import "encoding/xml"
// 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"`
// `xml:"urn:ietf:params:xml:ns:xmpp-stanzas text"`
XMLName xml.Name `xml:"text"`
Lang string `xml:"lang,attr,omitempty"`
Body string `xml:",innerxml"`
}
// Fallback - any hasn't matched element
type XMLElement struct {
XMLName xml.Name
InnerXML string `xml:",innerxml"`
}
// which XEP ?
type Delay struct {
Stamp string `xml:"stamp,attr"`
}

View File

@ -1,48 +0,0 @@
package messages
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/model"
)
type IQType string
const (
IQTypeGet IQType = "get"
IQTypeSet IQType = "set"
IQTypeResult IQType = "result"
IQTypeError IQType = "error"
)
// IQ element - info/query
type IQClient struct {
XMLName xml.Name `xml:"jabber:client iq"`
From *model.JID `xml:"from,attr"`
ID string `xml:"id,attr"`
To *model.JID `xml:"to,attr"`
Type IQType `xml:"type,attr"`
Error *ErrorClient `xml:"error"`
Bind *Bind
Ping *Ping
PrivateQuery *IQPrivateQuery
PrivateRegister *IQPrivateRegister
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}
type Ping struct {
XMLName xml.Name `xml:"urn:xmpp:ping ping"`
}
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"`
}

25
messages/iq_utils.go Normal file
View File

@ -0,0 +1,25 @@
package messages
// which XEP ????
import (
"encoding/xml"
)
// where to put: (server part debug? is it part)
type Ping struct {
XMLName xml.Name `xml:"urn:xmpp:ping ping"`
}
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"`
}

View File

@ -1,4 +1,4 @@
package model
package messages
import (
"errors"

View File

@ -1,4 +1,4 @@
package model
package messages
import (
"testing"

View File

@ -1,35 +0,0 @@
package messages
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/model"
)
type MessageType string
const (
MessageTypeChat MessageType = "chat"
MessageTypeGroupchat MessageType = "groupchat"
MessageTypeError MessageType = "error"
MessageTypeHeadline MessageType = "headline"
MessageTypeNormal MessageType = "normal"
)
// MessageClient element
type MessageClient struct {
XMLName xml.Name `xml:"jabber:client message"`
From *model.JID `xml:"from,attr,omitempty"`
ID string `xml:"id,attr,omitempty"`
To *model.JID `xml:"to,attr,omitempty"`
Type MessageType `xml:"type,attr,omitempty"`
Lang string `xml:"lang,attr,omitempty"`
Subject string `xml:"subject"`
Body string `xml:"body"`
Thread string `xml:"thread"`
// Any hasn't matched element
Other []XMLElement `xml:",any"`
Delay *Delay `xml:"delay"`
Error *ErrorClient
}

View File

@ -1,17 +1,29 @@
package messages
const (
// NSStream stream namesapce
// RFC 6120 - A.1 Stream Namespace
NSStream = "http://etherx.jabber.org/streams"
// NSTLS xmpp-tls xml namespace
NSTLS = "urn:ietf:params:xml:ns:xmpp-tls"
// NSSASL xmpp-sasl xml namespace
// RFC 6120 - A.2 Stream Error Namespace
NSStreamError = "urn:ietf:params:xml:ns:xmpp-streams"
// RFC 6120 - A.3 StartTLS Namespace
NSStartTLS = "urn:ietf:params:xml:ns:xmpp-tls"
// RFC 6120 - A.4 SASL Namespace
NSSASL = "urn:ietf:params:xml:ns:xmpp-sasl"
// RFC 6120 - A.5 Client Namespace
NSClient = "jabber:client"
// RFC 6120 - A.6 Server Namespace
NSServer = "jabber:server"
// RFC 6120 - A.7 Resource Binding Namespace
NSBind = "urn:ietf:params:xml:ns:xmpp-bind"
// NSClient jabbet client namespace
NSClient = "jabber:client"
// RFC 6120 - A.8 Stanza Error Binding Namespace
NSStanzaError = "urn:ietf:params:xml:ns:xmpp-stanzas"
NSIQRegister = "jabber:iq:register"

View File

@ -1,46 +0,0 @@
package messages
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/model"
)
type PresenceType string
const (
PresenceTypeUnavailable PresenceType = "unavailable"
PresenceTypeSubscribe PresenceType = "subscribe"
PresenceTypeSubscribed PresenceType = "subscribed"
PresenceTypeUnsubscribe PresenceType = "unsubscribe"
PresenceTypeUnsubscribed PresenceType = "unsubscribed"
PresenceTypeProbe PresenceType = "probe"
PresenceTypeError PresenceType = "error"
)
type PresenceShow string
const (
PresenceShowAway PresenceShow = "away"
PresenceShowChat PresenceShow = "chat"
PresenceShowDND PresenceShow = "dnd"
PresenceShowXA PresenceShow = "xa"
)
// PresenceClient element
type PresenceClient struct {
XMLName xml.Name `xml:"jabber:client presence"`
From *model.JID `xml:"from,attr,omitempty"`
ID string `xml:"id,attr,omitempty"`
To *model.JID `xml:"to,attr,omitempty"`
Type PresenceType `xml:"type,attr,omitempty"`
Lang string `xml:"lang,attr,omitempty"`
Show PresenceShow `xml:"show,omitempty"` // away, chat, dnd, xa
Status string `xml:"status,omitempty"` // sb []clientText
Priority string `xml:"priority,omitempty"`
// Caps *ClientCaps `xml:"c"`
Delay *Delay `xml:"delay"`
Error *ErrorClient
}

View File

@ -1,9 +1,9 @@
package messages
// which XEP ????
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/model"
)
type ClientQuery struct {
@ -11,9 +11,9 @@ type ClientQuery struct {
}
type RosterItem struct {
XMLName xml.Name `xml:"jabber:iq:roster item"`
JID *model.JID `xml:",attr"`
Name string `xml:",attr"`
Subscription string `xml:",attr"`
XMLName xml.Name `xml:"jabber:iq:roster item"`
JID *JID `xml:",attr"`
Name string `xml:",attr"`
Subscription string `xml:",attr"`
Group []string
}

View File

@ -4,7 +4,7 @@ import (
"encoding/xml"
)
// RFC 3920 C.4 SASL name space
// RFC 6120 - A.4 SASL Namespace
type SASLMechanisms struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
Mechanism []string `xml:"mechanism"`
@ -40,7 +40,7 @@ type SASLAbout struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl abort"`
}
// SASLFailure element
// RFC 6120 - A.4 SASL Namespace
type SASLFailure struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl failure"`
@ -56,5 +56,5 @@ type SASLFailure struct {
NotAuthorized *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl not-authorized"`
TemporaryAuthFailure *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl temporary-auth-failure"`
Body string `xml:",chardata"`
Text *Text
}

17
messages/server_error.go Normal file
View File

@ -0,0 +1,17 @@
package messages
import "encoding/xml"
// RFC 6120 - A.6 Server Namespace (a part)
type ErrorServer struct {
XMLName xml.Name `xml:"jabber:server error"`
Code string `xml:"code,attr,omitempty"`
Type ErrorType `xml:"type,attr"` // required
Text *Text
// RFC 6120 A.8 Resource binding namespace
StanzaErrorGroup
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

23
messages/server_iq.go Normal file
View File

@ -0,0 +1,23 @@
package messages
import (
"encoding/xml"
)
// RFC 6120 - A.6 Server Namespace (a part)
type IQServer struct {
XMLName xml.Name `xml:"jabber:server iq"`
From *JID `xml:"from,attr,omitempty"`
ID string `xml:"id,attr"` // required
To *JID `xml:"to,attr"` // required
Type IQType `xml:"type,attr"` // required
Error *ErrorServer
Bind *Bind // which XEP ?
Ping *Ping // which XEP ?
PrivateQuery *IQPrivateQuery // which XEP ?
PrivateRegister *IQPrivateRegister // which XEP ?
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

View File

@ -0,0 +1,25 @@
package messages
import (
"encoding/xml"
)
// RFC 6120 - A.6 Server Namespace (a part)
type MessageServer struct {
XMLName xml.Name `xml:"jabber:server message"`
From *JID `xml:"from,attr"` // required
ID string `xml:"id,attr,omitempty"`
To *JID `xml:"to,attr"` // required
Type MessageType `xml:"type,attr,omitempty"` // default: normal
Lang string `xml:"lang,attr,omitempty"`
Subject string `xml:"subject,omitempty"`
Body string `xml:"body,omitempty"`
Thread string `xml:"thread,omitempty"`
Error *ErrorServer
Delay *Delay `xml:"delay"` // which XEP ?
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

View File

@ -0,0 +1,29 @@
package messages
import (
"encoding/xml"
)
// RFC 6120 - A.6 Server Namespace (a part)
type PresenceServer struct {
XMLName xml.Name `xml:"jabber:server presence"`
From *JID `xml:"from,attr"` // required
ID string `xml:"id,attr,omitempty"`
To *JID `xml:"to,attr"` // required
Type PresenceType `xml:"type,attr,omitempty"`
Lang string `xml:"lang,attr,omitempty"`
Show PresenceShow `xml:"show,omitempty"`
Status string `xml:"status,omitempty"`
Priority uint `xml:"priority,omitempty"` // default: 0
Error *ErrorServer
Delay *Delay `xml:"delay"` // which XEP ?
// which XEP ?
// Caps *ClientCaps `xml:"c"`
// Any hasn't matched element
Other []XMLElement `xml:",any"`
}

View File

@ -8,15 +8,6 @@ import (
"reflect"
)
type Delay struct {
Stamp string `xml:"stamp,attr"`
}
type XMLElement struct {
XMLName xml.Name
InnerXML string `xml:",innerxml"`
}
func XMLStartElementToString(element *xml.StartElement) string {
if element == nil {
return "<nil>"

View File

@ -3,6 +3,8 @@ package model
import (
"errors"
"sync"
"dev.sum7.eu/genofire/yaja/messages"
)
type Domain struct {
@ -11,8 +13,8 @@ type Domain struct {
sync.Mutex
}
func (d *Domain) GetJID() *JID {
return &JID{
func (d *Domain) GetJID() *messages.JID {
return &messages.JID{
Domain: d.FQDN,
}
}
@ -36,7 +38,7 @@ type Account struct {
Bookmarks map[string]*Bookmark `json:"bookmarks"`
}
func NewAccount(jid *JID, password string) *Account {
func NewAccount(jid *messages.JID, password string) *Account {
if jid == nil {
return nil
}
@ -49,8 +51,8 @@ func NewAccount(jid *JID, password string) *Account {
}
}
func (a *Account) GetJID() *JID {
return &JID{
func (a *Account) GetJID() *messages.JID {
return &messages.JID{
Domain: a.Domain.FQDN,
Local: a.Local,
}

View File

@ -61,7 +61,7 @@ func (ex *IQDisco) Get(msg *messages.IQClient, client *utils.Client) bool {
client.Messages <- &messages.IQClient{
Type: messages.IQTypeResult,
To: client.JID,
From: model.NewJID(client.JID.Domain),
From: messages.NewJID(client.JID.Domain),
ID: msg.ID,
Body: queryByte,
}

View File

@ -61,7 +61,7 @@ func (ex *IQExtensionDiscovery) Get(msg *messages.IQClient, client *utils.Client
client.Messages <- &messages.IQClient{
Type: messages.IQTypeResult,
To: client.JID,
From: model.NewJID(client.JID.Domain),
From: messages.NewJID(client.JID.Domain),
ID: msg.ID,
Body: queryByte,
}

View File

@ -49,7 +49,7 @@ func (ex *IQLast) Get(msg *messages.IQClient, client *utils.Client) bool {
client.Messages <- &messages.IQClient{
Type: messages.IQTypeResult,
To: client.JID,
From: model.NewJID(client.JID.Domain),
From: messages.NewJID(client.JID.Domain),
ID: msg.ID,
Body: queryByte,
}

View File

@ -2,7 +2,6 @@ package extension
import (
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
"dev.sum7.eu/genofire/yaja/server/utils"
)
@ -23,7 +22,7 @@ func (ex *IQPing) Get(msg *messages.IQClient, client *utils.Client) bool {
client.Messages <- &messages.IQClient{
Type: messages.IQTypeResult,
To: client.JID,
From: model.NewJID(client.JID.Domain),
From: messages.NewJID(client.JID.Domain),
ID: msg.ID,
}

View File

@ -39,7 +39,7 @@ func (ex *IQPrivateBookmark) Handle(msg *messages.IQClient, client *utils.Client
client.Messages <- &messages.IQClient{
Type: messages.IQTypeResult,
To: client.JID,
From: model.NewJID(client.JID.Domain),
From: messages.NewJID(client.JID.Domain),
ID: msg.ID,
Body: queryByte,
}

View File

@ -40,7 +40,7 @@ func (ex *IQPrivateMetacontact) Handle(msg *messages.IQClient, client *utils.Cli
client.Messages <- &messages.IQClient{
Type: messages.IQTypeResult,
To: client.JID,
From: model.NewJID(client.JID.Domain),
From: messages.NewJID(client.JID.Domain),
ID: msg.ID,
Body: queryByte,
}

View File

@ -44,7 +44,7 @@ func (ex *IQPrivateRoster) Handle(msg *messages.IQClient, client *utils.Client)
client.Messages <- &messages.IQClient{
Type: messages.IQTypeResult,
To: client.JID,
From: model.NewJID(client.JID.Domain),
From: messages.NewJID(client.JID.Domain),
ID: msg.ID,
Body: queryByte,
}

View File

@ -5,7 +5,7 @@ import (
"net"
"dev.sum7.eu/genofire/yaja/database"
"dev.sum7.eu/genofire/yaja/model"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/server/extension"
"dev.sum7.eu/genofire/yaja/server/toclient"
"dev.sum7.eu/genofire/yaja/server/toserver"
@ -109,7 +109,7 @@ func (srv *Server) handleClient(conn net.Conn) {
}
}
func (srv *Server) DomainRegisterAllowed(jid *model.JID) bool {
func (srv *Server) DomainRegisterAllowed(jid *messages.JID) bool {
if jid.Domain == "" {
return false
}

View File

@ -5,7 +5,6 @@ import (
"fmt"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
"dev.sum7.eu/genofire/yaja/server/utils"
"golang.org/x/crypto/acme/autocert"
)
@ -33,7 +32,7 @@ func (state *Start) Process() State {
}
for _, attr := range element.Attr {
if attr.Name.Local == "to" {
state.Client.JID = &model.JID{Domain: attr.Value}
state.Client.JID = &messages.JID{Domain: attr.Value}
state.Client.Log = state.Client.Log.WithField("jid", state.Client.JID.Full())
}
}
@ -75,11 +74,11 @@ func (state *TLSUpgrade) Process() State {
state.Client.Log.Warn("unable to read: ", err)
return nil
}
if element.Name.Space != messages.NSTLS || element.Name.Local != "starttls" {
if element.Name.Space != messages.NSStartTLS || element.Name.Local != "starttls" {
state.Client.Log.Warn("is no starttls", element)
return nil
}
fmt.Fprintf(state.Client.Conn, "<proceed xmlns='%s'/>", messages.NSTLS)
fmt.Fprintf(state.Client.Conn, "<proceed xmlns='%s'/>", messages.NSStartTLS)
// perform the TLS handshake
var tlsConfig *tls.Config
if m := state.TLSManager; m != nil {

View File

@ -8,7 +8,6 @@ import (
"dev.sum7.eu/genofire/yaja/database"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
"dev.sum7.eu/genofire/yaja/server/extension"
"dev.sum7.eu/genofire/yaja/server/state"
"dev.sum7.eu/genofire/yaja/server/utils"
@ -226,7 +225,7 @@ func (state *AuthedStream) Process() state.State {
state.Client.Out.Encode(&messages.IQClient{
Type: messages.IQTypeResult,
To: state.Client.JID,
From: model.NewJID(state.Client.JID.Domain),
From: messages.NewJID(state.Client.JID.Domain),
ID: msg.ID,
Bind: &messages.Bind{JID: state.Client.JID},
})

View File

@ -49,7 +49,7 @@ func (state *RegisterFormRequest) Process() state.State {
state.Client.Out.Encode(&messages.IQClient{
Type: messages.IQTypeResult,
To: state.Client.JID,
From: model.NewJID(state.Client.JID.Domain),
From: messages.NewJID(state.Client.JID.Domain),
ID: msg.ID,
PrivateRegister: &messages.IQPrivateRegister{
Instructions: "Choose a username and password for use with this service.",
@ -109,7 +109,7 @@ func (state *RegisterRequest) Process() state.State {
state.Client.Out.Encode(&messages.IQClient{
Type: messages.IQTypeResult,
To: state.Client.JID,
From: model.NewJID(state.Client.JID.Domain),
From: messages.NewJID(state.Client.JID.Domain),
ID: msg.ID,
PrivateRegister: msg.PrivateRegister,
Error: &messages.ErrorClient{
@ -126,7 +126,7 @@ func (state *RegisterRequest) Process() state.State {
state.Client.Out.Encode(&messages.IQClient{
Type: messages.IQTypeResult,
To: state.Client.JID,
From: model.NewJID(state.Client.JID.Domain),
From: messages.NewJID(state.Client.JID.Domain),
ID: msg.ID,
})

View File

@ -4,6 +4,7 @@ import (
"encoding/xml"
"net"
"dev.sum7.eu/genofire/yaja/messages"
"dev.sum7.eu/genofire/yaja/model"
log "github.com/sirupsen/logrus"
)
@ -15,7 +16,7 @@ type Client struct {
Out *xml.Encoder
In *xml.Decoder
JID *model.JID
JID *messages.JID
account *model.Account
Messages chan interface{}

View File

@ -1,7 +1,5 @@
package utils
import (
"dev.sum7.eu/genofire/yaja/model"
)
import "dev.sum7.eu/genofire/yaja/messages"
type DomainRegisterAllowed func(*model.JID) bool
type DomainRegisterAllowed func(*messages.JID) bool