Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Конфигурации фильтров являются общими для всех экземпляров плагинов. Набор используемых фильтров и порядок их вызова определяется списком plugins → base → <plugin_instance_name> → call_stack конфигурации конкретного экземпляра плагина.

...

Code Block
titleПример фильтра case_before: различное декодирование DHCP-опции 82 при различных форматах Circuit-Id
collapsetrue
plugins:
  filters:
    case_before:
      extractdecode_switch_port_number_from_circuit_idoption_82:
        tags: post_auth
        case:
          - when: $request.RAD_REQUEST.DHCP-Relay-Circuit-Id.like?("^0x0006[0-9a-f]{12}$")
            then:
              '$var.PE-Switch-MAC-Address': $request.RAD_REQUEST.DHCP-Relay-Remote-Id.substring(2).format_mac()
              '$var.PE-Switch-Port-Number': $request.RAD_REQUEST.DHCP-Relay-Circuit-Id.substring(-2).to_i(16).to_s()
          - when: $request.RAD_REQUEST.DHCP-Relay-Circuit-Id.like?("^0x[0-9a-f]{20}$")
            then:
              '$var.PE-Switch-MAC-Address': $request.RAD_REQUEST.DHCP-Relay-Remote-Id.substring(2).format_mac()
              '$var.PE-Switch-Port-Number': $request.RAD_REQUEST.DHCP-Relay-Circuit-Id.substring(-10, -8).to_i(16).to_s()
          - else:
              '$var.PE-Switch-IP-Address': $request.RAD_REQUEST.DHCP-Relay-Remote-Id.unhex()
              '$var.PE-Switch-Port-Number': $request.RAD_REQUEST.DHCP-Relay-Circuit-Id.unhex().regexp_replace("^.+/(\d+):\d+$", "\\1")

check_attr_before

Выполнение некоторого действия с запросом.

...

Code Block
titleПример фильтра divide_after: пропорциональное уменьшение скоростей доступа
collapsetrue
plugins:
  filters:
    divide_after:
      tags:
        - authorize
        - service_status_ok
        - residential_customer
      divide_speed_limits:
        factors:
          '$response.RAD_REPLY.HARD-Day-In-Speed': 8
          '$response.RAD_REPLY.HARD-Day-Out-Speed': 2
          '$response.RAD_REPLY.HARD-Night-In-Speed': 4
          '$response.RAD_REPLY.HARD-Night-Out-Speed': 2

...

Code Block
titleПример фильтра format_after: формирование политики ограничения скорости с расчётом burst-значений
collapsetrue
plugins:
  filters:
    format_after:
      combine_rate_and_burst_values:
        tags: [authorize, individual_customer]
        values:
          InRate: '$response.RAD_REPLY.InRate'
          OutRate: '$response.RAD_REPLY.OutRate'
        destination: '$response.Speed-Limits'
        template: 'InRate=#{$InRate};InBurst=#{($InRate.to_i() / 8 * 900).to_i()};OutRate=#{$OutRate};OutBurst=#{($OutRate.to_i() / 8 * 900).to_i()}'
        delete_values: true

...