Merge pull request #9713 from jumpserver/pr@dev@perf_agent_check

perf: 修改 agent 判断
pull/9715/head
老广 2023-02-23 15:27:12 +08:00 committed by GitHub
commit 68ea8ef1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -85,13 +85,12 @@ def bulk_create_with_signal(cls: models.Model, items, **kwargs):
def get_request_os(request): def get_request_os(request):
"""获取请求的操作系统""" """获取请求的操作系统"""
agent = request.META.get('HTTP_USER_AGENT', '').lower() agent = request.META.get('HTTP_USER_AGENT', '').lower()
if agent is None: if 'windows' in agent:
return 'unknown'
if 'windows' in agent.lower():
return 'windows' return 'windows'
if 'mac' in agent.lower(): elif 'mac' in agent:
return 'mac' return 'mac'
if 'linux' in agent.lower(): elif 'linux' in agent:
return 'linux' return 'linux'
return 'unknown' else:
return 'unknown'