Переглянути джерело

Merge pull request #773 from slingamn/issue772_mitigation.1

mitigate #772
tags/v2.0.0-rc1
Shivaram Lingamneni 4 роки тому
джерело
коміт
e11f0a3428
Аккаунт користувача з таким Email не знайдено
2 змінених файлів з 10 додано та 8 видалено
  1. 4
    4
      irc/client.go
  2. 6
    4
      irc/server.go

+ 4
- 4
irc/client.go Переглянути файл

@@ -955,6 +955,10 @@ func (client *Client) updateNick(nick, nickCasefolded, skeleton string) {
955 955
 
956 956
 // updateNickMaskNoMutex updates the casefolded nickname and nickmask, not acquiring any mutexes.
957 957
 func (client *Client) updateNickMaskNoMutex() {
958
+	if client.nick == "*" {
959
+		return // pre-registration, don't bother generating the hostname
960
+	}
961
+
958 962
 	client.hostname = client.getVHostNoMutex()
959 963
 	if client.hostname == "" {
960 964
 		client.hostname = client.cloakedHostname
@@ -963,10 +967,6 @@ func (client *Client) updateNickMaskNoMutex() {
963 967
 		}
964 968
 	}
965 969
 
966
-	if client.hostname == "" {
967
-		return // pre-registration, don't bother generating the hostname
968
-	}
969
-
970 970
 	cfhostname := strings.ToLower(client.hostname)
971 971
 	client.nickMaskString = fmt.Sprintf("%s!%s@%s", client.nick, client.username, client.hostname)
972 972
 	client.nickMaskCasefolded = fmt.Sprintf("%s!%s@%s", client.nickCasefolded, strings.ToLower(client.username), cfhostname)

+ 6
- 4
irc/server.go Переглянути файл

@@ -331,6 +331,12 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
331 331
 		return true
332 332
 	}
333 333
 
334
+	// we have the final value of the IP address: do the hostname lookup
335
+	// (nickmask will be set below once nickname assignment succeeds)
336
+	if session.rawHostname == "" {
337
+		session.client.lookupHostname(session, false)
338
+	}
339
+
334 340
 	rb := NewResponseBuffer(session)
335 341
 	nickAssigned := performNickChange(server, c, c, session, c.preregNick, rb)
336 342
 	rb.Send(true)
@@ -339,10 +345,6 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
339 345
 		return
340 346
 	}
341 347
 
342
-	// we have nickname, username, and the final value of the IP address:
343
-	// do the hostname lookup and set the nickmask
344
-	session.client.lookupHostname(session, false)
345
-
346 348
 	if session.client != c {
347 349
 		// reattached, bail out.
348 350
 		// we'll play the reg burst later, on the new goroutine associated with

Завантаження…
Відмінити
Зберегти