github.com/mholt/caddy-l4@v0.0.0-20241104153248-ec8fae209322/integration/caddyfile_adapt/gd_matcher_regexp.caddytest (about)

     1  {
     2  	layer4 {
     3  		:12345 {
     4  			# regexp reads only 4 bytes by default
     5  			@r1 regexp \d+
     6  			route @r1 {
     7  				proxy r1.machine.local:10001
     8  			}
     9  			@r2 regexp \xFF\xEE\xDD\xCC\xBB\xAA 6
    10  			route @r2 {
    11  				proxy r2.machine.local:10001
    12  			}
    13  			@r3 regexp ^(b|c|r)at(.*)\x00\x00$ 10
    14  			route @r3 {
    15  				proxy r3.machine.local:10001
    16  			}
    17  			route {
    18  				echo
    19  			}
    20  		}
    21  	}
    22  }
    23  ----------
    24  {
    25  	"apps": {
    26  		"layer4": {
    27  			"servers": {
    28  				"srv0": {
    29  					"listen": [
    30  						":12345"
    31  					],
    32  					"routes": [
    33  						{
    34  							"match": [
    35  								{
    36  									"regexp": {
    37  										"pattern": "\\d+"
    38  									}
    39  								}
    40  							],
    41  							"handle": [
    42  								{
    43  									"handler": "proxy",
    44  									"upstreams": [
    45  										{
    46  											"dial": [
    47  												"r1.machine.local:10001"
    48  											]
    49  										}
    50  									]
    51  								}
    52  							]
    53  						},
    54  						{
    55  							"match": [
    56  								{
    57  									"regexp": {
    58  										"count": 6,
    59  										"pattern": "\\xFF\\xEE\\xDD\\xCC\\xBB\\xAA"
    60  									}
    61  								}
    62  							],
    63  							"handle": [
    64  								{
    65  									"handler": "proxy",
    66  									"upstreams": [
    67  										{
    68  											"dial": [
    69  												"r2.machine.local:10001"
    70  											]
    71  										}
    72  									]
    73  								}
    74  							]
    75  						},
    76  						{
    77  							"match": [
    78  								{
    79  									"regexp": {
    80  										"count": 10,
    81  										"pattern": "^(b|c|r)at(.*)\\x00\\x00$"
    82  									}
    83  								}
    84  							],
    85  							"handle": [
    86  								{
    87  									"handler": "proxy",
    88  									"upstreams": [
    89  										{
    90  											"dial": [
    91  												"r3.machine.local:10001"
    92  											]
    93  										}
    94  									]
    95  								}
    96  							]
    97  						},
    98  						{
    99  							"handle": [
   100  								{
   101  									"handler": "echo"
   102  								}
   103  							]
   104  						}
   105  					]
   106  				}
   107  			}
   108  		}
   109  	}
   110  }