Browse Source

make it easier to patch out the maximum line length

tags/v2.3.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
6a2fba9812
3 changed files with 10 additions and 8 deletions
  1. 9
    6
      irc/client.go
  2. 0
    1
      irc/errors.go
  3. 1
    1
      irc/ircconn.go

+ 9
- 6
irc/client.go View File

@@ -27,6 +27,9 @@ import (
27 27
 )
28 28
 
29 29
 const (
30
+	// maximum line length not including tags; don't change this for a public server
31
+	MaxLineLen = 512
32
+
30 33
 	// IdentTimeout is how long before our ident (username) check times out.
31 34
 	IdentTimeout         = time.Second + 500*time.Millisecond
32 35
 	IRCv3TimestampFormat = utils.IRCv3TimestampFormat
@@ -185,8 +188,8 @@ func (s *Session) EndMultilineBatch(label string) (batch MultilineBatch, err err
185 188
 	s.fakelag.Unsuspend()
186 189
 
187 190
 	// heuristics to estimate how much data they used while fakelag was suspended
188
-	fakelagBill := (batch.lenBytes / 512) + 1
189
-	fakelagBillLines := (batch.message.LenLines() * 60) / 512
191
+	fakelagBill := (batch.lenBytes / MaxLineLen) + 1
192
+	fakelagBillLines := (batch.message.LenLines() * 60) / MaxLineLen
190 193
 	if fakelagBill < fakelagBillLines {
191 194
 		fakelagBill = fakelagBillLines
192 195
 	}
@@ -666,7 +669,7 @@ func (client *Client) run(session *Session) {
666 669
 			}
667 670
 		}
668 671
 
669
-		msg, err := ircmsg.ParseLineStrict(line, true, 512)
672
+		msg, err := ircmsg.ParseLineStrict(line, true, MaxLineLen)
670 673
 		if err == ircmsg.ErrorLineIsEmpty {
671 674
 			continue
672 675
 		} else if err == ircmsg.ErrorLineTooLong {
@@ -1198,11 +1201,11 @@ func (client *Client) Quit(message string, session *Session) {
1198 1201
 		// #364: don't send QUIT lines to unregistered clients
1199 1202
 		if client.registered {
1200 1203
 			quitMsg := ircmsg.MakeMessage(nil, client.nickMaskString, "QUIT", message)
1201
-			finalData, _ = quitMsg.LineBytesStrict(false, 512)
1204
+			finalData, _ = quitMsg.LineBytesStrict(false, MaxLineLen)
1202 1205
 		}
1203 1206
 
1204 1207
 		errorMsg := ircmsg.MakeMessage(nil, "", "ERROR", message)
1205
-		errorMsgBytes, _ := errorMsg.LineBytesStrict(false, 512)
1208
+		errorMsgBytes, _ := errorMsg.LineBytesStrict(false, MaxLineLen)
1206 1209
 		finalData = append(finalData, errorMsgBytes...)
1207 1210
 
1208 1211
 		sess.socket.SetFinalData(finalData)
@@ -1536,7 +1539,7 @@ func (session *Session) SendRawMessage(message ircmsg.IrcMessage, blocking bool)
1536 1539
 	}
1537 1540
 
1538 1541
 	// assemble message
1539
-	line, err := message.LineBytesStrict(false, 512)
1542
+	line, err := message.LineBytesStrict(false, MaxLineLen)
1540 1543
 	if err != nil {
1541 1544
 		logline := fmt.Sprintf("Error assembling message for sending: %v\n%s", err, debug.Stack())
1542 1545
 		session.client.server.logger.Error("internal", logline)

+ 0
- 1
irc/errors.go View File

@@ -107,7 +107,6 @@ func (te *ThrottleError) Error() string {
107 107
 var (
108 108
 	ErrDatastorePathMissing    = errors.New("Datastore path missing")
109 109
 	ErrLimitsAreInsane         = errors.New("Limits aren't setup properly, check them and make them sane")
110
-	ErrLineLengthsTooSmall     = errors.New("Line lengths must be 512 or greater (check the linelen section under server->limits)")
111 110
 	ErrLoggerExcludeEmpty      = errors.New("Encountered logging type '-' with no type to exclude")
112 111
 	ErrLoggerFilenameMissing   = errors.New("Logging configuration specifies 'file' method but 'filename' is empty")
113 112
 	ErrLoggerHasNoTypes        = errors.New("Logger has no types to log")

+ 1
- 1
irc/ircconn.go View File

@@ -13,7 +13,7 @@ import (
13 13
 )
14 14
 
15 15
 const (
16
-	maxReadQBytes = ircmsg.MaxlenTagsFromClient + 512 + 1024
16
+	maxReadQBytes = ircmsg.MaxlenTagsFromClient + MaxLineLen + 1024
17 17
 )
18 18
 
19 19
 var (

Loading…
Cancel
Save