From 5c7f450edf598b08fd2c7f64cd0828957a41d97d Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Sun, 13 Jan 2013 19:57:21 +0800 Subject: [PATCH] Export RawAddr for use in benchmark. --- cmd/shadowsocks-httpget/httpget.go | 7 ++++++- shadowsocks/conn.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/shadowsocks-httpget/httpget.go b/cmd/shadowsocks-httpget/httpget.go index 4c070e4..c63ca1d 100644 --- a/cmd/shadowsocks-httpget/httpget.go +++ b/cmd/shadowsocks-httpget/httpget.go @@ -53,9 +53,14 @@ func get(connid int, url, serverAddr string, enctbl *ss.EncryptTable, done chan defer func() { done <- reqTime[:reqDone] }() + rawAddr, err := ss.RawAddr(url) + if err != nil { + panic("Error getting raw address.") + return + } tr := &http.Transport{ Dial: func(net, addr string) (c net.Conn, err error) { - return ss.Dial(addr, serverAddr, enctbl) + return ss.DialWithRawAddr(rawAddr, serverAddr, enctbl) }, } diff --git a/shadowsocks/conn.go b/shadowsocks/conn.go index 80f6c8d..4778bf6 100644 --- a/shadowsocks/conn.go +++ b/shadowsocks/conn.go @@ -18,7 +18,7 @@ func NewConn(cn net.Conn, encTbl *EncryptTable) *Conn { return &Conn{cn, encTbl} } -func rawAddr(addr string) (buf []byte, err error) { +func RawAddr(addr string) (buf []byte, err error) { arr := strings.Split(addr, ":") if len(arr) != 2 { return nil, errors.New( @@ -59,7 +59,7 @@ func DialWithRawAddr(rawaddr []byte, server string, encTbl *EncryptTable) (c *Co // addr should be in the form of host:port func Dial(addr, server string, encTbl *EncryptTable) (c *Conn, err error) { - ra, err := rawAddr(addr) + ra, err := RawAddr(addr) if err != nil { return }