mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-06-28 07:47:10 +00:00
Merge pull request #10806 from jumpserver/pr@dev@feat_terminal_endpointrule
feat: 系统设置 - 终端设置 - 端点规则: 新增字段is_active控制是否启用
This commit is contained in:
commit
eeba0a4bfc
@ -15,7 +15,7 @@ class Migration(migrations.Migration):
|
|||||||
field=models.CharField(
|
field=models.CharField(
|
||||||
choices=[('koko', 'KoKo'), ('guacamole', 'Guacamole'), ('omnidb', 'OmniDB'), ('xrdp', 'Xrdp'),
|
choices=[('koko', 'KoKo'), ('guacamole', 'Guacamole'), ('omnidb', 'OmniDB'), ('xrdp', 'Xrdp'),
|
||||||
('lion', 'Lion'), ('core', 'Core'), ('celery', 'Celery'), ('magnus', 'Magnus'),
|
('lion', 'Lion'), ('core', 'Core'), ('celery', 'Celery'), ('magnus', 'Magnus'),
|
||||||
('razor', 'Razor'), ('tinker', 'Tinker'), ('video_worker', 'Video Worker')], default='koko',
|
('razor', 'Razor'), ('tinker', 'Tinker'), ('video_worker', 'Video Worker'), ('chen', 'Chen')],
|
||||||
max_length=64, verbose_name='type'),
|
default='koko', max_length=64, verbose_name='type'),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
22
apps/terminal/migrations/0063_auto_20230621_1133.py
Normal file
22
apps/terminal/migrations/0063_auto_20230621_1133.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 3.2.19 on 2023-06-21 10:25
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('terminal', '0062_applet_edition'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='endpointrule',
|
||||||
|
options={'ordering': ('priority', 'is_active', 'name'), 'verbose_name': 'Endpoint rule'},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='endpointrule',
|
||||||
|
name='is_active',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='Is active'),
|
||||||
|
),
|
||||||
|
]
|
@ -98,17 +98,18 @@ class EndpointRule(JMSBaseModel):
|
|||||||
on_delete=models.SET_NULL, verbose_name=_("Endpoint"),
|
on_delete=models.SET_NULL, verbose_name=_("Endpoint"),
|
||||||
)
|
)
|
||||||
comment = models.TextField(default='', blank=True, verbose_name=_('Comment'))
|
comment = models.TextField(default='', blank=True, verbose_name=_('Comment'))
|
||||||
|
is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Endpoint rule')
|
verbose_name = _('Endpoint rule')
|
||||||
ordering = ('priority', 'name')
|
ordering = ('priority', 'is_active', 'name')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.name}({self.priority})'
|
return f'{self.name}({self.priority})'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def match(cls, target_instance, target_ip, protocol):
|
def match(cls, target_instance, target_ip, protocol):
|
||||||
for endpoint_rule in cls.objects.all().prefetch_related('endpoint'):
|
for endpoint_rule in cls.objects.prefetch_related('endpoint').filter(is_active=True):
|
||||||
if not contains_ip(target_ip, endpoint_rule.ip_group):
|
if not contains_ip(target_ip, endpoint_rule.ip_group):
|
||||||
continue
|
continue
|
||||||
if not endpoint_rule.endpoint:
|
if not endpoint_rule.endpoint:
|
||||||
|
@ -79,7 +79,7 @@ class EndpointRuleSerializer(BulkModelSerializer):
|
|||||||
fields_small = fields_mini + ['ip_group', 'priority']
|
fields_small = fields_mini + ['ip_group', 'priority']
|
||||||
fields_fk = ['endpoint']
|
fields_fk = ['endpoint']
|
||||||
fields = fields_mini + fields_small + fields_fk + [
|
fields = fields_mini + fields_small + fields_fk + [
|
||||||
'comment', 'date_created', 'date_updated', 'created_by'
|
'comment', 'date_created', 'date_updated', 'created_by', 'is_active'
|
||||||
]
|
]
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'priority': {'default': 50}
|
'priority': {'default': 50}
|
||||||
|
Loading…
Reference in New Issue
Block a user