ruleset: emit time ranges when both start and stop times are specified
[project/firewall4.git] / root / usr / share / firewall4 / templates / redirect.uc
index 3d1c113bf7e105947bcc4e7ced8e11dc213536f9..5b81f64bab240e0bfd8e9e809de06285d0b3a1cc 100644 (file)
 {%+ if (redirect.limit): -%}
        limit rate {{ redirect.limit.rate }}/{{ redirect.limit.unit }}
        {%- if (redirect.limit_burst): %} burst {{ redirect.limit_burst }} packets{% endif %} {%+ endif -%}
-{%+ if (redirect.start_date): -%}
-       meta time >= {{
-               exists(redirect.start_date, "hour") ? fw4.datetime(redirect.start_date) : fw4.date(redirect.start_date)
-       }} {%+ endif -%}
-{%+ if (redirect.stop_date): -%}
-       meta time <= {{
-               exists(redirect.stop_date, "hour") ? fw4.datetime(redirect.stop_date) : fw4.date(redirect.stop_date)
-       }} {%+ endif -%}
-{%+ if (redirect.start_time): -%}
-       meta hour >= {{ fw4.time(redirect.start_time) }} {%+ endif -%}
-{%+ if (redirect.stop_time): -%}
-       meta hour <= {{ fw4.time(redirect.stop_time) }} {%+ endif -%}
+{%+ if (redirect.start_date && redirect.stop_date): -%}
+       meta time {{ fw4.datestamp(redirect.start_date) }}-{{ fw4.datestamp(redirect.stop_date) }} {%+
+   elif (redirect.start_date): -%}
+       meta time >= {{ fw4.datestamp(redirect.start_date) }} {%+
+   elif (redirect.stop_date): -%}
+       meta time <= {{ fw4.datestamp(redirect.stop_date) }} {%+
+   endif -%}
+{%+ if (redirect.start_time && redirect.stop_time): -%}
+       meta hour {{ fw4.time(redirect.start_time) }}-{{ fw4.time(redirect.stop_time) }} {%+
+   elif (redirect.start_time): -%}
+       meta hour >= {{ fw4.time(redirect.start_time) }} {%+
+   elif (redirect.stop_time): -%}
+       meta hour <= {{ fw4.time(redirect.stop_time) }} {%+
+   endif -%}
 {%+ if (redirect.weekdays): -%}
        meta day{% if (redirect.weekdays.invert): %} !={% endif %} {{ fw4.set(redirect.weekdays.days) }} {%+ endif -%}
 {%+ if (redirect.mark && redirect.mark.mask < 0xFFFFFFFF): -%}