forked from jshiffer/go-xmpp
port to r60.1
This commit is contained in:
parent
4ddb93ef9d
commit
b6a67e2320
@ -5,7 +5,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"github.com/kless/go-readin/readin"
|
"github.com/kless/go-readin/readin"
|
||||||
"github.com/mattn/go-xmpp"
|
"github.com/mattn/go-xmpp"
|
||||||
"github.com/mattn/go-iconv/iconv"
|
"github.com/mattn/go-iconv"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
69
xmpp.go
69
xmpp.go
@ -25,6 +25,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"xml"
|
"xml"
|
||||||
|
"url"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -64,7 +65,7 @@ func NewClient(host, user, passwd string) (*Client, os.Error) {
|
|||||||
proxy = os.Getenv("http_proxy")
|
proxy = os.Getenv("http_proxy")
|
||||||
}
|
}
|
||||||
if proxy != "" {
|
if proxy != "" {
|
||||||
url, err := http.ParseRequestURL(proxy)
|
url, err := url.Parse(proxy)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
addr = url.Host
|
addr = url.Host
|
||||||
}
|
}
|
||||||
@ -246,7 +247,7 @@ func (c *Client) Send(chat Chat) {
|
|||||||
// RFC 3920 C.1 Streams name space
|
// RFC 3920 C.1 Streams name space
|
||||||
|
|
||||||
type streamFeatures struct {
|
type streamFeatures struct {
|
||||||
XMLName xml.Name "http://etherx.jabber.org/streams features"
|
XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"`
|
||||||
StartTLS tlsStartTLS
|
StartTLS tlsStartTLS
|
||||||
Mechanisms saslMechanisms
|
Mechanisms saslMechanisms
|
||||||
Bind bindBind
|
Bind bindBind
|
||||||
@ -254,7 +255,7 @@ type streamFeatures struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type streamError struct {
|
type streamError struct {
|
||||||
XMLName xml.Name "http://etherx.jabber.org/streams error"
|
XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"`
|
||||||
Any xml.Name
|
Any xml.Name
|
||||||
Text string
|
Text string
|
||||||
}
|
}
|
||||||
@ -262,28 +263,28 @@ type streamError struct {
|
|||||||
// RFC 3920 C.3 TLS name space
|
// RFC 3920 C.3 TLS name space
|
||||||
|
|
||||||
type tlsStartTLS struct {
|
type tlsStartTLS struct {
|
||||||
XMLName xml.Name ":ietf:params:xml:ns:xmpp-tls starttls"
|
XMLName xml.Name `xml:":ietf:params:xml:ns:xmpp-tls starttls"`
|
||||||
Required bool
|
Required bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type tlsProceed struct {
|
type tlsProceed struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-tls proceed"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls proceed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type tlsFailure struct {
|
type tlsFailure struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-tls failure"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3920 C.4 SASL name space
|
// RFC 3920 C.4 SASL name space
|
||||||
|
|
||||||
type saslMechanisms struct {
|
type saslMechanisms struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-sasl mechanisms"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
|
||||||
Mechanism []string
|
Mechanism []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type saslAuth struct {
|
type saslAuth struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-sasl auth"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl auth"`
|
||||||
Mechanism string "attr"
|
Mechanism string `xml:"attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type saslChallenge string
|
type saslChallenge string
|
||||||
@ -291,22 +292,22 @@ type saslChallenge string
|
|||||||
type saslResponse string
|
type saslResponse string
|
||||||
|
|
||||||
type saslAbort struct {
|
type saslAbort struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-sasl abort"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl abort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type saslSuccess struct {
|
type saslSuccess struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-sasl success"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type saslFailure struct {
|
type saslFailure struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-sasl failure"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl failure"`
|
||||||
Any xml.Name
|
Any xml.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC 3920 C.5 Resource binding name space
|
// RFC 3920 C.5 Resource binding name space
|
||||||
|
|
||||||
type bindBind struct {
|
type bindBind struct {
|
||||||
XMLName xml.Name "urn:ietf:params:xml:ns:xmpp-bind bind"
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
|
||||||
Resource string
|
Resource string
|
||||||
Jid string
|
Jid string
|
||||||
}
|
}
|
||||||
@ -314,11 +315,11 @@ type bindBind struct {
|
|||||||
// RFC 3921 B.1 jabber:client
|
// RFC 3921 B.1 jabber:client
|
||||||
|
|
||||||
type clientMessage struct {
|
type clientMessage struct {
|
||||||
XMLName xml.Name "jabber:client message"
|
XMLName xml.Name `xml:"jabber:client message"`
|
||||||
From string "attr"
|
From string `xml:"attr"`
|
||||||
Id string "attr"
|
Id string `xml:"attr"`
|
||||||
To string "attr"
|
To string `xml:"attr"`
|
||||||
Type string "attr" // chat, error, groupchat, headline, or normal
|
Type string `xml:"attr"` // chat, error, groupchat, headline, or normal
|
||||||
|
|
||||||
// These should technically be []clientText,
|
// These should technically be []clientText,
|
||||||
// but string is much more convenient.
|
// but string is much more convenient.
|
||||||
@ -328,17 +329,17 @@ type clientMessage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type clientText struct {
|
type clientText struct {
|
||||||
Lang string "attr"
|
Lang string `xml:"attr"`
|
||||||
Body string "chardata"
|
Body string `xml:"chardata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientPresence struct {
|
type clientPresence struct {
|
||||||
XMLName xml.Name "jabber:client presence"
|
XMLName xml.Name `xml:"jabber:client presence"`
|
||||||
From string "attr"
|
From string `xml:"attr"`
|
||||||
Id string "attr"
|
Id string `xml:"attr"`
|
||||||
To string "attr"
|
To string `xml:"attr"`
|
||||||
Type string "attr" // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
|
Type string `xml:"attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
|
||||||
Lang string "attr"
|
Lang string `xml:"attr"`
|
||||||
|
|
||||||
Show string // away, chat, dnd, xa
|
Show string // away, chat, dnd, xa
|
||||||
Status string // sb []clientText
|
Status string // sb []clientText
|
||||||
@ -347,19 +348,19 @@ type clientPresence struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type clientIQ struct { // info/query
|
type clientIQ struct { // info/query
|
||||||
XMLName xml.Name "jabber:client iq"
|
XMLName xml.Name `xml:"jabber:client iq"`
|
||||||
From string "attr"
|
From string `xml:"attr"`
|
||||||
Id string "attr"
|
Id string `xml:"attr"`
|
||||||
To string "attr"
|
To string `xml:"attr"`
|
||||||
Type string "attr" // error, get, result, set
|
Type string `xml:"attr"` // error, get, result, set
|
||||||
Error clientError
|
Error clientError
|
||||||
Bind bindBind
|
Bind bindBind
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientError struct {
|
type clientError struct {
|
||||||
XMLName xml.Name "jabber:client error"
|
XMLName xml.Name `xml:"jabber:client error"`
|
||||||
Code string "attr"
|
Code string `xml:"attr"`
|
||||||
Type string "attr"
|
Type string `xml:"attr"`
|
||||||
Any xml.Name
|
Any xml.Name
|
||||||
Text string
|
Text string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user