소스 검색

General comments, fix misspellings and lints

tags/v0.8.1
Daniel Oaks 7 년 전
부모
커밋
1c0c4841a1
9개의 변경된 파일81개의 추가작업 그리고 38개의 파일을 삭제
  1. 1
    1
      irc/accountreg.go
  2. 33
    16
      irc/capability.go
  3. 14
    9
      irc/client.go
  4. 1
    0
      irc/config.go
  5. 5
    2
      irc/help.go
  6. 2
    0
      irc/logger/logger.go
  7. 8
    2
      irc/modes.go
  8. 11
    7
      irc/websocket.go
  9. 6
    1
      irc/whowas.go

+ 1
- 1
irc/accountreg.go 파일 보기

@@ -182,7 +182,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
182 182
 		}
183 183
 	}
184 184
 	if credentialType == "certfp" && client.certfp == "" {
185
-		client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, "You are not using a certificiate")
185
+		client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, "You are not using a TLS certificate")
186 186
 		removeFailedAccRegisterData(server.store, casefoldedAccount)
187 187
 		return false
188 188
 	}

+ 33
- 16
irc/capability.go 파일 보기

@@ -14,22 +14,39 @@ import (
14 14
 type Capability string
15 15
 
16 16
 const (
17
-	AccountNotify   Capability = "account-notify"
18
-	AccountTag      Capability = "account-tag"
19
-	AwayNotify      Capability = "away-notify"
20
-	CapNotify       Capability = "cap-notify"
21
-	ChgHost         Capability = "chghost"
22
-	EchoMessage     Capability = "echo-message"
23
-	ExtendedJoin    Capability = "extended-join"
24
-	InviteNotify    Capability = "invite-notify"
25
-	MaxLine         Capability = "draft/maxline"
26
-	MessageIDs      Capability = "draft/message-ids"
27
-	MessageTags     Capability = "draft/message-tags-0.2"
28
-	MultiPrefix     Capability = "multi-prefix"
29
-	Rename          Capability = "draft/rename"
30
-	SASL            Capability = "sasl"
31
-	ServerTime      Capability = "server-time"
32
-	STS             Capability = "draft/sts"
17
+	// AccountNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/account-notify-3.1.html
18
+	AccountNotify Capability = "account-notify"
19
+	// AccountTag is this IRCv3 capability: http://ircv3.net/specs/extensions/account-tag-3.2.html
20
+	AccountTag Capability = "account-tag"
21
+	// AwayNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/away-notify-3.1.html
22
+	AwayNotify Capability = "away-notify"
23
+	// CapNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/cap-notify-3.2.html
24
+	CapNotify Capability = "cap-notify"
25
+	// ChgHost is this IRCv3 capability: http://ircv3.net/specs/extensions/chghost-3.2.html
26
+	ChgHost Capability = "chghost"
27
+	// EchoMessage is this IRCv3 capability: http://ircv3.net/specs/extensions/echo-message-3.2.html
28
+	EchoMessage Capability = "echo-message"
29
+	// ExtendedJoin is this IRCv3 capability: http://ircv3.net/specs/extensions/extended-join-3.1.html
30
+	ExtendedJoin Capability = "extended-join"
31
+	// InviteNotify is this IRCv3 capability: http://ircv3.net/specs/extensions/invite-notify-3.2.html
32
+	InviteNotify Capability = "invite-notify"
33
+	// MaxLine is this proposed capability: https://github.com/DanielOaks/ircv3-specifications/blob/master+line-lengths/extensions/line-lengths.md
34
+	MaxLine Capability = "draft/maxline"
35
+	// MessageIDs is this draft IRCv3 capability: http://ircv3.net/specs/extensions/message-ids.html
36
+	MessageIDs Capability = "draft/message-ids"
37
+	// MessageTags is this draft IRCv3 capability: http://ircv3.net/specs/core/message-tags-3.3.html
38
+	MessageTags Capability = "draft/message-tags-0.2"
39
+	// MultiPrefix is this IRCv3 capability: http://ircv3.net/specs/extensions/multi-prefix-3.1.html
40
+	MultiPrefix Capability = "multi-prefix"
41
+	// Rename is this proposed capability: https://github.com/SaberUK/ircv3-specifications/blob/rename/extensions/rename.md
42
+	Rename Capability = "draft/rename"
43
+	// SASL is this IRCv3 capability: http://ircv3.net/specs/extensions/sasl-3.2.html
44
+	SASL Capability = "sasl"
45
+	// ServerTime is this IRCv3 capability: http://ircv3.net/specs/extensions/server-time-3.2.html
46
+	ServerTime Capability = "server-time"
47
+	// STS is this draft IRCv3 capability: http://ircv3.net/specs/core/sts-3.3.html
48
+	STS Capability = "draft/sts"
49
+	// UserhostInNames is this IRCv3 capability: http://ircv3.net/specs/extensions/userhost-in-names-3.2.html
33 50
 	UserhostInNames Capability = "userhost-in-names"
34 51
 )
35 52
 

+ 14
- 9
irc/client.go 파일 보기

@@ -23,14 +23,19 @@ import (
23 23
 )
24 24
 
25 25
 const (
26
-	IDLE_TIMEOUT        = time.Minute + time.Second*30 // how long before a client is considered idle
27
-	QUIT_TIMEOUT        = time.Minute                  // how long after idle before a client is kicked
26
+	// IdleTimeout is how long without traffic before a client's considered idle.
27
+	IdleTimeout = time.Minute + time.Second*30
28
+	// QuitTimeout is how long without traffic (after they're considered idle) that clients are killed.
29
+	QuitTimeout = time.Minute
30
+	// IdentTimeoutSeconds is how many seconds before our ident (username) check times out.
28 31
 	IdentTimeoutSeconds = 5
29 32
 )
30 33
 
31 34
 var (
32
-	TIMEOUT_STATED_SECONDS = strconv.Itoa(int((IDLE_TIMEOUT + QUIT_TIMEOUT).Seconds()))
33
-	ErrNickAlreadySet      = errors.New("Nickname is already set")
35
+	// TimeoutStatedSeconds is how many seconds before clients are timed out (IdleTimeout plus QuitTimeout).
36
+	TimeoutStatedSeconds = strconv.Itoa(int((IdleTimeout + QuitTimeout).Seconds()))
37
+	// ErrNickAlreadySet is a weird error that's sent when the server's consistency has been compromised.
38
+	ErrNickAlreadySet = errors.New("Nickname is already set")
34 39
 )
35 40
 
36 41
 // Client is an IRC client.
@@ -233,9 +238,9 @@ func (client *Client) Touch() {
233 238
 	}
234 239
 
235 240
 	if client.idleTimer == nil {
236
-		client.idleTimer = time.AfterFunc(IDLE_TIMEOUT, client.connectionIdle)
241
+		client.idleTimer = time.AfterFunc(IdleTimeout, client.connectionIdle)
237 242
 	} else {
238
-		client.idleTimer.Reset(IDLE_TIMEOUT)
243
+		client.idleTimer.Reset(IdleTimeout)
239 244
 	}
240 245
 }
241 246
 
@@ -248,9 +253,9 @@ func (client *Client) connectionIdle() {
248 253
 	client.Send(nil, "", "PING", client.nick)
249 254
 
250 255
 	if client.quitTimer == nil {
251
-		client.quitTimer = time.AfterFunc(QUIT_TIMEOUT, client.connectionTimeout)
256
+		client.quitTimer = time.AfterFunc(QuitTimeout, client.connectionTimeout)
252 257
 	} else {
253
-		client.quitTimer.Reset(QUIT_TIMEOUT)
258
+		client.quitTimer.Reset(QuitTimeout)
254 259
 	}
255 260
 }
256 261
 
@@ -258,7 +263,7 @@ func (client *Client) connectionIdle() {
258 263
 // ping or any other activity back from the client. When this happens we assume the
259 264
 // connection has died and remove the client from the network.
260 265
 func (client *Client) connectionTimeout() {
261
-	client.Quit(fmt.Sprintf("Ping timeout: %s seconds", TIMEOUT_STATED_SECONDS))
266
+	client.Quit(fmt.Sprintf("Ping timeout: %s seconds", TimeoutStatedSeconds))
262 267
 	client.isQuitting = true
263 268
 }
264 269
 

+ 1
- 0
irc/config.go 파일 보기

@@ -98,6 +98,7 @@ type OperConfig struct {
98 98
 	Modes     string
99 99
 }
100 100
 
101
+// PasswordBytes returns the bytes represented by the password hash.
101 102
 func (conf *OperConfig) PasswordBytes() []byte {
102 103
 	bytes, err := DecodePasswordHash(conf.Password)
103 104
 	if err != nil {

+ 5
- 2
irc/help.go 파일 보기

@@ -15,9 +15,12 @@ import (
15 15
 type HelpEntryType int
16 16
 
17 17
 const (
18
-	CommandHelpEntry     HelpEntryType = 0
18
+	// CommandHelpEntry is a help entry explaining a client command.
19
+	CommandHelpEntry HelpEntryType = 0
20
+	// InformationHelpEntry is a help entry explaining general server info.
19 21
 	InformationHelpEntry HelpEntryType = 1
20
-	ISupportHelpEntry    HelpEntryType = 2
22
+	// ISupportHelpEntry is a help entry explaining a specific RPL_ISUPPORT token.
23
+	ISupportHelpEntry HelpEntryType = 2
21 24
 )
22 25
 
23 26
 // HelpEntry represents an entry in the Help map.

+ 2
- 0
irc/logger/logger.go 파일 보기

@@ -32,6 +32,7 @@ const (
32 32
 )
33 33
 
34 34
 var (
35
+	// LogLevelNames takes a config name and gives the real log level.
35 36
 	LogLevelNames = map[string]Level{
36 37
 		"debug":    LogDebug,
37 38
 		"info":     LogInfo,
@@ -41,6 +42,7 @@ var (
41 42
 		"error":    LogError,
42 43
 		"errors":   LogError,
43 44
 	}
45
+	// LogLevelDisplayNames gives the display name to use for our log levels.
44 46
 	LogLevelDisplayNames = map[Level]string{
45 47
 		LogDebug:   "debug",
46 48
 		LogInfo:    "info",

+ 8
- 2
irc/modes.go 파일 보기

@@ -22,8 +22,11 @@ func (op ModeOp) String() string {
22 22
 }
23 23
 
24 24
 const (
25
-	Add    ModeOp = '+'
26
-	List   ModeOp = '='
25
+	// Add is used when adding the given key.
26
+	Add ModeOp = '+'
27
+	// List is used when listing modes (for instance, listing the current bans on a channel).
28
+	List ModeOp = '='
29
+	// Remove is used when taking away the given key.
27 30
 	Remove ModeOp = '-'
28 31
 )
29 32
 
@@ -105,6 +108,7 @@ const (
105 108
 )
106 109
 
107 110
 var (
111
+	// SupportedUserModes are the user modes that we actually support (modifying).
108 112
 	SupportedUserModes = Modes{
109 113
 		Away, Invisible, Operator, ServerNotice, UserRoleplaying,
110 114
 	}
@@ -135,6 +139,7 @@ var (
135 139
 	Halfop          Mode = 'h' // arg
136 140
 	Voice           Mode = 'v' // arg
137 141
 
142
+	// SupportedChannelModes are the channel modes that we support.
138 143
 	SupportedChannelModes = Modes{
139 144
 		BanMask, ExceptMask, InviteMask, InviteOnly, Key, NoOutside,
140 145
 		OpOnlyTopic, Secret, UserLimit, ChanRoleplaying,
@@ -142,6 +147,7 @@ var (
142 147
 	// supportedChannelModesString acts as a cache for when we introduce users
143 148
 	supportedChannelModesString = SupportedChannelModes.String()
144 149
 
150
+	// DefaultChannelModes are enabled on brand new channels when they're created.
145 151
 	DefaultChannelModes = Modes{
146 152
 		NoOutside, OpOnlyTopic,
147 153
 	}

+ 11
- 7
irc/websocket.go 파일 보기

@@ -25,12 +25,14 @@ var upgrader = websocket.Upgrader{
25 25
 	CheckOrigin: func(r *http.Request) bool { return true },
26 26
 }
27 27
 
28
+// WSContainer holds the websocket.
28 29
 type WSContainer struct {
29 30
 	*websocket.Conn
30 31
 }
31 32
 
32
-func (this WSContainer) Read(msg []byte) (int, error) {
33
-	ty, bytes, err := this.ReadMessage()
33
+// Read reads new incoming messages.
34
+func (ws WSContainer) Read(msg []byte) (int, error) {
35
+	ty, bytes, err := ws.ReadMessage()
34 36
 	if ty == websocket.TextMessage {
35 37
 		n := copy(msg, []byte(string(bytes)+"\r\n\r\n"))
36 38
 		return n, err
@@ -39,14 +41,16 @@ func (this WSContainer) Read(msg []byte) (int, error) {
39 41
 	return 0, nil
40 42
 }
41 43
 
42
-func (this WSContainer) Write(msg []byte) (int, error) {
43
-	err := this.WriteMessage(websocket.TextMessage, msg)
44
+// Write writes lines out to the websocket.
45
+func (ws WSContainer) Write(msg []byte) (int, error) {
46
+	err := ws.WriteMessage(websocket.TextMessage, msg)
44 47
 	return len(msg), err
45 48
 }
46 49
 
47
-func (this WSContainer) SetDeadline(t time.Time) error {
48
-	if err := this.SetWriteDeadline(t); err != nil {
50
+// SetDeadline sets the read and write deadline on this websocket.
51
+func (ws WSContainer) SetDeadline(t time.Time) error {
52
+	if err := ws.SetWriteDeadline(t); err != nil {
49 53
 		return err
50 54
 	}
51
-	return this.SetReadDeadline(t)
55
+	return ws.SetReadDeadline(t)
52 56
 }

+ 6
- 1
irc/whowas.go 파일 보기

@@ -8,6 +8,7 @@ import (
8 8
 	"sync"
9 9
 )
10 10
 
11
+// WhoWasList holds our list of prior clients (for use with the WHOWAS command).
11 12
 type WhoWasList struct {
12 13
 	buffer []*WhoWas
13 14
 	start  int
@@ -16,6 +17,7 @@ type WhoWasList struct {
16 17
 	accessMutex sync.RWMutex
17 18
 }
18 19
 
20
+// WhoWas is an entry in the WhoWasList.
19 21
 type WhoWas struct {
20 22
 	nicknameCasefolded string
21 23
 	nickname           string
@@ -24,12 +26,14 @@ type WhoWas struct {
24 26
 	realname           string
25 27
 }
26 28
 
29
+// NewWhoWasList returns a new WhoWasList
27 30
 func NewWhoWasList(size uint) *WhoWasList {
28 31
 	return &WhoWasList{
29 32
 		buffer: make([]*WhoWas, size+1),
30 33
 	}
31 34
 }
32 35
 
36
+// Append adds an entry to the WhoWasList.
33 37
 func (list *WhoWasList) Append(client *Client) {
34 38
 	list.accessMutex.Lock()
35 39
 	defer list.accessMutex.Unlock()
@@ -47,6 +51,7 @@ func (list *WhoWasList) Append(client *Client) {
47 51
 	}
48 52
 }
49 53
 
54
+// Find tries to find an entry in our WhoWasList with the given details.
50 55
 func (list *WhoWasList) Find(nickname string, limit int64) []*WhoWas {
51 56
 	list.accessMutex.RLock()
52 57
 	defer list.accessMutex.RUnlock()
@@ -81,7 +86,7 @@ func (list *WhoWasList) prev(index int) int {
81 86
 	return index
82 87
 }
83 88
 
84
-// Iterate the buffer in reverse.
89
+// Each iterates the WhoWasList in reverse.
85 90
 func (list *WhoWasList) Each() <-chan *WhoWas {
86 91
 	ch := make(chan *WhoWas)
87 92
 	go func() {

Loading…
취소
저장