Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.
Комментарий: Published by Scroll Versions from space TMAG and version 7.15
Sv translation
languageru

Внешние системы могут подключаться к Traffic Monitor, отправлять в него события на анализ и получать вердикт в реальном времени через веб-сокет.

Чтобы настроить отправку и получить ответ:

  1. Для открытия веб-сокета отправьте команду в терминале на стороне клиента (на внешней системе), указав действующий IP-адрес сервера Traffic Monitor:


    Блок кода
    languagetext
    wscat -c 'wss://<ip_adress>:9106/xapi/websocket' --no-check

    Значение порта для веб-сокета всегда 9106.
    После выполнения команды убедитесь, что connection_id получен:

    Блок кода
    languagetext
    wscat -c 'wss://<ip_adress>:9106/xapi/websocket' --no-check  
    Connected (press CTRL+C to quit)  
    < {
      "type":"new_connection",
      "data":{"connection_id":"dc7e0f02-554d-44d4-8579-acaf1e1a8ba7"}
      }
    Предупреждение
    titleВажно!

    В ответе могут присутствовать другие типы сообщений "type".

    При открытии нескольких веб-сокетов каждому из них присваивается уникальный connection_id.
    Новый connection_id также присваивается при переподключении к веб-сокету.

  2. Чтобы отправить событие на анализ в Traffic Monitor, в другой вкладке терминала отправьте curl-запрос. Укажите при этом свои данные:

    • В строке 2 – адрес сервера Traffic Monitor. Событие должно быть отправлено на тот же порт, с которым было установлено соединение по веб-сокету.
    • В поле "-H 'X-API-Auth-Token" поменяйте токен на свой. Для этого используйте любой токен сервера из файла /opt/iw/tm5/etc/config/access_control/tokens.list.
    • В "evt_attributes", "name": "capture_ts" укажите любую прошедшую дату (например, сегодня утром). Это будет время получения события в Traffic Monitor.
    • В "evt_attributes" "name": "connection_id" укажите значение, которое пришло в веб-сокет на первом шаге.
    • В последней строке укажите путь к файлу, который нужно прикрепить для анализа.

       Для авторизации в Swagger укажите параметры:

      • authToken (apiKey) – любой токен сервера;
      • version (apiKey) – 1;
      • companyId (apiKey) – IW (обязательно заглавными буквами)

        Блок кода
        languagetext
        curl -k -X 'POST' \
          'https://<ip_adress>:9106/xapi/push/event' \
          -H 'accept: application/json' \
          -H 'X-API-Auth-Token: 7tghcu0jmvwxyg7e7l3l' \
          -H 'X-API-CompanyId: IW' \
          -H 'X-API-Version: 1' \
          -H 'Content-Type: multipart/form-data' \
          -H 'X-Enable-OpenAPI: 1' \
          -F 'event={
          "evt_class": 4,
          "evt_service": "cloud_storage",
          "evt_attributes": [
            {
              "name": "capture_ts",
              "value": "2025-07-15T07:07:07+03:00"
            },
            {
              "name": "capture_server_ip",
              "value": "127.0.0.1"
            },
            {
              "name": "capture_server_fqdn",
              "value": "localhost"
            },
            {
              "name": "connection_id",
              "value": "4e77e6e5-0ae6-4d07-a660-174e5be42492"
            }
          ],
          "evt_senders": [
            {
              "identity_id": 1,
              "identity_type": 0,
              "identity_contacts": [
                {
                  "name": "auth",
                  "value": "user_name@iw"
                }
              ]
            },
            {
              "identity_id": 2,
              "identity_type": 1,
              "identity_contacts": [
                {
                  "name": "dnshostname",
                  "value": "localhost.computer.domain"
                }
              ]
            }
          ],
          "evt_receivers": [
            {
              "identity_id": 3,
              "identity_type": 3,
              "identity_contacts": []
            }
          ],
          "evt_data": [
            {
              "data_id": 1,
              "data_attributes": [
                {
                  "name": "filename",
                  "value": "sample.pdf"
                },
                {
                  "name": "destination_file_path",
                  "value": "goodledrive.com/user/folder/"
                }
              ]
            }
          ],
          "evt_destination": {
            "identity_id": 4,
            "identity_type": 3,
            "identity_contacts": [],
            "identity_attributes": [
              {
                "name": "name",
                "value": "googledrive.com"
              }
            ]
          }
        }' \
          -F 'files[]="/home/work/scripts/sample.pdf";filename=1'
  3. После отправки и обработки события в Traffic Monitor в веб-сокет придет ответ, содержащий document_id и verdict:

    Блок кода
    languagetext
    wscat -c 'wss://<ip_adress>:9106/xapi/websocket' --no-check
     Connected (press CTRL+C to quit)
    < {
      "type":"new_connection",
      "data":{"connection_id":"dc7e0f02-554d-44d4-8579-acaf1e1a8ba7"}
      }  
    < {
      "type":"verdict",
      "data":{"document_id":"b509fe5d-bd6a-4647-aea8-0684fde1b369", "verdict":"Allowed"}
      }
    Предупреждение
    titleВажно!

    В ответе могут присутствовать другие типы сообщений "type".

    Вердикты событий с соответствующим connection_id будут приходить именно в веб-сокет с указанным connection_id и только до тех пор, пока этот веб-сокет открыт.

Информация
titleПримечание:

Вы также можете использовать HAProxy для отправки событий и получения вердиктов в Traffic Monitor. См. статью в Базе знаний Использование HAProxy для отправки событий и получения вердиктов по WebSocket в Traffic Monitor.

Sv translation
languageen

External systems can connect to Traffic Monitor, send events for analysis to it, and get a real-time verdict via a web socket. 

To set up sending events and getting responses:

  1. To open a web socket, send a command in the terminal on the client side (on an external system), specifying the valid IP address of the Traffic Monitor server:

    Блок кода
    languagetext
    wscat -c 'wss://<ip_adress>:9106/xapi/websocket' --no-check

    The port value for a web socket is always 9106.
    Once the command is executed, make sure you receive the connection_id parameter:

    Блок кода
    languagetext
    wscat -c 'wss://<ip_adress>:9106/xapi/websocket' --no-check  
    Connected (press CTRL+C to quit)  
    < {
      "type":"new_connection",
      "data":{"connection_id":"dc7e0f02-554d-44d4-8579-acaf1e1a8ba7"}
      }
    Предупреждение
    titleWarning!

    There may be other types of messages "type" in the response.

    When opening multiple web sockets, each of them is assigned a unique connection_id.

    A new connection_id is also assigned when you reconnect to a web socket.

  2. In order to send an event to Traffic Monitor for analysis, open another terminal tab and send a CURL request. Make sure you specify your data:

    • In line 2, the Traffic Monitor server address. An event must be sent to the same port that the web socket connection was established with.

    • In "-H 'X-API-Auth-Token" field, replace the sample token with any server token from the /opt/iw/tm5/etc/config/access_control/tokens.list file.
    • In "evt_attributes", "name": "capture_ts" area, specify any past date (for example, this morning). This will be the time of receiving the event in Traffic Monitor.
    • In "evt_attributes" "name": "connection_id" area, specify the value you received in the web socket at step 1.
    • In the last line, specify the path to the file that needs to be attached for analysis.

      Specify the parameters for Swagger authorization:

      • authToken (apiKey) – any server token
      • version (apiKey) – 1
      • companyId (apiKey) – IW (all capitals)

        Блок кода
        languagetext
        curl -k -X 'POST' \
          'https://<ip_adress>:9106/xapi/push/event' \
          -H 'accept: application/json' \
          -H 'X-API-Auth-Token: 7tghcu0jmvwxyg7e7l3l' \
          -H 'X-API-CompanyId: IW' \
          -H 'X-API-Version: 1' \
          -H 'Content-Type: multipart/form-data' \
          -H 'X-Enable-OpenAPI: 1' \
          -F 'event={
          "evt_class": 4,
          "evt_service": "cloud_storage",
          "evt_attributes": [
            {
              "name": "capture_ts",
              "value": "2025-07-15T07:07:07+03:00"
            },
            {
              "name": "capture_server_ip",
              "value": "127.0.0.1"
            },
            {
              "name": "capture_server_fqdn",
              "value": "localhost"
            },
            {
              "name": "connection_id",
              "value": "4e77e6e5-0ae6-4d07-a660-174e5be42492"
            }
          ],
          "evt_senders": [
            {
              "identity_id": 1,
              "identity_type": 0,
              "identity_contacts": [
                {
                  "name": "auth",
                  "value": "user_name@iw"
                }
              ]
            },
            {
              "identity_id": 2,
              "identity_type": 1,
              "identity_contacts": [
                {
                  "name": "dnshostname",
                  "value": "localhost.computer.domain"
                }
              ]
            }
          ],
          "evt_receivers": [
            {
              "identity_id": 3,
              "identity_type": 3,
              "identity_contacts": []
            }
          ],
          "evt_data": [
            {
              "data_id": 1,
              "data_attributes": [
                {
                  "name": "filename",
                  "value": "sample.pdf"
                },
                {
                  "name": "destination_file_path",
                  "value": "goodledrive.com/user/folder/"
                }
              ]
            }
          ],
          "evt_destination": {
            "identity_id": 4,
            "identity_type": 3,
            "identity_contacts": [],
            "identity_attributes": [
              {
                "name": "name",
                "value": "googledrive.com"
              }
            ]
          }
        }' \
          -F 'files[]="/home/work/scripts/sample.pdf";filename=1'
  3. Once the event has been sent to Traffic Monitor and processed, the web socket will receive a response containing document_id and verdict:

    Блок кода
    languagetext
    wscat -c 'wss://<ip_adress>:9106/xapi/websocket' --no-check
     Connected (press CTRL+C to quit)
    < {
      "type":"new_connection",
      "data":{"connection_id":"dc7e0f02-554d-44d4-8579-acaf1e1a8ba7"}
      }  
    < {
      "type":"verdict",
      "data":{"document_id":"b509fe5d-bd6a-4647-aea8-0684fde1b369", "verdict":"Allowed"}
      }
    Предупреждение
    titleWarning!

    There may be other types of messages "type" in the response.

    Event verdicts with the corresponding connection_id will arrive precisely at the web socket with the specified connection_id and only as long as this web socket is open.

Информация
titleNote: