Improve: clean code

This commit is contained in:
Dreamacro
2018-08-12 16:18:58 +08:00
parent fc4f119049
commit ebe1cee6dc
7 changed files with 97 additions and 83 deletions

View File

@ -7,23 +7,28 @@ import (
"github.com/riobard/go-shadowsocks2/socks"
)
// SocksAdapter is a adapter for socks and redir connection
type SocksAdapter struct {
conn net.Conn
addr *C.Addr
}
// Close socks and redir connection
func (s *SocksAdapter) Close() {
s.conn.Close()
}
// Addr return destination address
func (s *SocksAdapter) Addr() *C.Addr {
return s.addr
}
// Conn return raw net.Conn
func (s *SocksAdapter) Conn() net.Conn {
return s.conn
}
// NewSocks is SocksAdapter generator
func NewSocks(target socks.Addr, conn net.Conn) *SocksAdapter {
return &SocksAdapter{
conn: conn,