messages after RFC 6120 completed
This commit is contained in:
parent
4d4a201b1a
commit
81c8605477
|
@ -94,7 +94,10 @@ func (client *Client) auth(password string) error {
|
||||||
}
|
}
|
||||||
fail := messages.SASLFailure{}
|
fail := messages.SASLFailure{}
|
||||||
if err := client.Decode(&fail, element); err == nil {
|
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 {
|
if err := client.Decode(&messages.SASLSuccess{}, element); err != nil {
|
||||||
return errors.New("auth failed - with unexpected answer")
|
return errors.New("auth failed - with unexpected answer")
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client holds XMPP connection opitons
|
// Client holds XMPP connection opitons
|
||||||
|
@ -23,10 +23,17 @@ type Client struct {
|
||||||
|
|
||||||
Logging *log.Logger
|
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{
|
client := &Client{
|
||||||
Protocol: "tcp",
|
Protocol: "tcp",
|
||||||
JID: jid,
|
JID: jid,
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (client *Client) connect(password string) error {
|
||||||
}
|
}
|
||||||
if err := client.Send(&messages.IQClient{
|
if err := client.Send(&messages.IQClient{
|
||||||
Type: messages.IQTypeSet,
|
Type: messages.IQTypeSet,
|
||||||
To: model.NewJID(client.JID.Domain),
|
To: messages.NewJID(client.JID.Domain),
|
||||||
Bind: bind,
|
Bind: bind,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package tester
|
package tester
|
||||||
|
|
||||||
import "dev.sum7.eu/genofire/yaja/model"
|
import "dev.sum7.eu/genofire/yaja/messages"
|
||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
JID *model.JID `json:"jid"`
|
JID *messages.JID `json:"jid"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Admins map[string]interface{} `json:"admins"`
|
Admins map[string]interface{} `json:"admins"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/messages"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t *Tester) StartBot(status *Status) {
|
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
|
alist := list
|
||||||
for jid, _ := range toConvert {
|
for jid, _ := range toConvert {
|
||||||
alist = append(alist, model.NewJID(jid))
|
alist = append(alist, messages.NewJID(jid))
|
||||||
}
|
}
|
||||||
return alist
|
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 := ""
|
msg := ""
|
||||||
if len(cmd) == 2 {
|
if len(cmd) == 2 {
|
||||||
isAdmin := false
|
isAdmin := false
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package tester
|
package tester
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"github.com/FreifunkBremen/yanic/lib/duration"
|
"github.com/FreifunkBremen/yanic/lib/duration"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -15,9 +15,9 @@ type Config struct {
|
||||||
LoggingBots log.Level `toml:"logging_bots"`
|
LoggingBots log.Level `toml:"logging_bots"`
|
||||||
Timeout duration.Duration `toml:"timeout"`
|
Timeout duration.Duration `toml:"timeout"`
|
||||||
Interval duration.Duration `toml:"interval"`
|
Interval duration.Duration `toml:"interval"`
|
||||||
Admins []*model.JID `toml:"admins"`
|
Admins []*messages.JID `toml:"admins"`
|
||||||
Client struct {
|
Client struct {
|
||||||
JID *model.JID `toml:"jid"`
|
JID *messages.JID `toml:"jid"`
|
||||||
Password string `toml:"password"`
|
Password string `toml:"password"`
|
||||||
} `toml:"client"`
|
} `toml:"client"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"github.com/FreifunkBremen/yanic/lib/jsontime"
|
"github.com/FreifunkBremen/yanic/lib/jsontime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ func (t *Tester) Output() *Output {
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
toJID := model.NewJID(to)
|
toJID := messages.NewJID(to)
|
||||||
link := &Link{
|
link := &Link{
|
||||||
Source: status.JID.Domain,
|
Source: status.JID.Domain,
|
||||||
SourceJID: status.JID.Bare(),
|
SourceJID: status.JID.Bare(),
|
||||||
|
|
|
@ -7,14 +7,13 @@ import (
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/client"
|
"dev.sum7.eu/genofire/yaja/client"
|
||||||
"dev.sum7.eu/genofire/yaja/messages"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
backupClient *client.Client
|
backupClient *client.Client
|
||||||
client *client.Client
|
client *client.Client
|
||||||
account *Account
|
account *Account
|
||||||
JID *model.JID `json:"jid"`
|
JID *messages.JID `json:"jid"`
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
Login bool `json:"is_online"`
|
Login bool `json:"is_online"`
|
||||||
MessageForConnection map[string]string `json:"-"`
|
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),
|
Body: fmt.Sprintf("you recieve a notify that '%s' disconnect: %s", s.JID.Full(), reason),
|
||||||
}
|
}
|
||||||
for jid, _ := range s.account.Admins {
|
for jid, _ := range s.account.Admins {
|
||||||
msg.To = model.NewJID(jid)
|
msg.To = messages.NewJID(jid)
|
||||||
if err := s.backupClient.Send(msg); err != nil {
|
if err := s.backupClient.Send(msg); err != nil {
|
||||||
s.client.Send(msg)
|
s.client.Send(msg)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +58,7 @@ func (s *Status) Update(timeout time.Duration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &client.Client{
|
c := &client.Client{
|
||||||
JID: model.NewJID(s.account.JID.Bare()),
|
JID: messages.NewJID(s.account.JID.Bare()),
|
||||||
Protocol: "tcp4",
|
Protocol: "tcp4",
|
||||||
Logging: s.client.Logging,
|
Logging: s.client.Logging,
|
||||||
Timeout: timeout / 2,
|
Timeout: timeout / 2,
|
||||||
|
@ -72,7 +71,7 @@ func (s *Status) Update(timeout time.Duration) {
|
||||||
s.IPv4 = false
|
s.IPv4 = false
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JID = model.NewJID(s.account.JID.Bare())
|
c.JID = messages.NewJID(s.account.JID.Bare())
|
||||||
c.Protocol = "tcp6"
|
c.Protocol = "tcp6"
|
||||||
|
|
||||||
if err := c.Connect(s.account.Password); err == nil {
|
if err := c.Connect(s.account.Password); err == nil {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/client"
|
"dev.sum7.eu/genofire/yaja/client"
|
||||||
"dev.sum7.eu/genofire/yaja/messages"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Tester struct {
|
type Tester struct {
|
||||||
|
@ -17,9 +16,9 @@ type Tester struct {
|
||||||
Accounts map[string]*Account `json:"accounts"`
|
Accounts map[string]*Account `json:"accounts"`
|
||||||
Status map[string]*Status `json:"-"`
|
Status map[string]*Status `json:"-"`
|
||||||
mux sync.Mutex
|
mux sync.Mutex
|
||||||
LoggingClients *log.Logger `json:"-"`
|
LoggingClients *log.Logger `json:"-"`
|
||||||
LoggingBots log.Level `json:"-"`
|
LoggingBots log.Level `json:"-"`
|
||||||
Admins []*model.JID `json:"-"`
|
Admins []*messages.JID `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTester() *Tester {
|
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{
|
logCTX := log.WithFields(log.Fields{
|
||||||
"jid": to.Full(),
|
"jid": to.Full(),
|
||||||
"from": from.Full(),
|
"from": from.Full(),
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
"dev.sum7.eu/genofire/yaja/model"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -48,7 +49,7 @@ func (s *State) AddAccount(a *model.Account) error {
|
||||||
return errors.New("no give domain")
|
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")
|
logger := log.WithField("database", "auth")
|
||||||
|
|
||||||
if domain, ok := s.Domains[jid.Domain]; ok {
|
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
|
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")
|
logger := log.WithField("database", "get")
|
||||||
|
|
||||||
if domain, ok := s.Domains[jid.Domain]; ok {
|
if domain, ok := s.Domains[jid.Domain]; ok {
|
||||||
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -2,11 +2,9 @@ package messages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RFC 3920 C.1 Streams name space
|
// 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
|
||||||
|
@ -15,23 +13,25 @@ type StreamFeatures struct {
|
||||||
Session bool
|
Session bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3920 C.3 TLS name space
|
// RFC 6120 - A.3 StartTLS Namespace
|
||||||
type TLSStartTLS struct {
|
type TLSStartTLS struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls starttls"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls starttls"`
|
||||||
Required *string `xml:"required"`
|
Required *string `xml:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TLSFailure struct {
|
// RFC 6120 - A.3 StartTLS Namespace
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TLSProceed struct {
|
type TLSProceed struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls proceed"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls proceed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3920 C.5 Resource binding name space
|
// RFC 6120 - A.3 StartTLS Namespace
|
||||||
type Bind struct {
|
type TLSFailure struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"`
|
||||||
Resource string `xml:"resource"`
|
}
|
||||||
JID *model.JID `xml:"jid"`
|
|
||||||
|
// 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"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
)
|
|
@ -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"
|
||||||
|
)
|
|
@ -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"
|
||||||
|
)
|
|
@ -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"
|
||||||
|
)
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
|
||||||
}
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package model
|
package messages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
|
@ -1,4 +1,4 @@
|
||||||
package model
|
package messages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -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
|
|
||||||
}
|
|
|
@ -1,17 +1,29 @@
|
||||||
package messages
|
package messages
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// NSStream stream namesapce
|
// RFC 6120 - A.1 Stream Namespace
|
||||||
NSStream = "http://etherx.jabber.org/streams"
|
NSStream = "http://etherx.jabber.org/streams"
|
||||||
// NSTLS xmpp-tls xml namespace
|
|
||||||
NSTLS = "urn:ietf:params:xml:ns:xmpp-tls"
|
// RFC 6120 - A.2 Stream Error Namespace
|
||||||
// NSSASL xmpp-sasl xml 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"
|
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"
|
NSBind = "urn:ietf:params:xml:ns:xmpp-bind"
|
||||||
|
|
||||||
// NSClient jabbet client namespace
|
// RFC 6120 - A.8 Stanza Error Binding Namespace
|
||||||
NSClient = "jabber:client"
|
NSStanzaError = "urn:ietf:params:xml:ns:xmpp-stanzas"
|
||||||
|
|
||||||
NSIQRegister = "jabber:iq:register"
|
NSIQRegister = "jabber:iq:register"
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -1,9 +1,9 @@
|
||||||
package messages
|
package messages
|
||||||
|
|
||||||
|
// which XEP ????
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientQuery struct {
|
type ClientQuery struct {
|
||||||
|
@ -11,9 +11,9 @@ type ClientQuery struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type RosterItem struct {
|
type RosterItem struct {
|
||||||
XMLName xml.Name `xml:"jabber:iq:roster item"`
|
XMLName xml.Name `xml:"jabber:iq:roster item"`
|
||||||
JID *model.JID `xml:",attr"`
|
JID *JID `xml:",attr"`
|
||||||
Name string `xml:",attr"`
|
Name string `xml:",attr"`
|
||||||
Subscription string `xml:",attr"`
|
Subscription string `xml:",attr"`
|
||||||
Group []string
|
Group []string
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RFC 3920 C.4 SASL name space
|
// RFC 6120 - A.4 SASL Namespace
|
||||||
type SASLMechanisms struct {
|
type SASLMechanisms struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
|
||||||
Mechanism []string `xml:"mechanism"`
|
Mechanism []string `xml:"mechanism"`
|
||||||
|
@ -40,7 +40,7 @@ type SASLAbout struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl abort"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl abort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SASLFailure element
|
// RFC 6120 - A.4 SASL Namespace
|
||||||
type SASLFailure struct {
|
type SASLFailure struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl failure"`
|
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"`
|
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"`
|
TemporaryAuthFailure *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl temporary-auth-failure"`
|
||||||
|
|
||||||
Body string `xml:",chardata"`
|
Text *Text
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -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"`
|
||||||
|
}
|
|
@ -8,15 +8,6 @@ import (
|
||||||
"reflect"
|
"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 {
|
func XMLStartElementToString(element *xml.StartElement) string {
|
||||||
if element == nil {
|
if element == nil {
|
||||||
return "<nil>"
|
return "<nil>"
|
||||||
|
|
|
@ -3,6 +3,8 @@ package model
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Domain struct {
|
type Domain struct {
|
||||||
|
@ -11,8 +13,8 @@ type Domain struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Domain) GetJID() *JID {
|
func (d *Domain) GetJID() *messages.JID {
|
||||||
return &JID{
|
return &messages.JID{
|
||||||
Domain: d.FQDN,
|
Domain: d.FQDN,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +38,7 @@ type Account struct {
|
||||||
Bookmarks map[string]*Bookmark `json:"bookmarks"`
|
Bookmarks map[string]*Bookmark `json:"bookmarks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAccount(jid *JID, password string) *Account {
|
func NewAccount(jid *messages.JID, password string) *Account {
|
||||||
if jid == nil {
|
if jid == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -49,8 +51,8 @@ func NewAccount(jid *JID, password string) *Account {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Account) GetJID() *JID {
|
func (a *Account) GetJID() *messages.JID {
|
||||||
return &JID{
|
return &messages.JID{
|
||||||
Domain: a.Domain.FQDN,
|
Domain: a.Domain.FQDN,
|
||||||
Local: a.Local,
|
Local: a.Local,
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ func (ex *IQDisco) Get(msg *messages.IQClient, client *utils.Client) bool {
|
||||||
client.Messages <- &messages.IQClient{
|
client.Messages <- &messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: client.JID,
|
To: client.JID,
|
||||||
From: model.NewJID(client.JID.Domain),
|
From: messages.NewJID(client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
Body: queryByte,
|
Body: queryByte,
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ func (ex *IQExtensionDiscovery) Get(msg *messages.IQClient, client *utils.Client
|
||||||
client.Messages <- &messages.IQClient{
|
client.Messages <- &messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: client.JID,
|
To: client.JID,
|
||||||
From: model.NewJID(client.JID.Domain),
|
From: messages.NewJID(client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
Body: queryByte,
|
Body: queryByte,
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ func (ex *IQLast) Get(msg *messages.IQClient, client *utils.Client) bool {
|
||||||
client.Messages <- &messages.IQClient{
|
client.Messages <- &messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: client.JID,
|
To: client.JID,
|
||||||
From: model.NewJID(client.JID.Domain),
|
From: messages.NewJID(client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
Body: queryByte,
|
Body: queryByte,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package extension
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"dev.sum7.eu/genofire/yaja/messages"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
"dev.sum7.eu/genofire/yaja/server/utils"
|
"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{
|
client.Messages <- &messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: client.JID,
|
To: client.JID,
|
||||||
From: model.NewJID(client.JID.Domain),
|
From: messages.NewJID(client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (ex *IQPrivateBookmark) Handle(msg *messages.IQClient, client *utils.Client
|
||||||
client.Messages <- &messages.IQClient{
|
client.Messages <- &messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: client.JID,
|
To: client.JID,
|
||||||
From: model.NewJID(client.JID.Domain),
|
From: messages.NewJID(client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
Body: queryByte,
|
Body: queryByte,
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (ex *IQPrivateMetacontact) Handle(msg *messages.IQClient, client *utils.Cli
|
||||||
client.Messages <- &messages.IQClient{
|
client.Messages <- &messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: client.JID,
|
To: client.JID,
|
||||||
From: model.NewJID(client.JID.Domain),
|
From: messages.NewJID(client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
Body: queryByte,
|
Body: queryByte,
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (ex *IQPrivateRoster) Handle(msg *messages.IQClient, client *utils.Client)
|
||||||
client.Messages <- &messages.IQClient{
|
client.Messages <- &messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: client.JID,
|
To: client.JID,
|
||||||
From: model.NewJID(client.JID.Domain),
|
From: messages.NewJID(client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
Body: queryByte,
|
Body: queryByte,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/database"
|
"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/extension"
|
||||||
"dev.sum7.eu/genofire/yaja/server/toclient"
|
"dev.sum7.eu/genofire/yaja/server/toclient"
|
||||||
"dev.sum7.eu/genofire/yaja/server/toserver"
|
"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 == "" {
|
if jid.Domain == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/messages"
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
"dev.sum7.eu/genofire/yaja/server/utils"
|
"dev.sum7.eu/genofire/yaja/server/utils"
|
||||||
"golang.org/x/crypto/acme/autocert"
|
"golang.org/x/crypto/acme/autocert"
|
||||||
)
|
)
|
||||||
|
@ -33,7 +32,7 @@ func (state *Start) Process() State {
|
||||||
}
|
}
|
||||||
for _, attr := range element.Attr {
|
for _, attr := range element.Attr {
|
||||||
if attr.Name.Local == "to" {
|
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())
|
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)
|
state.Client.Log.Warn("unable to read: ", err)
|
||||||
return nil
|
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)
|
state.Client.Log.Warn("is no starttls", element)
|
||||||
return nil
|
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
|
// perform the TLS handshake
|
||||||
var tlsConfig *tls.Config
|
var tlsConfig *tls.Config
|
||||||
if m := state.TLSManager; m != nil {
|
if m := state.TLSManager; m != nil {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/yaja/database"
|
"dev.sum7.eu/genofire/yaja/database"
|
||||||
"dev.sum7.eu/genofire/yaja/messages"
|
"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/extension"
|
||||||
"dev.sum7.eu/genofire/yaja/server/state"
|
"dev.sum7.eu/genofire/yaja/server/state"
|
||||||
"dev.sum7.eu/genofire/yaja/server/utils"
|
"dev.sum7.eu/genofire/yaja/server/utils"
|
||||||
|
@ -226,7 +225,7 @@ func (state *AuthedStream) Process() state.State {
|
||||||
state.Client.Out.Encode(&messages.IQClient{
|
state.Client.Out.Encode(&messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: state.Client.JID,
|
To: state.Client.JID,
|
||||||
From: model.NewJID(state.Client.JID.Domain),
|
From: messages.NewJID(state.Client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
Bind: &messages.Bind{JID: state.Client.JID},
|
Bind: &messages.Bind{JID: state.Client.JID},
|
||||||
})
|
})
|
||||||
|
|
|
@ -49,7 +49,7 @@ func (state *RegisterFormRequest) Process() state.State {
|
||||||
state.Client.Out.Encode(&messages.IQClient{
|
state.Client.Out.Encode(&messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: state.Client.JID,
|
To: state.Client.JID,
|
||||||
From: model.NewJID(state.Client.JID.Domain),
|
From: messages.NewJID(state.Client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
PrivateRegister: &messages.IQPrivateRegister{
|
PrivateRegister: &messages.IQPrivateRegister{
|
||||||
Instructions: "Choose a username and password for use with this service.",
|
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{
|
state.Client.Out.Encode(&messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: state.Client.JID,
|
To: state.Client.JID,
|
||||||
From: model.NewJID(state.Client.JID.Domain),
|
From: messages.NewJID(state.Client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
PrivateRegister: msg.PrivateRegister,
|
PrivateRegister: msg.PrivateRegister,
|
||||||
Error: &messages.ErrorClient{
|
Error: &messages.ErrorClient{
|
||||||
|
@ -126,7 +126,7 @@ func (state *RegisterRequest) Process() state.State {
|
||||||
state.Client.Out.Encode(&messages.IQClient{
|
state.Client.Out.Encode(&messages.IQClient{
|
||||||
Type: messages.IQTypeResult,
|
Type: messages.IQTypeResult,
|
||||||
To: state.Client.JID,
|
To: state.Client.JID,
|
||||||
From: model.NewJID(state.Client.JID.Domain),
|
From: messages.NewJID(state.Client.JID.Domain),
|
||||||
ID: msg.ID,
|
ID: msg.ID,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
"dev.sum7.eu/genofire/yaja/model"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -15,7 +16,7 @@ type Client struct {
|
||||||
Out *xml.Encoder
|
Out *xml.Encoder
|
||||||
In *xml.Decoder
|
In *xml.Decoder
|
||||||
|
|
||||||
JID *model.JID
|
JID *messages.JID
|
||||||
account *model.Account
|
account *model.Account
|
||||||
|
|
||||||
Messages chan interface{}
|
Messages chan interface{}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import "dev.sum7.eu/genofire/yaja/messages"
|
||||||
"dev.sum7.eu/genofire/yaja/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DomainRegisterAllowed func(*model.JID) bool
|
type DomainRegisterAllowed func(*messages.JID) bool
|
||||||
|
|
Reference in New Issue