Feature: add custom DNS support (#56)

This commit is contained in:
Dreamacro
2018-12-05 21:13:29 +08:00
committed by GitHub
parent da5db36ccf
commit 03c249ecb1
23 changed files with 939 additions and 124 deletions

View File

@ -14,18 +14,18 @@ var (
tun = tunnel.Instance()
)
type httpListener struct {
type HttpListener struct {
net.Listener
address string
closed bool
}
func NewHttpProxy(addr string) (*httpListener, error) {
func NewHttpProxy(addr string) (*HttpListener, error) {
l, err := net.Listen("tcp", addr)
if err != nil {
return nil, err
}
hl := &httpListener{l, addr, false}
hl := &HttpListener{l, addr, false}
go func() {
log.Infoln("HTTP proxy listening at: %s", addr)
@ -44,12 +44,12 @@ func NewHttpProxy(addr string) (*httpListener, error) {
return hl, nil
}
func (l *httpListener) Close() {
func (l *HttpListener) Close() {
l.closed = true
l.Listener.Close()
}
func (l *httpListener) Address() string {
func (l *HttpListener) Address() string {
return l.address
}