Style: cleanup code
This commit is contained in:
@ -16,19 +16,19 @@ import (
|
||||
"github.com/Dreamacro/clash/tunnel"
|
||||
)
|
||||
|
||||
type HttpListener struct {
|
||||
type HTTPListener struct {
|
||||
net.Listener
|
||||
address string
|
||||
closed bool
|
||||
cache *cache.Cache
|
||||
}
|
||||
|
||||
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, cache.New(30 * time.Second)}
|
||||
hl := &HTTPListener{l, addr, false, cache.New(30 * time.Second)}
|
||||
|
||||
go func() {
|
||||
log.Infoln("HTTP proxy listening at: %s", addr)
|
||||
@ -48,12 +48,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
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ var (
|
||||
|
||||
socksListener *socks.SockListener
|
||||
socksUDPListener *socks.SockUDPListener
|
||||
httpListener *http.HttpListener
|
||||
httpListener *http.HTTPListener
|
||||
redirListener *redir.RedirListener
|
||||
redirUDPListener *redir.RedirUDPListener
|
||||
tproxyListener *redir.TProxyListener
|
||||
@ -78,7 +78,7 @@ func ReCreateHTTP(port int) error {
|
||||
}
|
||||
|
||||
var err error
|
||||
httpListener, err = http.NewHttpProxy(addr)
|
||||
httpListener, err = http.NewHTTPProxy(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -316,9 +316,8 @@ func genAddr(host string, port int, allowLan bool) string {
|
||||
if allowLan {
|
||||
if host == "*" {
|
||||
return fmt.Sprintf(":%d", port)
|
||||
} else {
|
||||
return fmt.Sprintf("%s:%d", host, port)
|
||||
}
|
||||
return fmt.Sprintf("%s:%d", host, port)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("127.0.0.1:%d", port)
|
||||
|
Reference in New Issue
Block a user