@@ -43,26 +43,43 @@ func Client(c net.Conn, config *tls.Config) net.Conn {
4343 return & Conn {Conn : tlsConn }
4444}
4545
46- var Fingerprints = map [string ]utls.ClientHelloID {
47- "chrome" : utls .HelloChrome_Auto ,
48- "firefox" : utls .HelloFirefox_Auto ,
49- "safari" : utls .HelloIOS_Auto ,
50- "randomized" : utls .HelloRandomized ,
46+ // Server initiates a TLS server handshake on the given connection.
47+ func Server (c net.Conn , config * tls.Config ) net.Conn {
48+ tlsConn := tls .Server (c , config )
49+ return & Conn {Conn : tlsConn }
50+ }
51+
52+ type UConn struct {
53+ * utls.UConn
54+ }
55+
56+ func (c * UConn ) HandshakeAddress () net.Address {
57+ if err := c .Handshake (); err != nil {
58+ return nil
59+ }
60+ state := c .ConnectionState ()
61+ if state .ServerName == "" {
62+ return nil
63+ }
64+ return net .ParseAddress (state .ServerName )
5165}
5266
53- func CopyConfig (c * tls.Config ) * utls.Config {
67+ func UClient (c net.Conn , config * tls.Config , fingerprint * utls.ClientHelloID ) net.Conn {
68+ utlsConn := utls .UClient (c , copyConfig (config ), * fingerprint )
69+ return & UConn {UConn : utlsConn }
70+ }
71+
72+ func copyConfig (c * tls.Config ) * utls.Config {
5473 return & utls.Config {
5574 RootCAs : c .RootCAs ,
56- NextProtos : c .NextProtos ,
5775 ServerName : c .ServerName ,
5876 InsecureSkipVerify : c .InsecureSkipVerify ,
59- MinVersion : c .MinVersion ,
60- MaxVersion : c .MaxVersion ,
6177 }
6278}
6379
64- // Server initiates a TLS server handshake on the given connection.
65- func Server (c net.Conn , config * tls.Config ) net.Conn {
66- tlsConn := tls .Server (c , config )
67- return & Conn {Conn : tlsConn }
80+ var Fingerprints = map [string ]* utls.ClientHelloID {
81+ "chrome" : & utls .HelloChrome_Auto ,
82+ "firefox" : & utls .HelloFirefox_Auto ,
83+ "safari" : & utls .HelloIOS_Auto ,
84+ "randomized" : & utls .HelloRandomized ,
6885}
0 commit comments