add websocket compression support

This commit is contained in:
Septs 2016-11-09 17:33:44 +08:00
parent b758b3d9ac
commit fa08b725db

6
ws.go
View File

@ -1,14 +1,12 @@
package gost
import (
//"github.com/ginuerzh/gosocks5"
"crypto/tls"
"github.com/golang/glog"
"github.com/gorilla/websocket"
"net"
"net/http"
"net/http/httputil"
//"net/url"
"time"
)
@ -28,6 +26,7 @@ func NewWebsocketServer(base *ProxyServer) *WebsocketServer {
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool { return true },
},
CompressionSupported: true,
}
}
@ -83,6 +82,7 @@ func WebsocketClientConn(url string, conn net.Conn, config *tls.Config) (*Websoc
NetDial: func(net, addr string) (net.Conn, error) {
return conn, nil
},
CompressionSupported: true,
}
c, resp, err := dialer.Dial(url, nil)
@ -90,7 +90,7 @@ func WebsocketClientConn(url string, conn net.Conn, config *tls.Config) (*Websoc
return nil, err
}
resp.Body.Close()
c.EnableWriteCompression(true)
return &WebsocketConn{conn: c}, nil
}