0
0
mirror of https://github.com/XTLS/REALITY.git synced 2025-08-22 22:48:36 +00:00

Use for i, t := range types instead

Much easier for other people to understand the code.
This commit is contained in:
RPRX 2023-02-10 13:50:08 +08:00 committed by GitHub
parent 5a9e6c0cc2
commit e814936a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
tls.go
View File

@ -93,7 +93,7 @@ func (c *ReaderConn) SetWriteDeadline(t time.Time) error {
var (
size = 8192
empty = make([]byte, size)
names = [7]string{
types = [7]string{
"Server Hello",
"Change Cipher Spec",
"Encrypted Extensions",
@ -305,7 +305,7 @@ func Server(conn net.Conn, config *Config) (*Conn, error) {
if len(s2cSaved) > size {
break
}
for i := 0; i < 7; i++ {
for i, t := range types {
if hs.c.out.handshakeLen[i] != 0 {
continue
}
@ -322,7 +322,7 @@ func Server(conn net.Conn, config *Config) (*Conn, error) {
handshakeLen = recordHeaderLen + Value(s2cSaved[3:5]...)
}
if config.Show {
fmt.Printf("REALITY remoteAddr: %v\tlen(s2cSaved): %v\t%v: %v\n", remoteAddr, len(s2cSaved), names[i], handshakeLen)
fmt.Printf("REALITY remoteAddr: %v\tlen(s2cSaved): %v\t%v: %v\n", remoteAddr, len(s2cSaved), t, handshakeLen)
}
if handshakeLen > size { // too long
break f