Browse Source

bump irc-go to include new ircutils function

tags/v2.6.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
074a5a077e

+ 1
- 1
go.mod View File

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

+ 2
- 0
go.sum View File

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

+ 9
- 0
vendor/github.com/goshuirc/irc-go/ircutils/doc.go View File

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

+ 41
- 0
vendor/github.com/goshuirc/irc-go/ircutils/hostnames.go View File

@@ -0,0 +1,41 @@
1
+// written by Daniel Oaks <daniel@danieloaks.net>
2
+// released under the ISC license
3
+
4
+package ircutils
5
+
6
+import "strings"
7
+
8
+var allowedHostnameChars = "abcdefghijklmnopqrstuvwxyz1234567890-."
9
+
10
+// HostnameIsValid provides a way for servers to check whether a looked-up client
11
+// hostname is valid (see InspIRCd #1033 for why this is required).
12
+//
13
+// This function shouldn't be called by clients since they don't need to validate
14
+// hostnames for IRC use, just by servers that need to confirm hostnames of incoming
15
+// clients.
16
+//
17
+// In addition to this function, servers should impose their own limits on max
18
+// hostname length -- this function limits it to 200 but most servers will probably
19
+// want to make it smaller than that.
20
+func HostnameIsValid(hostname string) bool {
21
+	// IRC hostnames specifically require a period, rough limit of 200 chars
22
+	if !strings.Contains(hostname, ".") || len(hostname) < 1 || len(hostname) > 200 {
23
+		return false
24
+	}
25
+
26
+	// ensure each part of hostname is valid
27
+	for _, part := range strings.Split(hostname, ".") {
28
+		if len(part) < 1 || len(part) > 63 || strings.HasPrefix(part, "-") || strings.HasSuffix(part, "-") {
29
+			return false
30
+		}
31
+	}
32
+
33
+	// ensure all chars of hostname are valid
34
+	for _, char := range strings.Split(strings.ToLower(hostname), "") {
35
+		if !strings.Contains(allowedHostnameChars, char) {
36
+			return false
37
+		}
38
+	}
39
+
40
+	return true
41
+}

+ 25
- 0
vendor/github.com/goshuirc/irc-go/ircutils/unicode.go View File

@@ -0,0 +1,25 @@
1
+// Copyright (c) 2021 Shivaram Lingamneni
2
+// Released under the MIT License
3
+
4
+package ircutils
5
+
6
+import (
7
+	"unicode/utf8"
8
+)
9
+
10
+// truncate a message, taking care not to make valid UTF8 into invalid UTF8
11
+func TruncateUTF8Safe(message string, byteLimit int) (result string) {
12
+	if len(message) <= byteLimit {
13
+		return message
14
+	}
15
+	message = message[:byteLimit]
16
+	for i := 0; i < (utf8.UTFMax - 1); i++ {
17
+		r, n := utf8.DecodeLastRuneInString(message)
18
+		if r == utf8.RuneError && n <= 1 {
19
+			message = message[:len(message)-1]
20
+		} else {
21
+			break
22
+		}
23
+	}
24
+	return message
25
+}

+ 56
- 0
vendor/github.com/goshuirc/irc-go/ircutils/userhost.go View File

@@ -0,0 +1,56 @@
1
+// written by Daniel Oaks <daniel@danieloaks.net>
2
+// released under the ISC license
3
+
4
+package ircutils
5
+
6
+import "strings"
7
+
8
+// UserHost holds a username+host combination
9
+type UserHost struct {
10
+	Nick string
11
+	User string
12
+	Host string
13
+}
14
+
15
+// ParseUserhost takes a userhost string and returns a UserHost instance.
16
+func ParseUserhost(userhost string) UserHost {
17
+	var uh UserHost
18
+
19
+	if len(userhost) == 0 {
20
+		return uh
21
+	}
22
+
23
+	if strings.Contains(userhost, "!") {
24
+		usersplit := strings.SplitN(userhost, "!", 2)
25
+		var rest string
26
+		if len(usersplit) == 2 {
27
+			uh.Nick = usersplit[0]
28
+			rest = usersplit[1]
29
+		} else {
30
+			rest = usersplit[0]
31
+		}
32
+
33
+		hostsplit := strings.SplitN(rest, "@", 2)
34
+		if len(hostsplit) == 2 {
35
+			uh.User = hostsplit[0]
36
+			uh.Host = hostsplit[1]
37
+		} else {
38
+			uh.User = hostsplit[0]
39
+		}
40
+	} else {
41
+		hostsplit := strings.SplitN(userhost, "@", 2)
42
+		if len(hostsplit) == 2 {
43
+			uh.Nick = hostsplit[0]
44
+			uh.Host = hostsplit[1]
45
+		} else {
46
+			uh.User = hostsplit[0]
47
+		}
48
+	}
49
+
50
+	return uh
51
+}
52
+
53
+// // Canonical returns the canonical string representation of the userhost.
54
+// func (uh *UserHost) Canonical() string {
55
+// 	return ""
56
+// }

+ 2
- 1
vendor/modules.txt View File

@@ -21,11 +21,12 @@ github.com/go-sql-driver/mysql
21 21
 # github.com/gorilla/websocket v1.4.2 => github.com/oragono/websocket v1.4.2-oragono1
22 22
 ## explicit
23 23
 github.com/gorilla/websocket
24
-# github.com/goshuirc/irc-go v0.0.0-20210311004346-ea7a188a73fe
24
+# github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef
25 25
 ## explicit
26 26
 github.com/goshuirc/irc-go/ircfmt
27 27
 github.com/goshuirc/irc-go/ircmsg
28 28
 github.com/goshuirc/irc-go/ircreader
29
+github.com/goshuirc/irc-go/ircutils
29 30
 # github.com/onsi/ginkgo v1.12.0
30 31
 ## explicit
31 32
 # github.com/onsi/gomega v1.9.0

Loading…
Cancel
Save