2022-09-18 16:07:59 +00:00
|
|
|
from django.db import models
|
2022-12-14 09:19:35 +00:00
|
|
|
|
2022-09-18 16:07:59 +00:00
|
|
|
from common.db.models import ChoicesMixin
|
|
|
|
|
|
|
|
__all__ = ['Protocol']
|
|
|
|
|
|
|
|
|
|
|
|
class Protocol(ChoicesMixin, models.TextChoices):
|
|
|
|
ssh = 'ssh', 'SSH'
|
|
|
|
rdp = 'rdp', 'RDP'
|
|
|
|
telnet = 'telnet', 'Telnet'
|
|
|
|
vnc = 'vnc', 'VNC'
|
|
|
|
|
|
|
|
mysql = 'mysql', 'MySQL'
|
|
|
|
mariadb = 'mariadb', 'MariaDB'
|
|
|
|
oracle = 'oracle', 'Oracle'
|
|
|
|
postgresql = 'postgresql', 'PostgreSQL'
|
|
|
|
sqlserver = 'sqlserver', 'SQLServer'
|
2022-12-06 09:13:37 +00:00
|
|
|
clickhouse = 'clickhouse', 'ClickHouse'
|
2022-09-18 16:07:59 +00:00
|
|
|
redis = 'redis', 'Redis'
|
|
|
|
mongodb = 'mongodb', 'MongoDB'
|
|
|
|
|
|
|
|
k8s = 'k8s', 'K8S'
|
|
|
|
http = 'http', 'HTTP'
|
2022-09-23 10:59:19 +00:00
|
|
|
_settings = None
|
2022-09-18 16:07:59 +00:00
|
|
|
|
|
|
|
@classmethod
|
2022-09-21 03:17:14 +00:00
|
|
|
def device_protocols(cls):
|
2022-09-20 13:19:05 +00:00
|
|
|
return {
|
|
|
|
cls.ssh: {
|
|
|
|
'port': 22,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password', 'ssh_key'],
|
2022-09-20 13:19:05 +00:00
|
|
|
'setting': {
|
|
|
|
'sftp_enabled': True,
|
|
|
|
'sftp_home': '/tmp',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
cls.rdp: {
|
|
|
|
'port': 3389,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
'setting': {
|
|
|
|
'console': True,
|
|
|
|
'security': 'any',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
cls.vnc: {
|
|
|
|
'port': 5900,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.telnet: {
|
|
|
|
'port': 23,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
@classmethod
|
2022-09-21 03:17:14 +00:00
|
|
|
def database_protocols(cls):
|
2022-09-20 13:19:05 +00:00
|
|
|
return {
|
|
|
|
cls.mysql: {
|
|
|
|
'port': 3306,
|
2023-01-29 09:40:15 +00:00
|
|
|
'setting': {},
|
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.mariadb: {
|
|
|
|
'port': 3306,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.postgresql: {
|
|
|
|
'port': 5432,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.oracle: {
|
|
|
|
'port': 1521,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.sqlserver: {
|
|
|
|
'port': 1433,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-12-06 09:13:37 +00:00
|
|
|
},
|
|
|
|
cls.clickhouse: {
|
|
|
|
'port': 9000,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-12-06 09:13:37 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.mongodb: {
|
|
|
|
'port': 27017,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.redis: {
|
|
|
|
'port': 6379,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2023-02-13 11:42:42 +00:00
|
|
|
'setting': {
|
|
|
|
'auth_username': True,
|
|
|
|
}
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
}
|
2022-09-18 16:07:59 +00:00
|
|
|
|
|
|
|
@classmethod
|
2022-09-21 03:17:14 +00:00
|
|
|
def cloud_protocols(cls):
|
2022-09-20 13:19:05 +00:00
|
|
|
return {
|
|
|
|
cls.k8s: {
|
|
|
|
'port': 443,
|
2023-01-29 09:40:15 +00:00
|
|
|
'required': True,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['token'],
|
2022-09-20 13:19:05 +00:00
|
|
|
},
|
|
|
|
cls.http: {
|
|
|
|
'port': 80,
|
2022-09-21 03:17:14 +00:00
|
|
|
'secret_types': ['password'],
|
2022-09-20 13:19:05 +00:00
|
|
|
'setting': {
|
2022-12-14 09:19:35 +00:00
|
|
|
'username_selector': 'name=username',
|
|
|
|
'password_selector': 'name=password',
|
|
|
|
'submit_selector': 'id=longin_button',
|
2022-09-20 13:19:05 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def settings(cls):
|
|
|
|
return {
|
2022-12-14 09:19:35 +00:00
|
|
|
**cls.device_protocols(),
|
|
|
|
**cls.database_protocols(),
|
|
|
|
**cls.cloud_protocols()
|
2022-09-18 16:07:59 +00:00
|
|
|
}
|