3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 02:32:39 +01:00

bump irc-go to include new ircutils function

This commit is contained in:
Shivaram Lingamneni 2021-03-18 03:56:57 -04:00
parent e447c61c73
commit 074a5a077e
7 changed files with 136 additions and 2 deletions

2
go.mod
View File

@ -10,7 +10,7 @@ require (
github.com/go-sql-driver/mysql v1.5.0
github.com/go-test/deep v1.0.6 // indirect
github.com/gorilla/websocket v1.4.2
github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe
github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef
github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.9.0 // indirect
github.com/oragono/confusables v0.0.0-20201108231250-4ab98ab61fb1

2
go.sum
View File

@ -44,6 +44,8 @@ github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96 h1:sihI3HsrJWyS4Mt
github.com/goshuirc/irc-go v0.0.0-20210304031553-cf78e9176f96/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe h1:5UsPgeXJBkFgJK3Ml0nj6ljasjd26xiUxALnDJHmipE=
github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef h1:07e6GcSuNh1BoZJigrvaJSpe2PsYJgkYETOuGKpM2co=
github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

9
vendor/github.com/goshuirc/irc-go/ircutils/doc.go generated vendored Normal file
View File

@ -0,0 +1,9 @@
// written by Daniel Oaks <daniel@danieloaks.net>
// released under the ISC license
/*
Package ircutils provides small, useful utility functions and classes.
This package is in an alpha stage.
*/
package ircutils

View File

@ -0,0 +1,41 @@
// written by Daniel Oaks <daniel@danieloaks.net>
// released under the ISC license
package ircutils
import "strings"
var allowedHostnameChars = "abcdefghijklmnopqrstuvwxyz1234567890-."
// HostnameIsValid provides a way for servers to check whether a looked-up client
// hostname is valid (see InspIRCd #1033 for why this is required).
//
// This function shouldn't be called by clients since they don't need to validate
// hostnames for IRC use, just by servers that need to confirm hostnames of incoming
// clients.
//
// In addition to this function, servers should impose their own limits on max
// hostname length -- this function limits it to 200 but most servers will probably
// want to make it smaller than that.
func HostnameIsValid(hostname string) bool {
// IRC hostnames specifically require a period, rough limit of 200 chars
if !strings.Contains(hostname, ".") || len(hostname) < 1 || len(hostname) > 200 {
return false
}
// ensure each part of hostname is valid
for _, part := range strings.Split(hostname, ".") {
if len(part) < 1 || len(part) > 63 || strings.HasPrefix(part, "-") || strings.HasSuffix(part, "-") {
return false
}
}
// ensure all chars of hostname are valid
for _, char := range strings.Split(strings.ToLower(hostname), "") {
if !strings.Contains(allowedHostnameChars, char) {
return false
}
}
return true
}

25
vendor/github.com/goshuirc/irc-go/ircutils/unicode.go generated vendored Normal file
View File

@ -0,0 +1,25 @@
// Copyright (c) 2021 Shivaram Lingamneni
// Released under the MIT License
package ircutils
import (
"unicode/utf8"
)
// truncate a message, taking care not to make valid UTF8 into invalid UTF8
func TruncateUTF8Safe(message string, byteLimit int) (result string) {
if len(message) <= byteLimit {
return message
}
message = message[:byteLimit]
for i := 0; i < (utf8.UTFMax - 1); i++ {
r, n := utf8.DecodeLastRuneInString(message)
if r == utf8.RuneError && n <= 1 {
message = message[:len(message)-1]
} else {
break
}
}
return message
}

56
vendor/github.com/goshuirc/irc-go/ircutils/userhost.go generated vendored Normal file
View File

@ -0,0 +1,56 @@
// written by Daniel Oaks <daniel@danieloaks.net>
// 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 ""
// }

3
vendor/modules.txt vendored
View File

@ -21,11 +21,12 @@ github.com/go-sql-driver/mysql
# github.com/gorilla/websocket v1.4.2 => github.com/oragono/websocket v1.4.2-oragono1
## explicit
github.com/gorilla/websocket
# github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe
# github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef
## explicit
github.com/goshuirc/irc-go/ircfmt
github.com/goshuirc/irc-go/ircmsg
github.com/goshuirc/irc-go/ircreader
github.com/goshuirc/irc-go/ircutils
# github.com/onsi/ginkgo v1.12.0
## explicit
# github.com/onsi/gomega v1.9.0