Skip to content

Commit

Permalink
add ssl conn support to redis (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobfantansy authored Jul 17, 2023
1 parent cdbd12e commit cedc1f3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions sql/engines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, instance=None):
self.password = instance.password
self.db_name = instance.db_name
self.mode = instance.mode
self.is_ssl = instance.is_ssl

# 判断如果配置了隧道则连接隧道,只测试了MySQL
if self.instance.tunnel:
Expand Down
2 changes: 2 additions & 0 deletions sql/engines/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def get_connection(self, db_name=None):
encoding_errors="ignore",
decode_responses=True,
socket_connect_timeout=10,
ssl=self.is_ssl,
)
else:
return redis.Redis(
Expand All @@ -43,6 +44,7 @@ def get_connection(self, db_name=None):
encoding_errors="ignore",
decode_responses=True,
socket_connect_timeout=10,
ssl=self.is_ssl,
)

@property
Expand Down
1 change: 1 addition & 0 deletions sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class Instance(models.Model):
password = fields.EncryptedCharField(
verbose_name="密码", max_length=300, default="", blank=True
)
is_ssl = models.BooleanField("是否启用SSL", default=False)
db_name = models.CharField("数据库", max_length=64, default="", blank=True)
charset = models.CharField("字符集", max_length=20, default="", blank=True)
service_name = models.CharField(
Expand Down
1 change: 1 addition & 0 deletions src/init_sql/v1.9.3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE sql_instance ADD is_ssl tinyint(1) DEFAULT 0 COMMENT '是否启用SSL';

0 comments on commit cedc1f3

Please sign in to comment.