2018-07-26 00:04:59 +08:00
|
|
|
package adapters
|
2018-06-14 01:00:58 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
C "github.com/Dreamacro/clash/constant"
|
|
|
|
)
|
|
|
|
|
|
|
|
type HttpsAdapter struct {
|
|
|
|
addr *C.Addr
|
|
|
|
conn net.Conn
|
|
|
|
rw *bufio.ReadWriter
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HttpsAdapter) Close() {
|
|
|
|
h.conn.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HttpsAdapter) Addr() *C.Addr {
|
|
|
|
return h.addr
|
|
|
|
}
|
|
|
|
|
2018-07-26 00:04:59 +08:00
|
|
|
func (h *HttpsAdapter) Conn() net.Conn {
|
|
|
|
return h.conn
|
2018-06-14 01:00:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewHttps(host string, conn net.Conn) *HttpsAdapter {
|
|
|
|
return &HttpsAdapter{
|
|
|
|
addr: parseHttpAddr(host),
|
|
|
|
conn: conn,
|
|
|
|
}
|
|
|
|
}
|