mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-15 16:42:34 +00:00
Compare commits
4 Commits
refactor_p
...
v2.13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
669f659843 | ||
|
|
a718862b37 | ||
|
|
52898e951e | ||
|
|
0f03fd1ee1 |
@@ -71,7 +71,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
|
|||||||
"""
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Asset
|
model = Asset
|
||||||
fields_mini = ['id', 'hostname', 'ip']
|
fields_mini = ['id', 'hostname', 'ip', 'platform', 'protocols']
|
||||||
fields_small = fields_mini + [
|
fields_small = fields_mini + [
|
||||||
'protocol', 'port', 'protocols', 'is_active', 'public_ip',
|
'protocol', 'port', 'protocols', 'is_active', 'public_ip',
|
||||||
'number', 'vendor', 'model', 'sn', 'cpu_model', 'cpu_count',
|
'number', 'vendor', 'model', 'sn', 'cpu_model', 'cpu_count',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import threading
|
import threading
|
||||||
import json
|
import json
|
||||||
|
from redis.exceptions import ConnectionError
|
||||||
from channels.generic.websocket import JsonWebsocketConsumer
|
from channels.generic.websocket import JsonWebsocketConsumer
|
||||||
|
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
@@ -12,13 +12,14 @@ logger = get_logger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class SiteMsgWebsocket(JsonWebsocketConsumer):
|
class SiteMsgWebsocket(JsonWebsocketConsumer):
|
||||||
disconnected = False
|
|
||||||
refresh_every_seconds = 10
|
refresh_every_seconds = 10
|
||||||
|
chan = None
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
user = self.scope["user"]
|
user = self.scope["user"]
|
||||||
if user.is_authenticated:
|
if user.is_authenticated:
|
||||||
self.accept()
|
self.accept()
|
||||||
|
self.chan = new_site_msg_chan.subscribe()
|
||||||
|
|
||||||
thread = threading.Thread(target=self.unread_site_msg_count)
|
thread = threading.Thread(target=self.unread_site_msg_count)
|
||||||
thread.start()
|
thread.start()
|
||||||
@@ -48,9 +49,8 @@ class SiteMsgWebsocket(JsonWebsocketConsumer):
|
|||||||
user_id = str(self.scope["user"].id)
|
user_id = str(self.scope["user"].id)
|
||||||
self.send_unread_msg_count()
|
self.send_unread_msg_count()
|
||||||
|
|
||||||
while not self.disconnected:
|
try:
|
||||||
subscribe = new_site_msg_chan.subscribe()
|
for message in self.chan.listen():
|
||||||
for message in subscribe.listen():
|
|
||||||
if message['type'] != 'message':
|
if message['type'] != 'message':
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@@ -64,7 +64,10 @@ class SiteMsgWebsocket(JsonWebsocketConsumer):
|
|||||||
self.send_unread_msg_count()
|
self.send_unread_msg_count()
|
||||||
except json.JSONDecoder as e:
|
except json.JSONDecoder as e:
|
||||||
logger.debug('Decode json error: ', e)
|
logger.debug('Decode json error: ', e)
|
||||||
|
except ConnectionError:
|
||||||
|
logger.debug('Redis chan closed')
|
||||||
|
|
||||||
def disconnect(self, close_code):
|
def disconnect(self, close_code):
|
||||||
self.disconnected = True
|
if self.chan is not None:
|
||||||
|
self.chan.close()
|
||||||
self.close()
|
self.close()
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class UserSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer):
|
|||||||
def validate_password(self, password):
|
def validate_password(self, password):
|
||||||
from ..utils import check_password_rules
|
from ..utils import check_password_rules
|
||||||
password_strategy = self.initial_data.get('password_strategy')
|
password_strategy = self.initial_data.get('password_strategy')
|
||||||
if self.instance is None and password_strategy != self.PasswordStrategy.custom:
|
if self.instance is None and password_strategy != PasswordStrategy.custom:
|
||||||
# 创建用户,使用邮件设置密码
|
# 创建用户,使用邮件设置密码
|
||||||
return
|
return
|
||||||
if self.instance and not password:
|
if self.instance and not password:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ "$(ps axu | grep 'celery' | grep -v 'grep' | grep -cv 'defunct')" == "5" ]];then
|
if [[ "$(ps axu | grep 'celery' | grep -v 'grep' | grep -cv 'defunct')" -gt "2" ]];then
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user