@@ -3103,6 +3103,39 @@ class FilterIPAddress {
31033103
31043104registerFilterClass ( FilterIPAddress ) ;
31053105
3106+ /******************************************************************************/
3107+
3108+ class FilterMessage {
3109+ static match ( ) {
3110+ return true ;
3111+ }
3112+
3113+ static compile ( details ) {
3114+ return [
3115+ FilterMessage . fid ,
3116+ encodeURIComponent ( details . optionValues . get ( 'message' ) ) ,
3117+ ] ;
3118+ }
3119+
3120+ static fromCompiled ( args ) {
3121+ const msg = args [ 1 ] ;
3122+ return filterDataAlloc ( args [ 0 ] , bidiTrie . storeString ( msg ) , msg . length ) ;
3123+ }
3124+
3125+ static keyFromArgs ( ) {
3126+ }
3127+
3128+ static logData ( idata , details ) {
3129+ const msg = bidiTrie . extractString (
3130+ filterData [ idata + 1 ] ,
3131+ filterData [ idata + 2 ]
3132+ ) ;
3133+ details . options . push ( `message=${ decodeURIComponent ( msg ) } ` ) ;
3134+ }
3135+ }
3136+
3137+ registerFilterClass ( FilterMessage ) ;
3138+
31063139/******************************************************************************/
31073140/******************************************************************************/
31083141
@@ -3578,6 +3611,10 @@ class FilterCompiler {
35783611 this . optionValues . set ( 'ipaddress' , parser . getNetOptionValue ( id ) || '' ) ;
35793612 this . optionUnitBits |= IPADDRESS_BIT ;
35803613 break ;
3614+ case sfp . NODE_TYPE_NET_OPTION_NAME_MESSAGE :
3615+ this . optionValues . set ( 'message' , parser . getNetOptionValue ( id ) ) ;
3616+ this . optionUnitBits |= MESSAGE_BIT ;
3617+ break ;
35813618 case sfp . NODE_TYPE_NET_OPTION_NAME_METHOD :
35823619 this . processMethodOption ( parser . getNetOptionValue ( id ) ) ;
35833620 this . optionUnitBits |= METHOD_BIT ;
@@ -3699,6 +3736,7 @@ class FilterCompiler {
36993736 case sfp . NODE_TYPE_NET_OPTION_NAME_FROM :
37003737 case sfp . NODE_TYPE_NET_OPTION_NAME_HEADER :
37013738 case sfp . NODE_TYPE_NET_OPTION_NAME_IPADDRESS :
3739+ case sfp . NODE_TYPE_NET_OPTION_NAME_MESSAGE :
37023740 case sfp . NODE_TYPE_NET_OPTION_NAME_METHOD :
37033741 case sfp . NODE_TYPE_NET_OPTION_NAME_PERMISSIONS :
37043742 case sfp . NODE_TYPE_NET_OPTION_NAME_REDIRECT :
@@ -4081,6 +4119,11 @@ class FilterCompiler {
40814119 this . action |= HEADERS_REALM ;
40824120 }
40834121
4122+ // Message
4123+ if ( ( this . optionUnitBits & MESSAGE_BIT ) !== 0 ) {
4124+ units . push ( FilterMessage . compile ( this ) ) ;
4125+ }
4126+
40844127 // Important
40854128 //
40864129 // IMPORTANT: must always appear at the end of the sequence, so as to
@@ -4175,16 +4218,17 @@ class FilterCompiler {
41754218}
41764219
41774220// These are to quickly test whether a filter is composite
4178- const FROM_BIT = 0b0000000001 ;
4179- const TO_BIT = 0b0000000010 ;
4180- const DENYALLOW_BIT = 0b0000000100 ;
4181- const HEADER_BIT = 0b0000001000 ;
4182- const STRICT_PARTY_BIT = 0b0000010000 ;
4183- const MODIFY_BIT = 0b0000100000 ;
4184- const NOT_TYPE_BIT = 0b0001000000 ;
4185- const IMPORTANT_BIT = 0b0010000000 ;
4186- const METHOD_BIT = 0b0100000000 ;
4187- const IPADDRESS_BIT = 0b1000000000 ;
4221+ const FROM_BIT = 0b00000000001 ;
4222+ const TO_BIT = 0b00000000010 ;
4223+ const DENYALLOW_BIT = 0b00000000100 ;
4224+ const HEADER_BIT = 0b00000001000 ;
4225+ const STRICT_PARTY_BIT = 0b00000010000 ;
4226+ const MODIFY_BIT = 0b00000100000 ;
4227+ const NOT_TYPE_BIT = 0b00001000000 ;
4228+ const IMPORTANT_BIT = 0b00010000000 ;
4229+ const METHOD_BIT = 0b00100000000 ;
4230+ const IPADDRESS_BIT = 0b01000000000 ;
4231+ const MESSAGE_BIT = 0b10000000000
41884232
41894233FilterCompiler . prototype . FILTER_OK = 0 ;
41904234FilterCompiler . prototype . FILTER_INVALID = 1 ;
0 commit comments