mirror of
https://github.com/zhigang1992/cow.git
synced 2026-04-29 18:05:46 +08:00
Add port in Proxy to avoid re-calc in PAC.
This commit is contained in:
3
pac.go
3
pac.go
@@ -101,8 +101,7 @@ func genPAC(c *clientConn) []byte {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
host, _ := splitHostPort(c.LocalAddr().String())
|
||||
_, port := splitHostPort(c.proxy.addr)
|
||||
proxyAddr := net.JoinHostPort(host, port)
|
||||
proxyAddr := net.JoinHostPort(host, c.proxy.port)
|
||||
|
||||
if *pac.directList == "" {
|
||||
// Empty direct domain list
|
||||
|
||||
6
proxy.go
6
proxy.go
@@ -30,7 +30,8 @@ const sslLeastDuration = time.Second
|
||||
// Some code are learnt from the http package
|
||||
|
||||
type Proxy struct {
|
||||
addr string // listen address
|
||||
addr string // listen address, contains port
|
||||
port string
|
||||
}
|
||||
|
||||
type connType byte
|
||||
@@ -125,7 +126,8 @@ var (
|
||||
)
|
||||
|
||||
func NewProxy(addr string) *Proxy {
|
||||
return &Proxy{addr: addr}
|
||||
_, port := splitHostPort(addr)
|
||||
return &Proxy{addr: addr, port: port}
|
||||
}
|
||||
|
||||
func (py *Proxy) Serve(done chan byte) {
|
||||
|
||||
Reference in New Issue
Block a user