mirror of https://github.com/v2ray/v2ray-core
				
				
				
			tls connection
							parent
							
								
									94eab286c0
								
							
						
					
					
						commit
						ccb874d65a
					
				| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
package hub
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"net"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -95,3 +96,68 @@ func (this *TCPConnection) CloseWrite() error {
 | 
			
		|||
	}
 | 
			
		||||
	return this.conn.CloseWrite()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type TLSConnection struct {
 | 
			
		||||
	conn     *tls.Conn
 | 
			
		||||
	listener *TCPHub
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) Read(b []byte) (int, error) {
 | 
			
		||||
	if this == nil || this.conn == nil {
 | 
			
		||||
		return 0, ErrorClosedConnection
 | 
			
		||||
	}
 | 
			
		||||
	return this.conn.Read(b)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) Write(b []byte) (int, error) {
 | 
			
		||||
	if this == nil || this.conn == nil {
 | 
			
		||||
		return this.conn.Write(b)
 | 
			
		||||
	}
 | 
			
		||||
	return this.conn.Write(b)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) Close() error {
 | 
			
		||||
	if this == nil || this.conn == nil {
 | 
			
		||||
		return ErrorClosedConnection
 | 
			
		||||
	}
 | 
			
		||||
	err := this.conn.Close()
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) Release() {
 | 
			
		||||
	if this == nil || this.listener == nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	this.Close()
 | 
			
		||||
	this.conn = nil
 | 
			
		||||
	this.listener = nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) LocalAddr() net.Addr {
 | 
			
		||||
	return this.conn.LocalAddr()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) RemoteAddr() net.Addr {
 | 
			
		||||
	return this.conn.RemoteAddr()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) SetDeadline(t time.Time) error {
 | 
			
		||||
	return this.conn.SetDeadline(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) SetReadDeadline(t time.Time) error {
 | 
			
		||||
	return this.conn.SetReadDeadline(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) SetWriteDeadline(t time.Time) error {
 | 
			
		||||
	return this.conn.SetWriteDeadline(t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) CloseRead() error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TLSConnection) CloseWrite() error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue