|
@@ -4,17 +4,15 @@
|
4
|
4
|
package irc
|
5
|
5
|
|
6
|
6
|
import (
|
7
|
|
- "bytes"
|
8
|
7
|
"fmt"
|
9
|
|
- "hash/crc32"
|
10
|
8
|
"sort"
|
11
|
|
- "strconv"
|
12
|
9
|
"strings"
|
13
|
10
|
"time"
|
14
|
11
|
|
15
|
12
|
"github.com/goshuirc/irc-go/ircfmt"
|
16
|
13
|
"github.com/oragono/oragono/irc/modes"
|
17
|
14
|
"github.com/oragono/oragono/irc/sno"
|
|
15
|
+ "github.com/oragono/oragono/irc/utils"
|
18
|
16
|
)
|
19
|
17
|
|
20
|
18
|
const chanservHelp = `ChanServ lets you register and manage channels.`
|
|
@@ -352,7 +350,7 @@ func csUnregisterHandler(server *Server, client *Client, command string, params
|
352
|
350
|
}
|
353
|
351
|
|
354
|
352
|
info := channel.ExportRegistration(0)
|
355
|
|
- expectedCode := unregisterConfirmationCode(info.Name, info.RegisteredAt)
|
|
353
|
+ expectedCode := utils.ConfirmationCode(info.Name, info.RegisteredAt)
|
356
|
354
|
if expectedCode != verificationCode {
|
357
|
355
|
csNotice(rb, ircfmt.Unescape(client.t("$bWarning: unregistering this channel will remove all stored channel attributes.$b")))
|
358
|
356
|
csNotice(rb, fmt.Sprintf(client.t("To confirm channel unregistration, type: /CS UNREGISTER %[1]s %[2]s"), channelKey, expectedCode))
|
|
@@ -363,14 +361,6 @@ func csUnregisterHandler(server *Server, client *Client, command string, params
|
363
|
361
|
csNotice(rb, fmt.Sprintf(client.t("Channel %s is now unregistered"), channelKey))
|
364
|
362
|
}
|
365
|
363
|
|
366
|
|
-// deterministically generates a confirmation code for unregistering a channel / account
|
367
|
|
-func unregisterConfirmationCode(name string, registeredAt time.Time) (code string) {
|
368
|
|
- var codeInput bytes.Buffer
|
369
|
|
- codeInput.WriteString(name)
|
370
|
|
- codeInput.WriteString(strconv.FormatInt(registeredAt.Unix(), 16))
|
371
|
|
- return strconv.Itoa(int(crc32.ChecksumIEEE(codeInput.Bytes())))
|
372
|
|
-}
|
373
|
|
-
|
374
|
364
|
func csClearHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
375
|
365
|
channel := server.channels.Get(params[0])
|
376
|
366
|
if channel == nil {
|
|
@@ -426,7 +416,7 @@ func csTransferHandler(server *Server, client *Client, command string, params []
|
426
|
416
|
return
|
427
|
417
|
}
|
428
|
418
|
if targetAccount.NameCasefolded != account {
|
429
|
|
- expectedCode := unregisterConfirmationCode(regInfo.Name, regInfo.RegisteredAt)
|
|
419
|
+ expectedCode := utils.ConfirmationCode(regInfo.Name, regInfo.RegisteredAt)
|
430
|
420
|
codeValidated := 2 < len(params) && params[2] == expectedCode
|
431
|
421
|
if !codeValidated {
|
432
|
422
|
csNotice(rb, ircfmt.Unescape(client.t("$bWarning: you are about to transfer control of your channel to another user.$b")))
|