Skip to content

Commit

Permalink
including an inspector for tls.Conn; update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AZ-X committed Apr 14, 2021
1 parent 41778b9 commit 52a18c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ Check out [Releases Page](https://github.com/AZ-X/pique/releases)

### Installation

[Download the latest release with golang 1.15 for AMD64 on Windows or Linux](https://github.com/AZ-X/pique/releases/tag/v1.1.10)
[Download the latest release with golang 1.15 for AMD64 on Windows or Linux](https://github.com/AZ-X/pique/releases/tag/v1.1.12)

[Download the latest release with golang 1.16 for AMD64 on Windows or Linux](https://github.com/AZ-X/pique/releases/tag/v1.1.11)
[Download the latest release with golang 1.16 for AMD64 on Windows or Linux](https://github.com/AZ-X/pique/releases/tag/v1.1.13)

> Notice:
> Releases for OpenWRT won't be included in this repository @github.
Expand Down
23 changes: 22 additions & 1 deletion repique/common/inspector_net_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package common

import (
"crypto/tls"
"io"
"net"
"syscall"
Expand Down Expand Up @@ -42,6 +43,24 @@ Retry:
return
}

type inspectForciblyConnTLS struct {
*tls.Conn
}

func (c *inspectForciblyConnTLS) Read(b []byte) (n int, err error) {
return retryOnRW(c.Conn.Read, b)
}

func (c *inspectForciblyConnTLS) Write(b []byte) (n int, err error) {
return retryOnRW(c.Conn.Write, b)
}

type TLSConn interface {
net.Conn
Handshake() error
ConnectionState() tls.ConnectionState
}

type inspectForciblyConnTCP struct {
net.Conn
}
Expand Down Expand Up @@ -73,6 +92,8 @@ func (c *inspectForciblyConnUDP) RemoteAddr() net.Addr {
func getInspector(conn net.Conn) net.Conn {
switch t := conn.(type) {
case net.PacketConn: return &inspectForciblyConnUDP{PacketConn:t,}
default: return &inspectForciblyConnTCP{Conn:t,}
case *net.TCPConn: return &inspectForciblyConnTCP{Conn:t,}
case *tls.Conn: return &inspectForciblyConnTLS{Conn:t,}
default: return conn
}
}
2 changes: 1 addition & 1 deletion repique/protocols/tls/xtransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Go:
if err = conn.SetDeadline(time.Now().Add(Timeout)); err != nil {
goto Error
}
tlsConn := conn.(*tls.Conn)
tlsConn := conn.(common.TLSConn)
if err = tlsConn.Handshake(); err != nil {
goto Error
}
Expand Down

0 comments on commit 52a18c7

Please sign in to comment.