Documentation
¶
Overview ¶
A net.Conn implementation which can change tls.TLSConn from net.TCPConn when a TLS ClientHello received. It should be used with net.TCPListener.Accept() as underlying connection for BufferConn and the BufferConn should be used for Conn as underlying connection. For implementation example check the test files.
Index ¶
- type BufferConn
- func (connection *BufferConn) Close() error
- func (connection *BufferConn) GetBuffer() []byte
- func (connection *BufferConn) LocalAddr() net.Addr
- func (connection *BufferConn) Read(buffer []byte) (int, error)
- func (connection *BufferConn) RemoteAddr() net.Addr
- func (connection *BufferConn) SetBuffer(buffer []byte)
- func (connection *BufferConn) SetDeadline(time time.Time) error
- func (connection *BufferConn) SetReadDeadline(time time.Time) error
- func (connection *BufferConn) SetWriteDeadline(time time.Time) error
- func (connection *BufferConn) Write(buffer []byte) (int, error)
- type Conn
- func (connection *Conn) Close() error
- func (connection *Conn) GetTls() bool
- func (connection *Conn) GetTlsConfig() *tls.Config
- func (connection *Conn) LocalAddr() net.Addr
- func (connection *Conn) Read(buffer []byte) (int, error)
- func (connection *Conn) RemoteAddr() net.Addr
- func (connection *Conn) SetDeadline(time time.Time) error
- func (connection *Conn) SetReadDeadline(time time.Time) error
- func (connection *Conn) SetTlsConfig(tlsConfig *tls.Config)
- func (connection *Conn) SetWriteDeadline(time time.Time) error
- func (connection *Conn) Write(buffer []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferConn ¶ added in v0.3.0
type BufferConn struct {
// contains filtered or unexported fields
}
BufferConn implements the net.Conn interface. It has an internal buffer and when there is data in it the Read returns the data from the buffer and delete the buffer instead of reading the underlying connection.
func CreateBufferConn ¶ added in v0.3.0
func CreateBufferConn(connection net.Conn) *BufferConn
CreateBufferConn returns a new BufferConn using connection as the underlying connection.
func (*BufferConn) Close ¶ added in v0.3.0
func (connection *BufferConn) Close() error
Close the underlying connection.
func (*BufferConn) GetBuffer ¶ added in v0.3.0
func (connection *BufferConn) GetBuffer() []byte
GetBuffer read the data from the buffer and delete the data from it.
func (*BufferConn) LocalAddr ¶ added in v0.3.0
func (connection *BufferConn) LocalAddr() net.Addr
LocalAddr of the underlying connection.
func (*BufferConn) Read ¶ added in v0.3.0
func (connection *BufferConn) Read(buffer []byte) (int, error)
Read returns the data from the buffer and delete the buffer instead of reading the underlying connection if the internal buffer has data.
func (*BufferConn) RemoteAddr ¶ added in v0.3.0
func (connection *BufferConn) RemoteAddr() net.Addr
RemoteAddr of the underlying connection.
func (*BufferConn) SetBuffer ¶ added in v0.3.0
func (connection *BufferConn) SetBuffer(buffer []byte)
SetBuffer the internal buffer will be equal to buffer. If there was data in the internal buffer it will be overwritten.
func (*BufferConn) SetDeadline ¶ added in v0.3.0
func (connection *BufferConn) SetDeadline(time time.Time) error
SetDeadline to the underlying connection.
func (*BufferConn) SetReadDeadline ¶ added in v0.3.0
func (connection *BufferConn) SetReadDeadline(time time.Time) error
SetReadDeadline to the underlying connection.
func (*BufferConn) SetWriteDeadline ¶ added in v0.3.0
func (connection *BufferConn) SetWriteDeadline(time time.Time) error
SetWriteDeadline to the underlying connection.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn implements the net.Conn interface. Which can change the underlying connection from TCP to TLS if a TLS ClientHello received.
func New ¶ added in v0.3.0
New returns a new Conn using connection converted to BufferConn as the underlying connection. The configuration config must be non-nil and must include at least one certificate or else set GetCertificate, if TLS will be added to the connection.
func (*Conn) GetTls ¶ added in v0.3.0
GetTls returns true if the underlying connection is using TLS and false if not.
func (*Conn) GetTlsConfig ¶ added in v0.3.0
GetTlsConfig returns the TLS server configuration.
func (*Conn) Read ¶
Read from the underlying connection. If TLS ClientHello received execute tls.TLSConn.Handshake() and read again for the actual message.
func (*Conn) RemoteAddr ¶
RemoteAddr of the underlying connection.
func (*Conn) SetDeadline ¶
SetDeadline to the underlying connection.
func (*Conn) SetReadDeadline ¶
SetReadDeadline to the underlying connection.
func (*Conn) SetTlsConfig ¶ added in v0.3.0
SetTlsConfig change the TLS server configuration. New connection will be not generated if you change it and TLS is already in use.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline to the underlying connection.