mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-07 10:20:57 +00:00
feat: Cloud 支持局域网 IP 扫描 (#8589)
* feat: Cloud 支持局域网 IP 扫描 * feat: Cloud 支持局域网 IP 扫描 Co-authored-by: Jiangjie.Bai <bugatti_it@163.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
import re
|
||||
import socket
|
||||
from django.templatetags.static import static
|
||||
from collections import OrderedDict
|
||||
from itertools import chain
|
||||
@@ -368,8 +369,23 @@ def group_by_count(it, count):
|
||||
return [it[i:i+count] for i in range(0, len(it), count)]
|
||||
|
||||
|
||||
def test_ip_connectivity(host, port, timeout=3):
|
||||
"""
|
||||
timeout: seconds
|
||||
"""
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.settimeout(timeout)
|
||||
result = sock.connect_ex((host, int(port)))
|
||||
sock.close()
|
||||
if result == 0:
|
||||
connectivity = True
|
||||
else:
|
||||
connectivity = False
|
||||
return connectivity
|
||||
|
||||
|
||||
def static_or_direct(logo_path):
|
||||
if logo_path.startswith('img/'):
|
||||
return static(logo_path)
|
||||
else:
|
||||
return logo_path
|
||||
return logo_path
|
Reference in New Issue
Block a user