mirror of
https://github.com/refraction-networking/utls.git
synced 2025-04-03 20:17:36 +03:00
crypto/tls: help linker remove code when only Client or Server is used
This saves 166 KiB for a tls.Dial hello world program (5382441 to 5212356 to bytes), by permitting the linker to remove TLS server code. Change-Id: I16610b836bb0802b7d84995ff881d79ec03b6a84 Reviewed-on: https://go-review.googlesource.com/c/go/+/228111 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7f376c8689
commit
2fcb91d134
3 changed files with 138 additions and 9 deletions
11
conn.go
11
conn.go
|
@ -24,8 +24,9 @@ import (
|
|||
// It implements the net.Conn interface.
|
||||
type Conn struct {
|
||||
// constant
|
||||
conn net.Conn
|
||||
isClient bool
|
||||
conn net.Conn
|
||||
isClient bool
|
||||
handshakeFn func() error // (*Conn).clientHandshake or serverHandshake
|
||||
|
||||
// handshakeStatus is 1 if the connection is currently transferring
|
||||
// application data (i.e. is not currently processing a handshake).
|
||||
|
@ -1349,11 +1350,7 @@ func (c *Conn) Handshake() error {
|
|||
c.in.Lock()
|
||||
defer c.in.Unlock()
|
||||
|
||||
if c.isClient {
|
||||
c.handshakeErr = c.clientHandshake()
|
||||
} else {
|
||||
c.handshakeErr = c.serverHandshake()
|
||||
}
|
||||
c.handshakeErr = c.handshakeFn()
|
||||
if c.handshakeErr == nil {
|
||||
c.handshakes++
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue