Documentation ¶
Index ¶
- Constants
- Variables
- func AddConnectionClosed(raw []byte) []byte
- func AddOrUpgradeCookie(raw []byte, value string) ([]byte, error)
- func AppendHeaderToHTTPPacket(raw []byte, line string) []byte
- func CharsetToUTF8(bodyRaw []byte, mimeType string, originCharset string) ([]byte, string)
- func ComputeWebsocketAcceptKey(websocketKey string) string
- func ContentEncodingDecode(contentEncoding string, bodyRaw []byte) (finalResult []byte, fixed bool)
- func ConvertHTTPRequestToFuzzTag(i []byte) []byte
- func CookiesToString(cookies []*http.Cookie) string
- func CopyRequest(r *http.Request) *http.Request
- func CurlToHTTPRequest(i string) ([]byte, error)
- func ExtractBodyFromHTTPResponseRaw(res []byte) ([]byte, error)
- func ExtractBoundaryFromBody(raw interface{}) string
- func ExtractCookieJarFromHTTPResponse(rawResponse []byte) []*http.Cookie
- func ExtractStatusCodeFromResponse(raw []byte) int
- func ExtractURLFromHTTPRequest(r *http.Request, https bool) (*url.URL, error)
- func ExtractURLFromHTTPRequestRaw(req []byte, isHttps bool) (*url.URL, error)
- func ExtractWebsocketURLFromHTTPRequest(req *http.Request) (bool, string)
- func FetchBannerFromHostPort(baseCtx context.Context, host string, port interface{}, size int64, ...) []byte
- func FixHTTPPacketCRLF(raw []byte, noFixLength bool) []byte
- func FixHTTPRequestOut(raw []byte) []byte
- func FixHTTPResponse(raw []byte) (rsp []byte, body []byte, _ error)
- func FixMultipartBody(i []byte) (string, []byte)
- func GetCookiejar(session interface{}) http.CookieJar
- func GetHostsFilePath() string
- func GetOverrideContentType(bodyPrescan []byte, contentType string) (overrideContentType string, originCharset string)
- func GetRedirectFromHTTPResponse(rawResponse []byte, jsRedirect bool) string
- func GetSystemEtcHosts() map[string]string
- func GetSystemHostByName(domain string) (string, bool)
- func HTTP2RequestToHTTP(framer *http2.Framer) ([]byte, error)
- func HTTP2ResponseToHTTP(frame *http2.Frame) ([]byte, error)
- func HTTPPacketForceChunked(raw []byte) []byte
- func HTTPRequestToHTTP2(schema string, host string, conn net.Conn, raw []byte, noFixContentLength bool) ([]byte, error)
- func IsMultipartFormDataRequest(req []byte) bool
- func IsPermessageDeflate(headers http.Header) bool
- func IsPrint(s string) bool
- func MergeCookies(cookies ...*http.Cookie) string
- func MergeUrlFromHTTPRequest(rawRequest []byte, target string, isHttps bool) string
- func ParseBytesToHTTPResponse(res []byte) (*http.Response, error)
- func ParseBytesToHttpRequest(raw []byte) (*http.Request, error)
- func ParseCookie(i string) []*http.Cookie
- func ParseStringToHTTPResponse(res string) (*http.Response, error)
- func ParseStringToHttpRequest(raw string) (*http.Request, error)
- func ParseUrlToHttpRequestRaw(method string, i interface{}) (bool, []byte, error)
- func ReadHTTPPacketBodySize(raw []byte) (cl int, chunked bool)
- func ReadHTTPPacketSafe(r *bufio.Reader) ([]byte, error)
- func ReadHTTPRequest(reader *bufio.Reader) (*http.Request, error)
- func ReadHTTPRequestEx(reader *bufio.Reader, loadbody bool) (*http.Request, error)
- func ReadHTTPResponseEx(reader *bufio.Reader, loadbody bool) (*http.Response, []byte, error)
- func RegisterSaveHTTPFlowHandler(h saveHTTPFlowHandler)
- func RemoveCEHeaders(headerBytes []byte) []byte
- func RemoveZeroContentLengthHTTPHeader(raw []byte) []byte
- func ReplaceHTTPPacketBody(raw []byte, body []byte, chunk bool) []byte
- func ReplaceHTTPPacketBodyEx(raw []byte, body []byte, chunk bool, forceCL bool) []byte
- func ReplaceMIMEType(headerBytes []byte, mimeType string) []byte
- func SaveResponse(r *LowhttpResponse)
- func SendHTTPRequestRaw(https bool, host string, port int, r *http.Request, timeout time.Duration) ([]byte, error)
- func SendHTTPRequestRawQuick(https bool, r *http.Request) ([]byte, error)
- func SendHTTPRequestRawQuickWithTimeout(https bool, r *http.Request, timeout time.Duration) ([]byte, error)
- func SendHTTPRequestWithRawPacket(forceHttps bool, host string, port int, r []byte, timeout time.Duration, ...) ([]byte, error)
- func SendHTTPRequestWithRawPacketEx(forceHttps bool, host string, port int, r []byte, timeout time.Duration, ...) ([]byte, bool, error)
- func SendHTTPRequestWithRawPacketWithRedirect(https bool, host string, port int, r []byte, timeout time.Duration, ...) ([]byte, [][]byte, error)
- func SendHTTPRequestWithRawPacketWithRedirectEx(https bool, host string, port int, r []byte, timeout time.Duration, ...) ([]byte, [][]byte, error)
- func SendHTTPRequestWithRawPacketWithRedirectFullEx(https bool, host string, port int, r []byte, timeout time.Duration, ...) ([]byte, [][]byte, error)
- func SendHTTPRequestWithRawPacketWithRedirectWithContextFullEx(https bool, host string, port int, r []byte, timeout time.Duration, ...) ([]byte, [][]byte, error)
- func SendHTTPRequestWithRawPacketWithRedirectWithStateFullEx(https bool, host string, port int, r []byte, timeout time.Duration, ...) ([]byte, [][]byte, bool, error)
- func SendPacketQuick(https bool, packet []byte, timeout float64, proxy ...string) ([]byte, [][]byte, error)
- func ShouldSendReqContentLength(method string, contentLength int64) bool
- func SplitHTTPHeader(i string) (string, string)
- func SplitHTTPHeadersAndBodyFromPacket(raw []byte, hook ...func(line string)) (string, []byte)
- func SplitHTTPHeadersAndBodyFromPacketEx(raw []byte, mf func(method string, requestUri string, proto string) error, ...) (string, []byte)
- func SplitHTTPHeadersAndBodyFromPacketEx2(raw []byte, mf func(method string, requestUri string, proto string) error, ...) (string, []byte)
- func SplitKV(i string) (string, string)
- func ToLower(s string) (lower string, ok bool)
- func ToUnquoteFuzzTag(i []byte) string
- func TrimLeftHTTPPacket(raw []byte) []byte
- func TrimRightHTTPPacket(raw []byte) []byte
- func TrimSpaceHTTPPacket(raw []byte) []byte
- func UrlToGetRequestPacket(u string, originRequest []byte, originRequestHttps bool, ...) []byte
- func WebsocketFrameToData(frame *Frame) (data []byte)
- type Frame
- type FrameReader
- type FrameWriter
- func (fw *FrameWriter) Flush() error
- func (fw *FrameWriter) WriteBinary(data []byte, mask bool, headerBytes ...byte) (err error)
- func (fw *FrameWriter) WriteFrame(frame *Frame, messageTypes ...int) (err error)
- func (fw *FrameWriter) WritePong(data []byte, mask bool) (err error)
- func (fw *FrameWriter) WriteRaw(raw []byte) (err error)
- func (fw *FrameWriter) WriteText(data []byte, mask bool, headerBytes ...byte) (err error)
- type LowhttpExecConfig
- type LowhttpOpt
- func WithBeforeDoRequest(h func([]byte) []byte) LowhttpOpt
- func WithContext(ctx context.Context) LowhttpOpt
- func WithDNSServers(servers []string) LowhttpOpt
- func WithETCHosts(hosts map[string]string) LowhttpOpt
- func WithHost(host string) LowhttpOpt
- func WithHttp2(Http2 bool) LowhttpOpt
- func WithHttps(https bool) LowhttpOpt
- func WithJsRedirect(jsRedirect bool) LowhttpOpt
- func WithNoFixContentLength(noFixContentLength bool) LowhttpOpt
- func WithPacket(packet []byte) LowhttpOpt
- func WithPort(port int) LowhttpOpt
- func WithProxy(proxy ...string) LowhttpOpt
- func WithRedirectHandler(redirectHandler func(bool, []byte, []byte) bool) LowhttpOpt
- func WithRedirectTimes(redirectTimes int) LowhttpOpt
- func WithRetryInStatusCode(sc []int) LowhttpOpt
- func WithRetryMaxWaitTime(retryMaxWaitTime time.Duration) LowhttpOpt
- func WithRetryNotInStatusCode(sc []int) LowhttpOpt
- func WithRetryTimes(retryTimes int) LowhttpOpt
- func WithRetryWaitTime(retryWaitTime time.Duration) LowhttpOpt
- func WithSaveHTTPFlow(b bool) LowhttpOpt
- func WithSession(session interface{}) LowhttpOpt
- func WithSource(s string) LowhttpOpt
- func WithTimeout(timeout time.Duration) LowhttpOpt
- type LowhttpResponse
- type LowhttpTraceInfo
- type WebHookServer
- type WebsocketClient
- func (c *WebsocketClient) StartFromServer()
- func (c *WebsocketClient) Stop()
- func (c *WebsocketClient) Wait()
- func (c *WebsocketClient) Write(r []byte) error
- func (c *WebsocketClient) WriteBinary(r []byte) error
- func (c *WebsocketClient) WritePong(r []byte) error
- func (c *WebsocketClient) WriteText(r []byte) error
- type WebsocketClientConfig
- type WebsocketClientOpt
- func WithWebsocketFromServerHandler(f func([]byte)) WebsocketClientOpt
- func WithWebsocketHost(t string) WebsocketClientOpt
- func WithWebsocketPort(t int) WebsocketClientOpt
- func WithWebsocketProxy(t string) WebsocketClientOpt
- func WithWebsocketTLS(t bool) WebsocketClientOpt
- func WithWebsocketTotalTimeout(t float64) WebsocketClientOpt
- func WithWebsocketWithContext(ctx context.Context) WebsocketClientOpt
Constants ¶
View Source
const ( FINALBIT = 1 << 7 RSV1BIT = 1 << 6 MASKBIT = 1 << 7 RESET_MESSAGE_TYPE_BIT = 0b11110000 FRAME_TYPE_BIT = 0b00001111 TWO_BYTE_BIT = 0b01111110 EIGHT_BYTE_BIT = 0b01111111 TWO_BYTE_SIZE = 65535 SEVEN_BIT_SIZE = 125 // 根据websocket协议,126和127分别代表用后续两个字节/八个字节表示长度,所以这里只能用125 DEFAULT_TEXT_MESSAGE_FISRT_BYTE = 0b10000001 TextMessage = 1 BinaryMessage = 2 CloseMessage = 8 PingMessage = 9 PongMessage = 10 ContinueMessage = 0 )
View Source
const (
CRLF = "\r\n"
)
Variables ¶
View Source
var CookiejarPool sync.Map
View Source
var GetProxyConn = utils.GetProxyConn
View Source
var GetProxyConnWithContext = utils.GetProxyConnWithContext
View Source
var ( // Add four bytes as specified in RFC // Add final block to squelch unexpected EOF error from flate reader TAIL = []byte{0, 0, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff} )
Functions ¶
func AddConnectionClosed ¶
func CharsetToUTF8 ¶
func ContentEncodingDecode ¶
func CookiesToString ¶
func CurlToHTTPRequest ¶
func ExtractBoundaryFromBody ¶
func ExtractBoundaryFromBody(raw interface{}) string
func FetchBannerFromHostPort ¶
func FixHTTPPacketCRLF ¶
func FixHTTPRequestOut ¶
func FixHTTPResponse ¶
FixHTTPResponse try its best to fix and present human-readable response
func GetCookiejar ¶
func GetHostsFilePath ¶
func GetHostsFilePath() string
func GetOverrideContentType ¶
func GetSystemEtcHosts ¶
func GetSystemHostByName ¶
func HTTPPacketForceChunked ¶
func HTTPRequestToHTTP2 ¶
func IsPermessageDeflate ¶
func MergeCookies ¶
func MergeUrlFromHTTPRequest ¶
func ParseCookie ¶
func ReadHTTPPacketBodySize ¶
func ReadHTTPRequestEx ¶
func ReadHTTPResponseEx ¶
func RegisterSaveHTTPFlowHandler ¶
func RegisterSaveHTTPFlowHandler(h saveHTTPFlowHandler)
func RemoveCEHeaders ¶
func ReplaceHTTPPacketBodyEx ¶
func ReplaceMIMEType ¶
func SaveResponse ¶
func SaveResponse(r *LowhttpResponse)
func SendHTTPRequestRaw ¶
func SendHTTPRequestRawQuick ¶
func SendHTTPRequestWithRawPacketEx ¶
func SendHTTPRequestWithRawPacketEx(forceHttps bool, host string, port int, r []byte, timeout time.Duration, noFixContentLength bool, forceHttp2 bool, proxy ...string) ([]byte, bool, error)
SendHTTPRequestWithRawPacketEx
Returns:
- response bytes
- is port opened?
- error
func SendHTTPRequestWithRawPacketWithRedirectFullEx ¶
func SendHTTPRequestWithRawPacketWithRedirectFullEx( https bool, host string, port int, r []byte, timeout time.Duration, redirectTimes int, jsRedirect bool, redirectHandler func(isHttps bool, req []byte, rsp []byte) bool, noFixContentLength bool, forceHttp2 bool, proxy ...string) ([]byte, [][]byte, error)
SendHTTPRequestWithRawPacketWithRedirectFullEx
func SendHTTPRequestWithRawPacketWithRedirectWithContextFullEx ¶
func SendHTTPRequestWithRawPacketWithRedirectWithContextFullEx( https bool, host string, port int, r []byte, timeout time.Duration, redirectTimes int, jsRedirect bool, ctx context.Context, redirectHandler func(isHttps bool, req []byte, rsp []byte) bool, noFixContentLength bool, forceHttp2 bool, source string, proxy ...string) ([]byte, [][]byte, error)
func SendHTTPRequestWithRawPacketWithRedirectWithStateFullEx ¶
func SendHTTPRequestWithRawPacketWithRedirectWithStateFullEx( https bool, host string, port int, r []byte, timeout time.Duration, redirectTimes int, jsRedirect bool, redirectHandler func(isHttps bool, req []byte, rsp []byte) bool, noFixContentLength bool, forceHttp2 bool, proxy ...string) ([]byte, [][]byte, bool, error)
SendHTTPRequestWithRawPacketWithRedirectWithState 返回端口状态
func SendPacketQuick ¶
func ShouldSendReqContentLength ¶
ShouldSendReqContentLength reports whether the http2.Transport should send a "content-length" request header. This logic is basically a copy of the net/http transferWriter.shouldSendContentLength. The contentLength is the corrected contentLength (so 0 means actually 0, not unknown). -1 means unknown.
func SplitHTTPHeader ¶
func ToUnquoteFuzzTag ¶
func TrimLeftHTTPPacket ¶
func TrimRightHTTPPacket ¶
func TrimSpaceHTTPPacket ¶
func UrlToGetRequestPacket ¶
func WebsocketFrameToData ¶
Types ¶
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
func DataToWebsocketFrame ¶
func (*Frame) GetMaskingKey ¶
func (*Frame) RawPayloadData ¶
func (*Frame) SetMaskingKey ¶
type FrameReader ¶
type FrameReader struct {
// contains filtered or unexported fields
}
func NewFrameReader ¶
func NewFrameReader(r io.Reader, isDeflate bool) *FrameReader
func NewFrameReaderFromBufio ¶
func NewFrameReaderFromBufio(r *bufio.Reader, isDeflate bool) *FrameReader
func (*FrameReader) ReadFrame ¶
func (fr *FrameReader) ReadFrame() (frame *Frame, err error)
type FrameWriter ¶
type FrameWriter struct {
// contains filtered or unexported fields
}
func NewFrameWriter ¶
func NewFrameWriter(w io.Writer, isDeflate bool) *FrameWriter
func NewFrameWriterFromBufio ¶
func NewFrameWriterFromBufio(w *bufio.Writer, isDeflate bool) *FrameWriter
func (*FrameWriter) Flush ¶
func (fw *FrameWriter) Flush() error
func (*FrameWriter) WriteBinary ¶
func (fw *FrameWriter) WriteBinary(data []byte, mask bool, headerBytes ...byte) (err error)
func (*FrameWriter) WriteFrame ¶
func (fw *FrameWriter) WriteFrame(frame *Frame, messageTypes ...int) (err error)
func (*FrameWriter) WritePong ¶
func (fw *FrameWriter) WritePong(data []byte, mask bool) (err error)
func (*FrameWriter) WriteRaw ¶
func (fw *FrameWriter) WriteRaw(raw []byte) (err error)
type LowhttpExecConfig ¶
type LowhttpExecConfig struct { Host string Port int Packet []byte Https bool Http2 bool Timeout time.Duration RedirectTimes int RetryTimes int RetryInStatusCode []int RetryNotInStatusCode []int RetryWaitTime time.Duration RetryMaxWaitTime time.Duration JsRedirect bool Proxy []string NoFixContentLength bool RedirectHandler func(bool, []byte, []byte) bool Session interface{} BeforeDoRequest func([]byte) []byte Ctx context.Context SaveHTTPFlow bool RequestSource string EtcHosts map[string]string DNSServers []string }
type LowhttpOpt ¶
type LowhttpOpt func(o *LowhttpExecConfig)
func WithBeforeDoRequest ¶
func WithBeforeDoRequest(h func([]byte) []byte) LowhttpOpt
func WithContext ¶
func WithContext(ctx context.Context) LowhttpOpt
func WithDNSServers ¶
func WithDNSServers(servers []string) LowhttpOpt
func WithETCHosts ¶
func WithETCHosts(hosts map[string]string) LowhttpOpt
func WithHost ¶
func WithHost(host string) LowhttpOpt
func WithHttp2 ¶
func WithHttp2(Http2 bool) LowhttpOpt
func WithHttps ¶
func WithHttps(https bool) LowhttpOpt
func WithJsRedirect ¶
func WithJsRedirect(jsRedirect bool) LowhttpOpt
func WithNoFixContentLength ¶
func WithNoFixContentLength(noFixContentLength bool) LowhttpOpt
func WithPacket ¶
func WithPacket(packet []byte) LowhttpOpt
func WithPort ¶
func WithPort(port int) LowhttpOpt
func WithProxy ¶
func WithProxy(proxy ...string) LowhttpOpt
func WithRedirectHandler ¶
func WithRedirectHandler(redirectHandler func(bool, []byte, []byte) bool) LowhttpOpt
func WithRedirectTimes ¶
func WithRedirectTimes(redirectTimes int) LowhttpOpt
func WithRetryInStatusCode ¶
func WithRetryInStatusCode(sc []int) LowhttpOpt
func WithRetryMaxWaitTime ¶
func WithRetryMaxWaitTime(retryMaxWaitTime time.Duration) LowhttpOpt
func WithRetryNotInStatusCode ¶
func WithRetryNotInStatusCode(sc []int) LowhttpOpt
func WithRetryTimes ¶
func WithRetryTimes(retryTimes int) LowhttpOpt
func WithRetryWaitTime ¶
func WithRetryWaitTime(retryWaitTime time.Duration) LowhttpOpt
func WithSaveHTTPFlow ¶
func WithSaveHTTPFlow(b bool) LowhttpOpt
func WithSession ¶
func WithSession(session interface{}) LowhttpOpt
func WithSource ¶
func WithSource(s string) LowhttpOpt
func WithTimeout ¶
func WithTimeout(timeout time.Duration) LowhttpOpt
type LowhttpResponse ¶
type LowhttpResponse struct { RawPacket []byte RedirectRawPackets [][]byte PortIsOpen bool TraceInfo *LowhttpTraceInfo Url string RemoteAddr string Proxy string Https bool Http2 bool RawRequest []byte Source string // 请求源 }
func SendHTTPRequestWithRawPacketWithRedirectWithStateWithOptFullEx ¶
func SendHTTPRequestWithRawPacketWithRedirectWithStateWithOptFullEx(opts ...LowhttpOpt) (*LowhttpResponse, error)
SendHTTPRequestWithRawPacketWithRedirectWithStateWithOptFullEx
func SendHttpRequestWithRawPacketWithOptEx ¶
func SendHttpRequestWithRawPacketWithOptEx(opts ...LowhttpOpt) (*LowhttpResponse, error)
SendHttpRequestWithRawPacketWithOpt
func (*LowhttpResponse) GetDurationFloat ¶
func (l *LowhttpResponse) GetDurationFloat() float64
type LowhttpTraceInfo ¶
type LowhttpTraceInfo struct { AvailableDNSServers []string // DNS 完整请求时间 DNSTime time.Duration // 获取一个连接的耗时 ConnTime time.Duration // 服务器处理耗时,计算从连接建立到客户端收到第一个字节的时间间隔 ServerTime time.Duration // 完整请求的耗时 TotalTime time.Duration }
func (*LowhttpTraceInfo) GetServerDurationMS ¶
func (l *LowhttpTraceInfo) GetServerDurationMS() int64
type WebHookServer ¶
type WebHookServer struct {
// contains filtered or unexported fields
}
func NewWebHookServer ¶
func NewWebHookServer(port int, cb func(data interface{})) *WebHookServer
func NewWebHookServerEx ¶
func NewWebHookServerEx(port int, cb func(data interface{})) *WebHookServer
func (*WebHookServer) Addr ¶
func (w *WebHookServer) Addr() string
func (*WebHookServer) Shutdown ¶
func (w *WebHookServer) Shutdown()
func (*WebHookServer) Start ¶
func (w *WebHookServer) Start()
type WebsocketClient ¶
type WebsocketClient struct { Request []byte Response []byte FromServerOnce *sync.Once FromServerHandler func([]byte) Context context.Context // contains filtered or unexported fields }
func NewWebsocketClient ¶
func NewWebsocketClient(packet []byte, opt ...WebsocketClientOpt) (*WebsocketClient, error)
func (*WebsocketClient) StartFromServer ¶
func (c *WebsocketClient) StartFromServer()
func (*WebsocketClient) Stop ¶
func (c *WebsocketClient) Stop()
func (*WebsocketClient) Wait ¶
func (c *WebsocketClient) Wait()
func (*WebsocketClient) Write ¶
func (c *WebsocketClient) Write(r []byte) error
func (*WebsocketClient) WriteBinary ¶
func (c *WebsocketClient) WriteBinary(r []byte) error
func (*WebsocketClient) WritePong ¶
func (c *WebsocketClient) WritePong(r []byte) error
func (*WebsocketClient) WriteText ¶
func (c *WebsocketClient) WriteText(r []byte) error
type WebsocketClientConfig ¶
type WebsocketClientOpt ¶
type WebsocketClientOpt func(config *WebsocketClientConfig)
func WithWebsocketFromServerHandler ¶
func WithWebsocketFromServerHandler(f func([]byte)) WebsocketClientOpt
func WithWebsocketHost ¶
func WithWebsocketHost(t string) WebsocketClientOpt
func WithWebsocketPort ¶
func WithWebsocketPort(t int) WebsocketClientOpt
func WithWebsocketProxy ¶
func WithWebsocketProxy(t string) WebsocketClientOpt
func WithWebsocketTLS ¶
func WithWebsocketTLS(t bool) WebsocketClientOpt
func WithWebsocketTotalTimeout ¶
func WithWebsocketTotalTimeout(t float64) WebsocketClientOpt
func WithWebsocketWithContext ¶
func WithWebsocketWithContext(ctx context.Context) WebsocketClientOpt
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package http2 implements the HTTP/2 protocol.
|
Package http2 implements the HTTP/2 protocol. |
hpack
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
|
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2. |
Click to show internal directories.
Click to hide internal directories.