관리-도구
편집 파일: json.cpython-311.opt-1.pyc
� IMg� � � � d Z ddlZddlmZmZmZmZ ddlmZ ddl m Z defd�Z G d� d ej � � Z G d � de� � ZdS )z6JSON encoders to help with sending messages to server.� N)�IPv4Address�IPv4Network�IPv6Address�IPv6Network)� model_to_dict)�Model�returnc �p � t | j � � st | j � � S t | � � S )zn IPv4Network('192.168.1.1/32') -> '192.168.1.1' IPv4Network('192.168.1.0/24') -> '192.168.1.0/24' )�int�hostmask�str�network_address)�nets �O/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/json.py�ip_net_to_stringr s2 � � �s�|��� (��3�&�'�'�'��s�8�8�O� c � � e Zd Zd� ZdS )� IPEncoderc �� � t |t t f� � rt |� � S t |t t f� � rt |� � S t j � | |� � S �N) � isinstancer r r r r r �json�JSONEncoder�default)�self�objs r r zIPEncoder.default sb � ��c�K��5�6�6� )�#�C�(�(�(��c�K��5�6�6� ��s�8�8�O���'�'��c�2�2�2r N)�__name__� __module__�__qualname__r � r r r r s# � � � � � �3� 3� 3� 3� 3r r c � � � e Zd Z� fd�Z� xZS )�ServerJSONEncoderc � �� t |t � � rt |� � S t � � � |� � S r )r r r �superr )r r � __class__s �r r zServerJSONEncoder.default s9 �� ��c�5�!�!� &� ��%�%�%��w�w���s�#�#�#r )r r r r � __classcell__)r% s @r r"