mirror of
https://github.com/refraction-networking/utls.git
synced 2025-04-04 20:47:36 +03:00
fix ApplicationSettings
This commit is contained in:
parent
514195a7ac
commit
fcaacdbbe7
1 changed files with 8 additions and 9 deletions
|
@ -854,9 +854,9 @@ func (e *ApplicationSettingsExtension) writeToUConn(uc *UConn) error {
|
|||
}
|
||||
|
||||
func (e *ApplicationSettingsExtension) Len() int {
|
||||
result := 7
|
||||
result := 6 //id + first length + second length
|
||||
for _, element := range e.SupportedALPNList {
|
||||
result += len(element)
|
||||
result += 1 + len(element) //byte for string length + allocation for string in bytes
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -868,22 +868,21 @@ func (e *ApplicationSettingsExtension) Read(b []byte) (int, error) {
|
|||
|
||||
b[0] = byte(extensionApplicationSettings >> 8)
|
||||
b[1] = byte(0x69)
|
||||
b[2] = 0
|
||||
b[4] = 0
|
||||
|
||||
currentIndex := 6
|
||||
|
||||
for _, alpn := range e.SupportedALPNList {
|
||||
b[currentIndex] = byte(len(alpn))
|
||||
b[currentIndex] = byte(len(alpn)) //set length of string in bytes
|
||||
currentIndex++
|
||||
for _, char := range alpn {
|
||||
b[currentIndex] = byte(char)
|
||||
b[currentIndex] = byte(char) //convert char to byte
|
||||
currentIndex++
|
||||
}
|
||||
}
|
||||
|
||||
b[3] = byte(currentIndex - 4)
|
||||
b[5] = byte(currentIndex - 6)
|
||||
b[2] = 0x00
|
||||
b[3] = byte(e.Len() - 4) //len minus id and itself (2+2)
|
||||
b[4] = 0x00
|
||||
b[5] = byte(e.Len() - 6) //len minus id big length and itself 5 (2+2+2)
|
||||
|
||||
return e.Len(), io.EOF
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue