Add port in Proxy to avoid re-calc in PAC.

This commit is contained in:
Chen Yufei
2013-02-11 19:28:24 +08:00
parent 7c758b7bd2
commit 2659105aa5
2 changed files with 5 additions and 4 deletions

3
pac.go
View File

@@ -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

View File

@@ -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) {