From ff9479670070c0f1de4cf66622df7b69736dd22a Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 14 Aug 2016 21:48:51 +0200 Subject: Refactor bridge. Allows bridging between every protocol --- vendor/github.com/thoj/go-ircevent/irc.go | 1 - vendor/github.com/thoj/go-ircevent/irc_callback.go | 4 +- vendor/github.com/thoj/go-ircevent/irc_sasl.go | 54 ++++++++++++++++++++++ vendor/github.com/thoj/go-ircevent/sasl.go | 54 ---------------------- vendor/manifest | 2 +- 5 files changed, 57 insertions(+), 58 deletions(-) create mode 100644 vendor/github.com/thoj/go-ircevent/irc_sasl.go delete mode 100644 vendor/github.com/thoj/go-ircevent/sasl.go (limited to 'vendor') diff --git a/vendor/github.com/thoj/go-ircevent/irc.go b/vendor/github.com/thoj/go-ircevent/irc.go index 0ba1d650..3981761a 100644 --- a/vendor/github.com/thoj/go-ircevent/irc.go +++ b/vendor/github.com/thoj/go-ircevent/irc.go @@ -152,7 +152,6 @@ func (irc *Connection) writeLoop() { } } } - return } // Pings the server if we have not received any messages for 5 minutes diff --git a/vendor/github.com/thoj/go-ircevent/irc_callback.go b/vendor/github.com/thoj/go-ircevent/irc_callback.go index 109cbb1f..b5622367 100644 --- a/vendor/github.com/thoj/go-ircevent/irc_callback.go +++ b/vendor/github.com/thoj/go-ircevent/irc_callback.go @@ -33,7 +33,7 @@ func (irc *Connection) RemoveCallback(eventcode string, i int) bool { delete(irc.events[eventcode], i) return true } - irc.Log.Printf("Event found, but no callback found at id %s\n", i) + irc.Log.Printf("Event found, but no callback found at id %d\n", i) return false } @@ -64,7 +64,7 @@ func (irc *Connection) ReplaceCallback(eventcode string, i int, callback func(*E event[i] = callback return } - irc.Log.Printf("Event found, but no callback found at id %s\n", i) + irc.Log.Printf("Event found, but no callback found at id %d\n", i) } irc.Log.Printf("Event not found. Use AddCallBack\n") } diff --git a/vendor/github.com/thoj/go-ircevent/irc_sasl.go b/vendor/github.com/thoj/go-ircevent/irc_sasl.go new file mode 100644 index 00000000..e5ff9e38 --- /dev/null +++ b/vendor/github.com/thoj/go-ircevent/irc_sasl.go @@ -0,0 +1,54 @@ +package irc + +import ( + "encoding/base64" + "errors" + "fmt" + "strings" +) + +type SASLResult struct { + Failed bool + Err error +} + +func (irc *Connection) setupSASLCallbacks(result chan<- *SASLResult) { + irc.AddCallback("CAP", func(e *Event) { + if len(e.Arguments) == 3 { + if e.Arguments[1] == "LS" { + if !strings.Contains(e.Arguments[2], "sasl") { + result <- &SASLResult{true, errors.New("no SASL capability " + e.Arguments[2])} + } + } + if e.Arguments[1] == "ACK" { + if irc.SASLMech != "PLAIN" { + result <- &SASLResult{true, errors.New("only PLAIN is supported")} + } + irc.SendRaw("AUTHENTICATE " + irc.SASLMech) + } + } + }) + irc.AddCallback("AUTHENTICATE", func(e *Event) { + str := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s\x00%s\x00%s", irc.SASLLogin, irc.SASLLogin, irc.SASLPassword))) + irc.SendRaw("AUTHENTICATE " + str) + }) + irc.AddCallback("901", func(e *Event) { + irc.SendRaw("CAP END") + irc.SendRaw("QUIT") + result <- &SASLResult{true, errors.New(e.Arguments[1])} + }) + irc.AddCallback("902", func(e *Event) { + irc.SendRaw("CAP END") + irc.SendRaw("QUIT") + result <- &SASLResult{true, errors.New(e.Arguments[1])} + }) + irc.AddCallback("903", func(e *Event) { + irc.SendRaw("CAP END") + result <- &SASLResult{false, nil} + }) + irc.AddCallback("904", func(e *Event) { + irc.SendRaw("CAP END") + irc.SendRaw("QUIT") + result <- &SASLResult{true, errors.New(e.Arguments[1])} + }) +} diff --git a/vendor/github.com/thoj/go-ircevent/sasl.go b/vendor/github.com/thoj/go-ircevent/sasl.go deleted file mode 100644 index e5ff9e38..00000000 --- a/vendor/github.com/thoj/go-ircevent/sasl.go +++ /dev/null @@ -1,54 +0,0 @@ -package irc - -import ( - "encoding/base64" - "errors" - "fmt" - "strings" -) - -type SASLResult struct { - Failed bool - Err error -} - -func (irc *Connection) setupSASLCallbacks(result chan<- *SASLResult) { - irc.AddCallback("CAP", func(e *Event) { - if len(e.Arguments) == 3 { - if e.Arguments[1] == "LS" { - if !strings.Contains(e.Arguments[2], "sasl") { - result <- &SASLResult{true, errors.New("no SASL capability " + e.Arguments[2])} - } - } - if e.Arguments[1] == "ACK" { - if irc.SASLMech != "PLAIN" { - result <- &SASLResult{true, errors.New("only PLAIN is supported")} - } - irc.SendRaw("AUTHENTICATE " + irc.SASLMech) - } - } - }) - irc.AddCallback("AUTHENTICATE", func(e *Event) { - str := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s\x00%s\x00%s", irc.SASLLogin, irc.SASLLogin, irc.SASLPassword))) - irc.SendRaw("AUTHENTICATE " + str) - }) - irc.AddCallback("901", func(e *Event) { - irc.SendRaw("CAP END") - irc.SendRaw("QUIT") - result <- &SASLResult{true, errors.New(e.Arguments[1])} - }) - irc.AddCallback("902", func(e *Event) { - irc.SendRaw("CAP END") - irc.SendRaw("QUIT") - result <- &SASLResult{true, errors.New(e.Arguments[1])} - }) - irc.AddCallback("903", func(e *Event) { - irc.SendRaw("CAP END") - result <- &SASLResult{false, nil} - }) - irc.AddCallback("904", func(e *Event) { - irc.SendRaw("CAP END") - irc.SendRaw("QUIT") - result <- &SASLResult{true, errors.New(e.Arguments[1])} - }) -} diff --git a/vendor/manifest b/vendor/manifest index 417c6ddd..98c01162 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -179,4 +179,4 @@ "notests": true } ] -} \ No newline at end of file +} -- cgit v1.2.3