2021-11-03 13:06:54 +00:00
package websocket
import (
"context"
"crypto/tls"
2021-11-03 13:28:00 +00:00
"fmt"
2021-11-03 13:06:54 +00:00
"io"
2021-11-03 21:26:59 +00:00
"net"
2021-11-03 13:06:54 +00:00
"net/http"
"net/url"
2021-11-03 21:32:29 +00:00
"path"
2021-11-03 13:06:54 +00:00
"strings"
"time"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
"github.com/pkg/errors"
2021-11-25 15:09:20 +00:00
2021-11-03 13:06:54 +00:00
"github.com/projectdiscovery/fastdialer/fastdialer"
"github.com/projectdiscovery/gologger"
2023-10-17 12:14:13 +00:00
"github.com/projectdiscovery/nuclei/v3/pkg/operators"
"github.com/projectdiscovery/nuclei/v3/pkg/operators/extractors"
"github.com/projectdiscovery/nuclei/v3/pkg/operators/matchers"
"github.com/projectdiscovery/nuclei/v3/pkg/output"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/contextargs"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/expressions"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/generators"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/helpers/eventcreator"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/helpers/responsehighlighter"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/utils/vardump"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/network/networkclientpool"
protocolutils "github.com/projectdiscovery/nuclei/v3/pkg/protocols/utils"
templateTypes "github.com/projectdiscovery/nuclei/v3/pkg/templates/types"
"github.com/projectdiscovery/nuclei/v3/pkg/types"
2023-01-05 11:11:59 +00:00
urlutil "github.com/projectdiscovery/utils/url"
2021-11-03 13:06:54 +00:00
)
// Request is a request for the Websocket protocol
type Request struct {
// Operators for the current request go here.
2023-02-07 08:10:40 +00:00
operators . Operators ` yaml:",inline,omitempty" json:",inline,omitempty" `
CompiledOperators * operators . Operators ` yaml:"-" json:"-" `
2021-11-03 13:06:54 +00:00
2023-08-31 12:33:01 +00:00
// ID is the optional id of the request
ID string ` yaml:"id,omitempty" json:"id,omitempty" jsonschema:"title=id of the request,description=ID of the network request" `
2021-11-03 13:06:54 +00:00
// description: |
// Address contains address for the request
2023-02-07 08:10:40 +00:00
Address string ` yaml:"address,omitempty" json:"address,omitempty" jsonschema:"title=address for the websocket request,description=Address contains address for the request" `
2021-11-03 13:06:54 +00:00
// description: |
// Inputs contains inputs for the websocket protocol
2023-02-07 08:10:40 +00:00
Inputs [ ] * Input ` yaml:"inputs,omitempty" json:"inputs,omitempty" jsonschema:"title=inputs for the websocket request,description=Inputs contains any input/output for the current request" `
2021-11-03 13:06:54 +00:00
// description: |
// Headers contains headers for the request.
2023-02-07 08:10:40 +00:00
Headers map [ string ] string ` yaml:"headers,omitempty" json:"headers,omitempty" jsonschema:"title=headers contains the request headers,description=Headers contains headers for the request" `
2021-11-03 13:06:54 +00:00
// description: |
// Attack is the type of payload combinations to perform.
//
// Sniper is each payload once, pitchfork combines multiple payload sets and clusterbomb generates
// permutations and combinations for all payloads.
2023-02-07 08:10:40 +00:00
AttackType generators . AttackTypeHolder ` yaml:"attack,omitempty" json:"attack,omitempty" jsonschema:"title=attack is the payload combination,description=Attack is the type of payload combinations to perform,enum=sniper,enum=pitchfork,enum=clusterbomb" `
2021-11-03 13:06:54 +00:00
// description: |
// Payloads contains any payloads for the current request.
//
// Payloads support both key-values combinations where a list
// of payloads is provided, or optionally a single file can also
// be provided as payload which will be read on run-time.
2023-08-01 18:33:43 +00:00
Payloads map [ string ] interface { } ` yaml:"payloads,omitempty" json:"payloads,omitempty" jsonschema:"title=payloads for the websocket request,description=Payloads contains any payloads for the current request" `
2021-11-03 13:06:54 +00:00
2021-11-04 21:31:41 +00:00
generator * generators . PayloadGenerator
2021-11-03 13:06:54 +00:00
// cache any variables that may be needed for operation.
dialer * fastdialer . Dialer
2023-05-31 20:58:10 +00:00
options * protocols . ExecutorOptions
2021-11-03 13:06:54 +00:00
}
// Input is an input for the websocket protocol
type Input struct {
// description: |
// Data is the data to send as the input.
//
// It supports DSL Helper Functions as well as normal expressions.
// examples:
// - value: "\"TEST\""
// - value: "\"hex_decode('50494e47')\""
2023-02-07 08:10:40 +00:00
Data string ` yaml:"data,omitempty" json:"data,omitempty" jsonschema:"title=data to send as input,description=Data is the data to send as the input" `
2021-11-03 13:06:54 +00:00
// description: |
// Name is the optional name of the data read to provide matching on.
// examples:
// - value: "\"prefix\""
2023-02-07 08:10:40 +00:00
Name string ` yaml:"name,omitempty" json:"name,omitempty" jsonschema:"title=optional name for data read,description=Optional name of the data read to provide matching on" `
2021-11-03 13:06:54 +00:00
}
2022-05-12 10:10:14 +00:00
const (
2022-06-04 12:15:16 +00:00
parseUrlErrorMessage = "could not parse input url"
2022-05-12 10:10:14 +00:00
evaluateTemplateExpressionErrorMessage = "could not evaluate template expressions"
)
2021-11-03 13:06:54 +00:00
// Compile compiles the request generators preparing any requests possible.
2023-05-31 20:58:10 +00:00
func ( request * Request ) Compile ( options * protocols . ExecutorOptions ) error {
2021-11-03 13:06:54 +00:00
request . options = options
client , err := networkclientpool . Get ( options . Options , & networkclientpool . Configuration { } )
if err != nil {
return errors . Wrap ( err , "could not get network client" )
}
request . dialer = client
if len ( request . Payloads ) > 0 {
2023-08-31 12:33:01 +00:00
request . generator , err = generators . New ( request . Payloads , request . AttackType . Value , request . options . TemplatePath , options . Catalog , options . Options . AttackType , types . DefaultOptions ( ) )
2021-11-03 13:06:54 +00:00
if err != nil {
return errors . Wrap ( err , "could not parse payloads" )
}
}
if len ( request . Matchers ) > 0 || len ( request . Extractors ) > 0 {
compiled := & request . Operators
2022-06-24 17:39:27 +00:00
compiled . ExcludeMatchers = options . ExcludeMatchers
compiled . TemplateID = options . TemplateID
2021-11-03 13:06:54 +00:00
if err := compiled . Compile ( ) ; err != nil {
return errors . Wrap ( err , "could not compile operators" )
}
request . CompiledOperators = compiled
}
return nil
}
// Requests returns the total number of requests the rule will perform
func ( request * Request ) Requests ( ) int {
if request . generator != nil {
return request . generator . NewIterator ( ) . Total ( )
}
return 1
}
// GetID returns the ID for the request if any.
func ( request * Request ) GetID ( ) string {
return ""
}
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
2022-10-03 10:12:20 +00:00
func ( request * Request ) ExecuteWithResults ( input * contextargs . Context , dynamicValues , previous output . InternalEvent , callback protocols . OutputEventCallback ) error {
2022-11-09 13:18:56 +00:00
hostname , err := getAddress ( input . MetaInput . Input )
2021-11-03 13:06:54 +00:00
if err != nil {
2021-11-03 13:28:00 +00:00
return err
2021-11-03 13:06:54 +00:00
}
if request . generator != nil {
iterator := request . generator . NewIterator ( )
for {
value , ok := iterator . Value ( )
if ! ok {
break
}
2023-08-31 12:33:01 +00:00
if err := request . executeRequestWithPayloads ( input , hostname , value , previous , callback ) ; err != nil {
2021-11-03 13:06:54 +00:00
return err
}
}
} else {
value := make ( map [ string ] interface { } )
2023-08-31 12:33:01 +00:00
if err := request . executeRequestWithPayloads ( input , hostname , value , previous , callback ) ; err != nil {
2021-11-03 13:06:54 +00:00
return err
}
}
return nil
}
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
2023-08-31 12:33:01 +00:00
func ( request * Request ) executeRequestWithPayloads ( target * contextargs . Context , hostname string , dynamicValues , previous output . InternalEvent , callback protocols . OutputEventCallback ) error {
2021-11-03 13:06:54 +00:00
header := http . Header { }
2023-08-31 12:33:01 +00:00
input := target . MetaInput . Input
2021-11-03 13:06:54 +00:00
2023-04-11 20:20:58 +00:00
parsed , err := urlutil . Parse ( input )
2021-11-03 13:06:54 +00:00
if err != nil {
2022-05-12 10:10:14 +00:00
return errors . Wrap ( err , parseUrlErrorMessage )
2021-11-03 13:06:54 +00:00
}
2023-05-02 18:19:56 +00:00
defaultVars := protocolutils . GenerateVariables ( parsed , false , nil )
2023-04-11 20:20:58 +00:00
optionVars := generators . BuildPayloadFromOptions ( request . options . Options )
2023-06-09 14:22:56 +00:00
// add templatecontext variables to varMap
2023-08-31 12:33:01 +00:00
variables := request . options . Variables . Evaluate ( generators . MergeMaps ( defaultVars , optionVars , dynamicValues , request . options . GetTemplateCtx ( target . MetaInput ) . GetAll ( ) ) )
2023-05-25 16:32:35 +00:00
payloadValues := generators . MergeMaps ( variables , defaultVars , optionVars , dynamicValues , request . options . Constants )
2021-11-03 13:06:54 +00:00
2021-11-04 21:31:41 +00:00
requestOptions := request . options
2021-11-03 13:06:54 +00:00
for key , value := range request . Headers {
finalData , dataErr := expressions . EvaluateByte ( [ ] byte ( value ) , payloadValues )
if dataErr != nil {
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , dataErr )
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2022-05-12 10:10:14 +00:00
return errors . Wrap ( dataErr , evaluateTemplateExpressionErrorMessage )
2021-11-03 13:06:54 +00:00
}
header . Set ( key , string ( finalData ) )
}
2022-06-04 12:15:16 +00:00
tlsConfig := & tls . Config {
InsecureSkipVerify : true ,
ServerName : hostname ,
MinVersion : tls . VersionTLS10 ,
}
2022-05-11 10:30:39 +00:00
if requestOptions . Options . SNI != "" {
tlsConfig . ServerName = requestOptions . Options . SNI
}
2021-11-03 13:06:54 +00:00
websocketDialer := ws . Dialer {
Header : ws . HandshakeHeaderHTTP ( header ) ,
2021-11-04 21:31:41 +00:00
Timeout : time . Duration ( requestOptions . Options . Timeout ) * time . Second ,
2021-11-03 13:06:54 +00:00
NetDial : request . dialer . Dial ,
2022-05-11 10:30:39 +00:00
TLSConfig : tlsConfig ,
2021-11-03 13:06:54 +00:00
}
2022-11-01 14:58:50 +00:00
if vardump . EnableVarDump {
2023-10-13 07:47:27 +00:00
gologger . Debug ( ) . Msgf ( "Websocket Protocol request variables: \n%s\n" , vardump . DumpVariables ( payloadValues ) )
2022-08-25 10:07:03 +00:00
}
2021-11-03 13:06:54 +00:00
finalAddress , dataErr := expressions . EvaluateByte ( [ ] byte ( request . Address ) , payloadValues )
if dataErr != nil {
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , dataErr )
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2022-05-12 10:10:14 +00:00
return errors . Wrap ( dataErr , evaluateTemplateExpressionErrorMessage )
2021-11-03 13:06:54 +00:00
}
2021-11-03 21:32:29 +00:00
2021-11-03 13:06:54 +00:00
addressToDial := string ( finalAddress )
2021-11-03 21:32:29 +00:00
parsedAddress , err := url . Parse ( addressToDial )
if err != nil {
2021-11-08 12:26:14 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , err )
2021-11-04 21:31:41 +00:00
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2022-05-12 10:10:14 +00:00
return errors . Wrap ( err , parseUrlErrorMessage )
2021-11-03 21:32:29 +00:00
}
2021-11-04 21:31:41 +00:00
parsedAddress . Path = path . Join ( parsedAddress . Path , parsed . Path )
addressToDial = parsedAddress . String ( )
2021-11-03 13:06:54 +00:00
conn , readBuffer , _ , err := websocketDialer . Dial ( context . Background ( ) , addressToDial )
if err != nil {
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , err )
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2021-11-03 13:06:54 +00:00
return errors . Wrap ( err , "could not connect to server" )
}
defer conn . Close ( )
responseBuilder := & strings . Builder { }
if readBuffer != nil {
_ , _ = io . Copy ( responseBuilder , readBuffer ) // Copy initial response
}
2021-11-03 21:26:59 +00:00
events , requestOutput , err := request . readWriteInputWebsocket ( conn , payloadValues , input , responseBuilder )
if err != nil {
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , err )
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2021-11-03 21:26:59 +00:00
return errors . Wrap ( err , "could not read write response" )
}
2021-11-04 21:31:41 +00:00
requestOptions . Progress . IncrementRequests ( )
2021-11-03 21:26:59 +00:00
2021-11-04 21:31:41 +00:00
if requestOptions . Options . Debug || requestOptions . Options . DebugRequests {
gologger . Debug ( ) . Str ( "address" , input ) . Msgf ( "[%s] Dumped Websocket request for %s" , requestOptions . TemplateID , input )
2021-11-03 21:26:59 +00:00
gologger . Print ( ) . Msgf ( "%s" , requestOutput )
}
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , err )
2021-11-03 21:26:59 +00:00
gologger . Verbose ( ) . Msgf ( "Sent Websocket request to %s" , input )
data := make ( map [ string ] interface { } )
2021-11-22 12:23:25 +00:00
data [ "type" ] = request . Type ( ) . String ( )
2021-11-03 21:26:59 +00:00
data [ "success" ] = "true"
data [ "request" ] = requestOutput
data [ "response" ] = responseBuilder . String ( )
data [ "host" ] = input
2021-11-03 21:32:29 +00:00
data [ "matched" ] = addressToDial
2021-11-03 21:26:59 +00:00
data [ "ip" ] = request . dialer . GetDialedIP ( hostname )
2023-06-09 14:22:56 +00:00
// add response fields to template context and merge templatectx variables to output event
2023-08-31 12:33:01 +00:00
request . options . AddTemplateVars ( target . MetaInput , request . Type ( ) , request . ID , data )
data = generators . MergeMaps ( data , request . options . GetTemplateCtx ( target . MetaInput ) . GetAll ( ) )
2023-06-09 14:22:56 +00:00
for k , v := range previous {
data [ k ] = v
}
for k , v := range events {
data [ k ] = v
}
2021-11-04 21:31:41 +00:00
event := eventcreator . CreateEventWithAdditionalOptions ( request , data , requestOptions . Options . Debug || requestOptions . Options . DebugResponse , func ( internalWrappedEvent * output . InternalWrappedEvent ) {
2021-11-03 21:26:59 +00:00
internalWrappedEvent . OperatorsResult . PayloadValues = payloadValues
} )
2021-11-04 21:31:41 +00:00
if requestOptions . Options . Debug || requestOptions . Options . DebugResponse {
2021-11-03 21:26:59 +00:00
responseOutput := responseBuilder . String ( )
2021-11-04 21:31:41 +00:00
gologger . Debug ( ) . Msgf ( "[%s] Dumped Websocket response for %s" , requestOptions . TemplateID , input )
gologger . Print ( ) . Msgf ( "%s" , responsehighlighter . Highlight ( event . OperatorsResult , responseOutput , requestOptions . Options . NoColor , false ) )
2021-11-03 21:26:59 +00:00
}
callback ( event )
return nil
}
2021-11-03 13:06:54 +00:00
2021-11-03 21:26:59 +00:00
func ( request * Request ) readWriteInputWebsocket ( conn net . Conn , payloadValues map [ string ] interface { } , input string , respBuilder * strings . Builder ) ( events map [ string ] interface { } , req string , err error ) {
reqBuilder := & strings . Builder { }
2021-11-03 13:06:54 +00:00
inputEvents := make ( map [ string ] interface { } )
2021-11-03 21:26:59 +00:00
2021-11-04 21:31:41 +00:00
requestOptions := request . options
2021-11-03 13:06:54 +00:00
for _ , req := range request . Inputs {
reqBuilder . Grow ( len ( req . Data ) )
finalData , dataErr := expressions . EvaluateByte ( [ ] byte ( req . Data ) , payloadValues )
if dataErr != nil {
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , dataErr )
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2022-05-12 10:10:14 +00:00
return nil , "" , errors . Wrap ( dataErr , evaluateTemplateExpressionErrorMessage )
2021-11-03 13:06:54 +00:00
}
reqBuilder . WriteString ( string ( finalData ) )
err = wsutil . WriteClientMessage ( conn , ws . OpText , finalData )
if err != nil {
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , err )
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2021-11-03 21:26:59 +00:00
return nil , "" , errors . Wrap ( err , "could not write request to server" )
2021-11-03 13:06:54 +00:00
}
2021-11-03 14:38:11 +00:00
msg , opCode , err := wsutil . ReadServerData ( conn )
2021-11-03 13:06:54 +00:00
if err != nil {
2021-11-04 21:31:41 +00:00
requestOptions . Output . Request ( requestOptions . TemplateID , input , request . Type ( ) . String ( ) , err )
requestOptions . Progress . IncrementFailedRequestsBy ( 1 )
2021-11-03 21:26:59 +00:00
return nil , "" , errors . Wrap ( err , "could not write request to server" )
2021-11-03 13:06:54 +00:00
}
2021-11-25 16:54:16 +00:00
// Only perform matching and writes in case we receive
2021-11-03 14:38:11 +00:00
// text or binary opcode from the websocket server.
if opCode != ws . OpText && opCode != ws . OpBinary {
continue
}
2021-11-03 13:06:54 +00:00
2021-11-03 21:26:59 +00:00
respBuilder . Write ( msg )
2021-11-03 13:06:54 +00:00
if req . Name != "" {
bufferStr := string ( msg )
2021-11-03 13:28:00 +00:00
inputEvents [ req . Name ] = bufferStr
2021-11-03 13:06:54 +00:00
// Run any internal extractors for the request here and add found values to map.
if request . CompiledOperators != nil {
values := request . CompiledOperators . ExecuteInternalExtractors ( map [ string ] interface { } { req . Name : bufferStr } , protocols . MakeDefaultExtractFunc )
for k , v := range values {
2021-11-03 21:26:59 +00:00
inputEvents [ k ] = v
2021-11-03 13:06:54 +00:00
}
}
}
}
2021-11-03 21:26:59 +00:00
return inputEvents , reqBuilder . String ( ) , nil
2021-11-03 13:06:54 +00:00
}
// getAddress returns the address of the host to make request to
func getAddress ( toTest string ) ( string , error ) {
2021-11-03 13:28:00 +00:00
parsed , err := url . Parse ( toTest )
if err != nil {
2022-05-12 10:10:14 +00:00
return "" , errors . Wrap ( err , parseUrlErrorMessage )
2021-11-03 13:28:00 +00:00
}
scheme := strings . ToLower ( parsed . Scheme )
if scheme != "ws" && scheme != "wss" {
return "" , fmt . Errorf ( "invalid url scheme provided: %s" , scheme )
2021-11-03 13:06:54 +00:00
}
if parsed != nil && parsed . Host != "" {
return parsed . Host , nil
}
return "" , nil
}
// Match performs matching operation for a matcher on model and returns:
// true and a list of matched snippets if the matcher type is supports it
// otherwise false and an empty string slice
func ( request * Request ) Match ( data map [ string ] interface { } , matcher * matchers . Matcher ) ( bool , [ ] string ) {
return protocols . MakeDefaultMatchFunc ( data , matcher )
}
// Extract performs extracting operation for an extractor on model and returns true or false.
func ( request * Request ) Extract ( data map [ string ] interface { } , matcher * extractors . Extractor ) map [ string ] struct { } {
return protocols . MakeDefaultExtractFunc ( data , matcher )
}
// MakeResultEvent creates a result event from internal wrapped event
func ( request * Request ) MakeResultEvent ( wrapped * output . InternalWrappedEvent ) [ ] * output . ResultEvent {
return protocols . MakeDefaultResultEvent ( request , wrapped )
}
// GetCompiledOperators returns a list of the compiled operators
func ( request * Request ) GetCompiledOperators ( ) [ ] * operators . Operators {
return [ ] * operators . Operators { request . CompiledOperators }
}
2021-11-26 10:53:54 +00:00
// RequestPartDefinitions contains a mapping of request part definitions and their
// description. Multiple definitions are separated by commas.
// Definitions not having a name (generated on runtime) are prefixed & suffixed by <>.
var RequestPartDefinitions = map [ string ] string {
"type" : "Type is the type of request made" ,
"success" : "Success specifies whether websocket connection was successful" ,
"request" : "Websocket request made to the server" ,
2022-02-07 14:41:55 +00:00
"response" : "Websocket response received from the server" ,
2021-11-26 10:53:54 +00:00
"host" : "Host is the input to the template" ,
"matched" : "Matched is the input which was matched upon" ,
}
2021-11-03 13:06:54 +00:00
func ( request * Request ) MakeResultEventItem ( wrapped * output . InternalWrappedEvent ) * output . ResultEvent {
2023-11-28 08:56:23 +00:00
fields := protocolutils . GetJsonFieldsFromURL ( types . ToString ( wrapped . InternalEvent [ "host" ] ) )
if types . ToString ( wrapped . InternalEvent [ "ip" ] ) != "" {
fields . Ip = types . ToString ( wrapped . InternalEvent [ "ip" ] )
}
2021-11-03 13:06:54 +00:00
data := & output . ResultEvent {
TemplateID : types . ToString ( request . options . TemplateID ) ,
TemplatePath : types . ToString ( request . options . TemplatePath ) ,
Info : request . options . TemplateInfo ,
2021-11-22 12:23:25 +00:00
Type : types . ToString ( wrapped . InternalEvent [ "type" ] ) ,
2023-11-28 08:56:23 +00:00
Host : fields . Host ,
Port : fields . Port ,
2021-11-03 21:32:29 +00:00
Matched : types . ToString ( wrapped . InternalEvent [ "matched" ] ) ,
2021-11-03 13:06:54 +00:00
Metadata : wrapped . OperatorsResult . PayloadValues ,
ExtractedResults : wrapped . OperatorsResult . OutputExtracts ,
Timestamp : time . Now ( ) ,
2021-11-22 12:23:25 +00:00
MatcherStatus : true ,
2023-11-28 08:56:23 +00:00
IP : fields . Ip ,
2021-11-03 13:06:54 +00:00
Request : types . ToString ( wrapped . InternalEvent [ "request" ] ) ,
Response : types . ToString ( wrapped . InternalEvent [ "response" ] ) ,
2023-11-10 23:12:27 +00:00
TemplateEncoded : request . options . EncodeTemplate ( ) ,
2023-11-27 18:54:45 +00:00
Error : types . ToString ( wrapped . InternalEvent [ "error" ] ) ,
2021-11-03 13:06:54 +00:00
}
return data
}
2021-11-03 14:23:45 +00:00
// Type returns the type of the protocol request
func ( request * Request ) Type ( ) templateTypes . ProtocolType {
return templateTypes . WebsocketProtocol
}