Skip to content

Commit

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

if not self.awsSecretId == None and self.awsSecretId.strip():
client = boto3.client('secretsmanager')
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
3 changes: 2 additions & 1 deletion src/init_sql/v1.9.3.sql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ALTER TABLE sql_instance ADD awsSecretId varchar(100) NULL;
ALTER TABLE sql_instance ADD awsSecretId varchar(100) DEFAULT '' COMMENT 'AWS SecretId';
ALTER TABLE sql_instance ADD is_ssl tinyint(1) DEFAULT 0 COMMENT '是否启用SSL';

0 comments on commit ae5ba58

Please sign in to comment.