mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-02-25 18:20:44 +00:00
Reality: Remove unnecessary usage of reflect package
This commit is contained in:
parent
94c7970fd6
commit
56a1a78bd0
@ -18,12 +18,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
_ "unsafe"
|
||||||
|
|
||||||
utls "github.com/refraction-networking/utls"
|
utls "github.com/refraction-networking/utls"
|
||||||
"github.com/xtls/reality"
|
"github.com/xtls/reality"
|
||||||
@ -78,8 +77,10 @@ func (c *UConn) HandshakeAddress() net.Address {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *UConn) VerifyPeerCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
|
func (c *UConn) VerifyPeerCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
|
||||||
p, _ := reflect.TypeOf(c.Conn).Elem().FieldByName("peerCertificates")
|
certs := make([]*x509.Certificate, len(rawCerts))
|
||||||
certs := *(*([]*x509.Certificate))(unsafe.Pointer(uintptr(unsafe.Pointer(c.Conn)) + p.Offset))
|
for i, rawCert := range rawCerts {
|
||||||
|
certs[i], _ = x509.ParseCertificate(rawCert)
|
||||||
|
}
|
||||||
if pub, ok := certs[0].PublicKey.(ed25519.PublicKey); ok {
|
if pub, ok := certs[0].PublicKey.(ed25519.PublicKey); ok {
|
||||||
h := hmac.New(sha512.New, c.AuthKey)
|
h := hmac.New(sha512.New, c.AuthKey)
|
||||||
h.Write(pub)
|
h.Write(pub)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user