GonetsDocs/Documentation/Tech-docs/api/models/ufw.md
2025-10-14 16:19:35 +05:00

195 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# models.ufw
### *class* models.ufw.Action(\*values)
Bases: `str`, `Enum`
Enum для действий UFW.
#### ALLOW
Разрешить трафик
#### DENY
Запретить трафик без уведомления
#### REJECT
Запретить трафик с уведомлением отправителю
#### ALLOW *= 'allow'*
#### DENY *= 'deny'*
#### REJECT *= 'reject'*
### *class* models.ufw.Direction(\*values)
Bases: `str`, `Enum`
Enum для направления трафика UFW.
#### IN
Входящий трафик
#### OUT
Исходящий трафик
#### IN *= 'in'*
#### OUT *= 'out'*
### *class* models.ufw.Protocol(\*values)
Bases: `str`, `Enum`
Enum для сетевых протоколов UFW.
#### BOTH *= 'both'*
#### TCP *= 'tcp'*
#### UDP *= 'udp'*
#### *property* protocols *: List[str]*
Возвращает список протоколов для использования в команде UFW.
### *class* models.ufw.UFWRule(, action: Action, direction: Direction, from_ip: str, to_ip: str, port: int | str, protocol: Protocol, comment: str | None = None)
Bases: `BaseModel`
Модель правила UFW
#### action *: Action*
#### comment *: str | None*
#### direction *: Direction*
#### from_ip *: str*
#### *classmethod* from_ufw_output(line: str) → UFWRule
Создает экземпляр UFWRule из строки вывода команды ‘ufw status numbered’.
* **Parameters:**
**line** – Строка вывода UFW (например, “[1] 80/tcp ALLOW IN 192.168.1.0/24 # Web Server”)
* **Returns:**
Новый экземпляр правила
* **Return type:**
UFWRule
#### model_config *: ClassVar[ConfigDict]* *= {}*
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
#### port *: int | str*
#### protocol *: Protocol*
#### to_ip *: str*
#### to_ufw_command() → str
Преобразует правило в команду UFW.
#### *classmethod* validate_action(v)
Приводит значение action к нижнему регистру перед валидацией
#### *classmethod* validate_ip(v)
Проверяет корректность IP адреса
#### *classmethod* validate_ip_version_compatibility(v, values)
Проверяет совместимость версий IP адресов
#### *classmethod* validate_port(v)
Проверяет корректность порта или диапазона портов.
* **Parameters:**
**v** – Порт (число) или диапазон портов (строка вида “3000:3999”)
* **Returns:**
Валидированное значение порта
* **Return type:**
Union[int, str]
* **Raises:**
**ValueError** – Если порт или диапазон портов некорректен
#### *classmethod* validate_protocol(v)
Приводит значение protocol к нижнему регистру перед валидацией
### *class* models.ufw.UFWRulesResponse(\*, enabled: bool, rules: ~typing.List[~models.ufw.UFWRule] = <factory>)
Bases: `BaseModel`
Модель для представления списка правил UFW.
#### enabled
Включен ли UFW
* **Type:**
bool
#### rules
Список правил UFW
* **Type:**
List[models.ufw.UFWRule]
#### total_rules
Общее количество правил
#### enabled *: bool*
#### model_config *: ClassVar[ConfigDict]* *= {}*
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
#### rules *: List[UFWRule]*
#### *property* total_rules *: int*
Возвращает общее количество правил.
### *class* models.ufw.UFWStatus(, enabled: bool, message: str)
Bases: `BaseModel`
Модель для представления статуса UFW.
#### enabled
Включен ли UFW
* **Type:**
bool
#### message
Сообщение о статусе
* **Type:**
str
#### last_checked
Время последней проверки статуса
#### enabled *: bool*
#### message *: str*
#### model_config *: ClassVar[ConfigDict]* *= {}*
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].