From 74f3ea1d2ebb3926b6cd2db63fe47bcb487fe961 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 20 Jan 2022 17:59:57 -0500 Subject: [PATCH] bump irc-go to v0.1.0 --- go.mod | 2 +- go.sum | 2 + vendor/github.com/ergochat/irc-go/LICENSE | 3 +- .../ergochat/irc-go/ircmsg/message.go | 38 ++++++++---- .../ergochat/irc-go/ircmsg/userhost.go | 61 +++++++++++++++++++ .../ergochat/irc-go/ircutils/userhost.go | 56 ----------------- vendor/modules.txt | 2 +- 7 files changed, 94 insertions(+), 70 deletions(-) create mode 100644 vendor/github.com/ergochat/irc-go/ircmsg/userhost.go delete mode 100644 vendor/github.com/ergochat/irc-go/ircutils/userhost.go diff --git a/go.mod b/go.mod index 678c6699..1c85648b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1 github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 - github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce + github.com/ergochat/irc-go v0.1.0 github.com/go-sql-driver/mysql v1.6.0 github.com/go-test/deep v1.0.6 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible diff --git a/go.sum b/go.sum index 09fe42c1..594f4d14 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 h1:QSJIdpr3HOzJD github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775/go.mod h1:d2qvgjD0TvGNSvUs+mZgX090RiJlrzUYW6vtANGOy3A= github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce h1:RfyjeynouKZjmnN8WGzCSrtuHGZ9dwfSYBq405FPoqs= github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce/go.mod h1:2vi7KNpIPWnReB5hmLpl92eMywQvuIeIIGdt/FQCph0= +github.com/ergochat/irc-go v0.1.0 h1:jBHUayERH9SiPOWe4ePDWRztBjIQsU/jwLbbGUuiOWM= +github.com/ergochat/irc-go v0.1.0/go.mod h1:2vi7KNpIPWnReB5hmLpl92eMywQvuIeIIGdt/FQCph0= github.com/ergochat/scram v1.0.2-ergo1 h1:2bYXiRFQH636pT0msOG39fmEYl4Eq+OuutcyDsCix/g= github.com/ergochat/scram v1.0.2-ergo1/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/ergochat/websocket v1.4.2-oragono1 h1:plMUunFBM6UoSCIYCKKclTdy/TkkHfUslhOfJQzfueM= diff --git a/vendor/github.com/ergochat/irc-go/LICENSE b/vendor/github.com/ergochat/irc-go/LICENSE index 05ac8863..4268653e 100644 --- a/vendor/github.com/ergochat/irc-go/LICENSE +++ b/vendor/github.com/ergochat/irc-go/LICENSE @@ -1,4 +1,5 @@ -Copyright (c) 2016-2017 Daniel Oaks +Copyright (c) 2016-2021 Daniel Oaks +Copyright (c) 2018-2021 Shivaram Lingamneni Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/vendor/github.com/ergochat/irc-go/ircmsg/message.go b/vendor/github.com/ergochat/irc-go/ircmsg/message.go index b80dedb5..2d3cd112 100644 --- a/vendor/github.com/ergochat/irc-go/ircmsg/message.go +++ b/vendor/github.com/ergochat/irc-go/ircmsg/message.go @@ -65,7 +65,7 @@ var ( // extended by the IRCv3 Message Tags specification with the introduction // of message tags. type Message struct { - Prefix string + Source string Command string Params []string forceTrailing bool @@ -154,6 +154,22 @@ func (msg *Message) ClientOnlyTags() map[string]string { return msg.clientOnlyTags } +// Nick returns the name component of the message source (typically a nickname, +// but possibly a server name). +func (msg *Message) Nick() (nick string) { + nuh, err := ParseNUH(msg.Source) + if err == nil { + return nuh.Name + } + return +} + +// NUH returns the source of the message as a parsed NUH ("nick-user-host"); +// if the source is not well-formed as a NUH, it returns an error. +func (msg *Message) NUH() (nuh NUH, err error) { + return ParseNUH(msg.Source) +} + // ParseLine creates and returns a message from the given IRC line. func ParseLine(line string) (ircmsg Message, err error) { return parseLine(line, 0, 0) @@ -229,15 +245,15 @@ func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg Messa // by one or more ASCII SPACE characters" line = trimInitialSpaces(line) - // prefix + // source if 0 < len(line) && line[0] == ':' { - prefixEnd := strings.IndexByte(line, ' ') - if prefixEnd == -1 { + sourceEnd := strings.IndexByte(line, ' ') + if sourceEnd == -1 { return ircmsg, ErrorLineIsEmpty } - ircmsg.Prefix = line[1:prefixEnd] - // skip over the prefix and the separating space - line = line[prefixEnd+1:] + ircmsg.Source = line[1:sourceEnd] + // skip over the source and the separating space + line = line[sourceEnd+1:] } line = trimInitialSpaces(line) @@ -312,8 +328,8 @@ func (ircmsg *Message) parseTags(tags string) (err error) { } // MakeMessage provides a simple way to create a new Message. -func MakeMessage(tags map[string]string, prefix string, command string, params ...string) (ircmsg Message) { - ircmsg.Prefix = prefix +func MakeMessage(tags map[string]string, source string, command string, params ...string) (ircmsg Message) { + ircmsg.Source = source ircmsg.Command = command ircmsg.Params = params ircmsg.UpdateTags(tags) @@ -411,9 +427,9 @@ func (ircmsg *Message) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagData return nil, ErrorTagsTooLong } - if len(ircmsg.Prefix) > 0 { + if len(ircmsg.Source) > 0 { buf.WriteByte(':') - buf.WriteString(ircmsg.Prefix) + buf.WriteString(ircmsg.Source) buf.WriteByte(' ') } diff --git a/vendor/github.com/ergochat/irc-go/ircmsg/userhost.go b/vendor/github.com/ergochat/irc-go/ircmsg/userhost.go new file mode 100644 index 00000000..ca8406d2 --- /dev/null +++ b/vendor/github.com/ergochat/irc-go/ircmsg/userhost.go @@ -0,0 +1,61 @@ +// written by Daniel Oaks +// released under the ISC license + +package ircmsg + +import ( + "errors" + "strings" +) + +var ( + MalformedNUH = errors.New("NUH is malformed") +) + +// NUH holds a parsed name!user@host source ("prefix") of an IRC message. +// The Name member will be either a nickname (in the case of a user-initiated +// message) or a server name (in the case of a server-initiated numeric, +// command, or NOTICE). +type NUH struct { + Name string + User string + Host string +} + +// ParseNUH parses a NUH source of an IRC message into its constituent parts; +// name (nickname or server name), username, and hostname. +func ParseNUH(in string) (out NUH, err error) { + if len(in) == 0 { + return out, MalformedNUH + } + + hostStart := strings.IndexByte(in, '@') + if hostStart != -1 { + out.Host = in[hostStart+1:] + in = in[:hostStart] + } + userStart := strings.IndexByte(in, '!') + if userStart != -1 { + out.User = in[userStart+1:] + in = in[:userStart] + } + out.Name = in + + return +} + +// Canonical returns the canonical string representation of the NUH. +func (nuh *NUH) Canonical() (result string) { + var out strings.Builder + out.Grow(len(nuh.Name) + len(nuh.User) + len(nuh.Host) + 2) + out.WriteString(nuh.Name) + if len(nuh.User) != 0 { + out.WriteByte('!') + out.WriteString(nuh.User) + } + if len(nuh.Host) != 0 { + out.WriteByte('@') + out.WriteString(nuh.Host) + } + return out.String() +} diff --git a/vendor/github.com/ergochat/irc-go/ircutils/userhost.go b/vendor/github.com/ergochat/irc-go/ircutils/userhost.go deleted file mode 100644 index 53b0d75c..00000000 --- a/vendor/github.com/ergochat/irc-go/ircutils/userhost.go +++ /dev/null @@ -1,56 +0,0 @@ -// written by Daniel Oaks -// released under the ISC license - -package ircutils - -import "strings" - -// UserHost holds a username+host combination -type UserHost struct { - Nick string - User string - Host string -} - -// ParseUserhost takes a userhost string and returns a UserHost instance. -func ParseUserhost(userhost string) UserHost { - var uh UserHost - - if len(userhost) == 0 { - return uh - } - - if strings.Contains(userhost, "!") { - usersplit := strings.SplitN(userhost, "!", 2) - var rest string - if len(usersplit) == 2 { - uh.Nick = usersplit[0] - rest = usersplit[1] - } else { - rest = usersplit[0] - } - - hostsplit := strings.SplitN(rest, "@", 2) - if len(hostsplit) == 2 { - uh.User = hostsplit[0] - uh.Host = hostsplit[1] - } else { - uh.User = hostsplit[0] - } - } else { - hostsplit := strings.SplitN(userhost, "@", 2) - if len(hostsplit) == 2 { - uh.Nick = hostsplit[0] - uh.Host = hostsplit[1] - } else { - uh.User = hostsplit[0] - } - } - - return uh -} - -// // Canonical returns the canonical string representation of the userhost. -// func (uh *UserHost) Canonical() string { -// return "" -// } diff --git a/vendor/modules.txt b/vendor/modules.txt index fef02789..6c23d3fc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -16,7 +16,7 @@ github.com/ergochat/confusables # github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 ## explicit github.com/ergochat/go-ident -# github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce +# github.com/ergochat/irc-go v0.1.0 ## explicit; go 1.15 github.com/ergochat/irc-go/ircfmt github.com/ergochat/irc-go/ircmsg