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

     1  {
     2  	layer4 {
     3  		:8080 {
     4  			@night_m clock before 05:00:00
     5  			@morning clock 05:00:00 12:00:00
     6  			@afternoon clock 12:00:00 17:00:00
     7  			@evening clock 17:00:00 21:00:00
     8  			@night_e clock after 21:00:00
     9  			route @night_m @night_e {
    10  				proxy 00.upstream.local:8080
    11  			}
    12  			route @morning {
    13  				proxy 01.upstream.local:8080 02.upstream.local:8080
    14  			}
    15  			route @afternoon {
    16  				proxy 03.upstream.local:8080 04.upstream.local:8080 05.upstream.local:8080
    17  			}
    18  			route @evening {
    19  				proxy 06.upstream.local:8080 07.upstream.local:8080
    20  			}
    21  		}
    22  		:8888 {
    23  			@la_is_awake clock 08:00:00 20:00:00 America/Los_Angeles
    24  			route @la_is_awake {
    25  				proxy existing.machine.local:8888
    26  			}
    27  			@la_is_asleep not clock 08:00:00 20:00:00 America/Los_Angeles
    28  			route @la_is_asleep {
    29  				proxy non-existing.machine.local:8888
    30  			}
    31  		}
    32  	}
    33  }
    34  ----------
    35  {
    36  	"apps": {
    37  		"layer4": {
    38  			"servers": {
    39  				"srv0": {
    40  					"listen": [
    41  						":8080"
    42  					],
    43  					"routes": [
    44  						{
    45  							"match": [
    46  								{
    47  									"clock": {
    48  										"after": "00:00:00",
    49  										"before": "05:00:00"
    50  									}
    51  								},
    52  								{
    53  									"clock": {
    54  										"after": "21:00:00",
    55  										"before": "00:00:00"
    56  									}
    57  								}
    58  							],
    59  							"handle": [
    60  								{
    61  									"handler": "proxy",
    62  									"upstreams": [
    63  										{
    64  											"dial": [
    65  												"00.upstream.local:8080"
    66  											]
    67  										}
    68  									]
    69  								}
    70  							]
    71  						},
    72  						{
    73  							"match": [
    74  								{
    75  									"clock": {
    76  										"after": "05:00:00",
    77  										"before": "12:00:00"
    78  									}
    79  								}
    80  							],
    81  							"handle": [
    82  								{
    83  									"handler": "proxy",
    84  									"upstreams": [
    85  										{
    86  											"dial": [
    87  												"01.upstream.local:8080"
    88  											]
    89  										},
    90  										{
    91  											"dial": [
    92  												"02.upstream.local:8080"
    93  											]
    94  										}
    95  									]
    96  								}
    97  							]
    98  						},
    99  						{
   100  							"match": [
   101  								{
   102  									"clock": {
   103  										"after": "12:00:00",
   104  										"before": "17:00:00"
   105  									}
   106  								}
   107  							],
   108  							"handle": [
   109  								{
   110  									"handler": "proxy",
   111  									"upstreams": [
   112  										{
   113  											"dial": [
   114  												"03.upstream.local:8080"
   115  											]
   116  										},
   117  										{
   118  											"dial": [
   119  												"04.upstream.local:8080"
   120  											]
   121  										},
   122  										{
   123  											"dial": [
   124  												"05.upstream.local:8080"
   125  											]
   126  										}
   127  									]
   128  								}
   129  							]
   130  						},
   131  						{
   132  							"match": [
   133  								{
   134  									"clock": {
   135  										"after": "17:00:00",
   136  										"before": "21:00:00"
   137  									}
   138  								}
   139  							],
   140  							"handle": [
   141  								{
   142  									"handler": "proxy",
   143  									"upstreams": [
   144  										{
   145  											"dial": [
   146  												"06.upstream.local:8080"
   147  											]
   148  										},
   149  										{
   150  											"dial": [
   151  												"07.upstream.local:8080"
   152  											]
   153  										}
   154  									]
   155  								}
   156  							]
   157  						}
   158  					]
   159  				},
   160  				"srv1": {
   161  					"listen": [
   162  						":8888"
   163  					],
   164  					"routes": [
   165  						{
   166  							"match": [
   167  								{
   168  									"clock": {
   169  										"after": "08:00:00",
   170  										"before": "20:00:00",
   171  										"timezone": "America/Los_Angeles"
   172  									}
   173  								}
   174  							],
   175  							"handle": [
   176  								{
   177  									"handler": "proxy",
   178  									"upstreams": [
   179  										{
   180  											"dial": [
   181  												"existing.machine.local:8888"
   182  											]
   183  										}
   184  									]
   185  								}
   186  							]
   187  						},
   188  						{
   189  							"match": [
   190  								{
   191  									"not": [
   192  										{
   193  											"clock": {
   194  												"after": "08:00:00",
   195  												"before": "20:00:00",
   196  												"timezone": "America/Los_Angeles"
   197  											}
   198  										}
   199  									]
   200  								}
   201  							],
   202  							"handle": [
   203  								{
   204  									"handler": "proxy",
   205  									"upstreams": [
   206  										{
   207  											"dial": [
   208  												"non-existing.machine.local:8888"
   209  											]
   210  										}
   211  									]
   212  								}
   213  							]
   214  						}
   215  					]
   216  				}
   217  			}
   218  		}
   219  	}
   220  }