mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-07 02:10:23 +00:00
feat: JumpServer支持部署在使用了ssl的redis上
This commit is contained in:
@@ -1,23 +1,29 @@
|
||||
import json
|
||||
import threading
|
||||
|
||||
import redis
|
||||
from redis import Redis
|
||||
from django.conf import settings
|
||||
|
||||
from jumpserver.const import CONFIG
|
||||
from common.http import is_true
|
||||
from common.db.utils import safe_db_connection
|
||||
from common.utils import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def get_redis_client(db):
|
||||
rc = redis.StrictRedis(
|
||||
host=settings.REDIS_HOST,
|
||||
port=settings.REDIS_PORT,
|
||||
password=settings.REDIS_PASSWORD,
|
||||
db=db
|
||||
)
|
||||
return rc
|
||||
def get_redis_client(db=0):
|
||||
params = {
|
||||
'host': CONFIG.REDIS_HOST,
|
||||
'port': CONFIG.REDIS_PORT,
|
||||
'password': CONFIG.REDIS_PASSWORD,
|
||||
'db': db,
|
||||
"ssl": is_true(CONFIG.REDIS_USE_SSL),
|
||||
'ssl_keyfile': getattr(settings, 'REDIS_SSL_KEYFILE'),
|
||||
'ssl_certfile': getattr(settings, 'REDIS_SSL_CERTFILE'),
|
||||
'ssl_ca_certs': getattr(settings, 'REDIS_SSL_CA_CERTS'),
|
||||
}
|
||||
return Redis(**params)
|
||||
|
||||
|
||||
class Subscription:
|
||||
@@ -99,5 +105,3 @@ class RedisPubSub:
|
||||
data_json = json.dumps(data)
|
||||
self.redis.publish(self.ch, data_json)
|
||||
return True
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user