2017-11-29 12:24:48 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2017-11-30 01:11:53 +00:00
|
|
|
"crypto/tls"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
2017-11-29 12:24:48 +00:00
|
|
|
"time"
|
2017-11-30 01:11:53 +00:00
|
|
|
|
|
|
|
cuc "git.loafle.net/commons_go/util/context"
|
2017-11-29 12:24:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type SocketHandlers struct {
|
2017-11-30 01:11:53 +00:00
|
|
|
URL *url.URL
|
|
|
|
RequestCookie http.CookieJar
|
|
|
|
RequestHeader http.Header
|
|
|
|
SubProtocols []string
|
|
|
|
EnableCompression bool
|
|
|
|
HandshakeTimeout time.Duration
|
|
|
|
TLSConfig *tls.Config
|
|
|
|
ReadBufferSize int
|
|
|
|
WriteBufferSize int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) SocketContext(parent cuc.Context) SocketContext {
|
|
|
|
return newSocketContext(parent)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) GetURL() *url.URL {
|
|
|
|
return sh.URL
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 01:11:53 +00:00
|
|
|
func (sh *SocketHandlers) GetRequestCookie() http.CookieJar {
|
|
|
|
return sh.RequestCookie
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|
2017-11-30 01:11:53 +00:00
|
|
|
|
|
|
|
func (sh *SocketHandlers) GetRequestHeader() http.Header {
|
|
|
|
return sh.RequestHeader
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|
2017-11-30 01:11:53 +00:00
|
|
|
|
|
|
|
func (sh *SocketHandlers) GetSubProtocols() []string {
|
|
|
|
return sh.SubProtocols
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|
2017-11-30 01:11:53 +00:00
|
|
|
|
|
|
|
func (sh *SocketHandlers) EnableCompression() bool {
|
|
|
|
return sh.EnableCompression
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|
2017-11-30 01:11:53 +00:00
|
|
|
|
|
|
|
func (sh *SocketHandlers) UseProxy(req *http.Request) (*url.URL, error) {
|
|
|
|
return nil, nil
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|
2017-11-30 01:11:53 +00:00
|
|
|
|
|
|
|
func (sh *SocketHandlers) GetHandshakeTimeout() time.Duration {
|
|
|
|
return sh.HandshakeTimeout
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) Dial(network, addr string) (net.Conn, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) GetTLSConfig() *tls.Config {
|
|
|
|
return sh.TLSConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) GetReadBufferSize() int {
|
|
|
|
return sh.ReadBufferSize
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) GetWriteBufferSize() int {
|
|
|
|
return sh.WriteBufferSize
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *SocketHandlers) Validate() {
|
2017-11-30 01:11:53 +00:00
|
|
|
|
2017-11-29 12:24:48 +00:00
|
|
|
}
|