summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/LICENSE (renamed from vendor/github.com/mattn/go-xmpp/LICENSE)0
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp.go (renamed from vendor/github.com/mattn/go-xmpp/xmpp.go)62
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go (renamed from vendor/github.com/mattn/go-xmpp/xmpp_information_query.go)7
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp_muc.go (renamed from vendor/github.com/mattn/go-xmpp/xmpp_muc.go)0
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp_ping.go (renamed from vendor/github.com/mattn/go-xmpp/xmpp_ping.go)0
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp_subscription.go (renamed from vendor/github.com/mattn/go-xmpp/xmpp_subscription.go)0
-rw-r--r--vendor/manifest16
7 files changed, 58 insertions, 27 deletions
diff --git a/vendor/github.com/mattn/go-xmpp/LICENSE b/vendor/github.com/matterbridge/go-xmpp/LICENSE
index 6a66aea5..6a66aea5 100644
--- a/vendor/github.com/mattn/go-xmpp/LICENSE
+++ b/vendor/github.com/matterbridge/go-xmpp/LICENSE
diff --git a/vendor/github.com/mattn/go-xmpp/xmpp.go b/vendor/github.com/matterbridge/go-xmpp/xmpp.go
index 6af9a3ed..d3f31367 100644
--- a/vendor/github.com/mattn/go-xmpp/xmpp.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp.go
@@ -68,6 +68,11 @@ func (c *Client) JID() string {
return c.jid
}
+func containsIgnoreCase(s, substr string) bool {
+ s, substr = strings.ToUpper(s), strings.ToUpper(substr)
+ return strings.Contains(s, substr)
+}
+
func connect(host, user, passwd string) (net.Conn, error) {
addr := host
@@ -81,16 +86,34 @@ func connect(host, user, passwd string) (net.Conn, error) {
if len(a) == 1 {
addr += ":5222"
}
+
proxy := os.Getenv("HTTP_PROXY")
if proxy == "" {
proxy = os.Getenv("http_proxy")
}
+ // test for no proxy, takes a comma separated list with substrings to match
+ if proxy != "" {
+ noproxy := os.Getenv("NO_PROXY")
+ if noproxy == "" {
+ noproxy = os.Getenv("no_proxy")
+ }
+ if noproxy != "" {
+ nplist := strings.Split(noproxy, ",")
+ for _, s := range nplist {
+ if containsIgnoreCase(addr, s) {
+ proxy = ""
+ break
+ }
+ }
+ }
+ }
if proxy != "" {
url, err := url.Parse(proxy)
if err == nil {
addr = url.Host
}
}
+
c, err := net.Dial("tcp", addr)
if err != nil {
return nil, err
@@ -168,6 +191,9 @@ type Options struct {
// Status message
StatusMessage string
+
+ // Logger
+ Logger io.Writer
}
// NewClient establishes a new Client connection based on a set of Options.
@@ -501,7 +527,7 @@ func (c *Client) startTLSIfRequired(f *streamFeatures, o *Options, domain string
// will be returned.
func (c *Client) startStream(o *Options, domain string) (*streamFeatures, error) {
if o.Debug {
- c.p = xml.NewDecoder(tee{c.conn, os.Stderr})
+ c.p = xml.NewDecoder(tee{c.conn, o.Logger})
} else {
c.p = xml.NewDecoder(c.conn)
}
@@ -545,6 +571,8 @@ type Chat struct {
Remote string
Type string
Text string
+ Subject string
+ Thread string
Roster Roster
Other []string
OtherElem []XMLElement
@@ -594,6 +622,8 @@ func (c *Client) Recv() (stanza interface{}, err error) {
Remote: v.From,
Type: v.Type,
Text: v.Body,
+ Subject: v.Subject,
+ Thread: v.Thread,
Other: v.OtherStrings(),
OtherElem: v.Other,
Stamp: stamp,
@@ -609,7 +639,7 @@ func (c *Client) Recv() (stanza interface{}, err error) {
return Presence{v.From, v.To, v.Type, v.Show, v.Status}, nil
case *clientIQ:
// TODO check more strictly
- if bytes.Equal(v.Query, []byte(`<ping xmlns='urn:xmpp:ping'/>`)) || bytes.Equal(v.Query, []byte(`<ping xmlns="urn:xmpp:ping"/>`)) {
+ if bytes.Equal(bytes.TrimSpace(v.Query), []byte(`<ping xmlns='urn:xmpp:ping'/>`)) || bytes.Equal(bytes.TrimSpace(v.Query), []byte(`<ping xmlns="urn:xmpp:ping"/>`)) {
err := c.SendResultPing(v.ID, v.From)
if err != nil {
return Chat{}, err
@@ -622,7 +652,15 @@ func (c *Client) Recv() (stanza interface{}, err error) {
// Send sends the message wrapped inside an XMPP message stanza body.
func (c *Client) Send(chat Chat) (n int, err error) {
- return fmt.Fprintf(c.conn, "<message to='%s' type='%s' xml:lang='en'>"+"<body>%s</body></message>",
+ var subtext = ``
+ var thdtext = ``
+ if chat.Subject != `` {
+ subtext = `<subject>` + xmlEscape(chat.Subject) + `</subject>`
+ }
+ if chat.Thread != `` {
+ thdtext = `<thread>` + xmlEscape(chat.Thread) + `</thread>`
+ }
+ return fmt.Fprintf(c.conn, "<message to='%s' type='%s' xml:lang='en'>"+subtext+"<body>%s</body>"+thdtext+"</message>",
xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text))
}
@@ -901,24 +939,10 @@ func next(p *xml.Decoder) (xml.Name, interface{}, error) {
return se.Name, nv, err
}
-var xmlSpecial = map[byte]string{
- '<': "&lt;",
- '>': "&gt;",
- '"': "&quot;",
- '\'': "&apos;",
- '&': "&amp;",
-}
-
func xmlEscape(s string) string {
var b bytes.Buffer
- for i := 0; i < len(s); i++ {
- c := s[i]
- if s, ok := xmlSpecial[c]; ok {
- b.WriteString(s)
- } else {
- b.WriteByte(c)
- }
- }
+ xml.Escape(&b, []byte(s))
+
return b.String()
}
diff --git a/vendor/github.com/mattn/go-xmpp/xmpp_information_query.go b/vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
index d89379af..2a699222 100644
--- a/vendor/github.com/mattn/go-xmpp/xmpp_information_query.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
@@ -22,3 +22,10 @@ func (c *Client) RawInformationQuery(from, to, id, iqType, requestNamespace, bod
_, err := fmt.Fprintf(c.conn, xmlIQ, xmlEscape(from), xmlEscape(to), id, iqType, requestNamespace, body)
return id, err
}
+
+// rawInformation send a IQ request with the the payload body to the server
+func (c *Client) RawInformation(from, to, id, iqType, body string) (string, error) {
+ const xmlIQ = "<iq from='%s' to='%s' id='%s' type='%s'>%s</iq>"
+ _, err := fmt.Fprintf(c.conn, xmlIQ, xmlEscape(from), xmlEscape(to), id, iqType, body)
+ return id, err
+}
diff --git a/vendor/github.com/mattn/go-xmpp/xmpp_muc.go b/vendor/github.com/matterbridge/go-xmpp/xmpp_muc.go
index 7b50c128..7b50c128 100644
--- a/vendor/github.com/mattn/go-xmpp/xmpp_muc.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp_muc.go
diff --git a/vendor/github.com/mattn/go-xmpp/xmpp_ping.go b/vendor/github.com/matterbridge/go-xmpp/xmpp_ping.go
index 39269d80..39269d80 100644
--- a/vendor/github.com/mattn/go-xmpp/xmpp_ping.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp_ping.go
diff --git a/vendor/github.com/mattn/go-xmpp/xmpp_subscription.go b/vendor/github.com/matterbridge/go-xmpp/xmpp_subscription.go
index eb293141..eb293141 100644
--- a/vendor/github.com/mattn/go-xmpp/xmpp_subscription.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp_subscription.go
diff --git a/vendor/manifest b/vendor/manifest
index 875c8ff2..7cd182d2 100644
--- a/vendor/manifest
+++ b/vendor/manifest
@@ -287,6 +287,14 @@
"notests": true
},
{
+ "importpath": "github.com/matterbridge/go-xmpp",
+ "repository": "https://github.com/matterbridge/go-xmpp",
+ "vcs": "git",
+ "revision": "0aa93db586ce719b8793aace600ddea0fdc7e828",
+ "branch": "work",
+ "notests": true
+ },
+ {
"importpath": "github.com/matterbridge/gomatrix",
"repository": "https://github.com/matterbridge/gomatrix",
"vcs": "git",
@@ -428,14 +436,6 @@
"notests": true
},
{
- "importpath": "github.com/mattn/go-xmpp",
- "repository": "https://github.com/mattn/go-xmpp",
- "vcs": "git",
- "revision": "d0cdb99fae16437f69616ccc40662b6fe8ac6d47",
- "branch": "master",
- "notests": true
- },
- {
"importpath": "github.com/mgutz/ansi",
"repository": "https://github.com/mgutz/ansi",
"vcs": "git",