perf: support redis url with `rediss` protocol #127

This commit is contained in:
Lykin 2024-01-26 12:56:33 +08:00
parent 581a1b79ca
commit f94134faa0
2 changed files with 26 additions and 13 deletions

View File

@ -528,6 +528,10 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
if len(addrPart) > 1 { if len(addrPart) > 1 {
port, _ = strconv.Atoi(addrPart[1]) port, _ = strconv.Atoi(addrPart[1])
} }
var sslServerName string
if urlOpt.TLSConfig != nil {
sslServerName = urlOpt.TLSConfig.ServerName
}
resp.Success = true resp.Success = true
resp.Data = struct { resp.Data = struct {
Addr string `json:"addr"` Addr string `json:"addr"`
@ -536,6 +540,7 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
Password string `json:"password"` Password string `json:"password"`
ConnTimeout int64 `json:"connTimeout"` ConnTimeout int64 `json:"connTimeout"`
ExecTimeout int64 `json:"execTimeout"` ExecTimeout int64 `json:"execTimeout"`
SSLServerName string `json:"sslServerName,omitempty"`
}{ }{
Addr: addr, Addr: addr,
Port: port, Port: port,
@ -543,6 +548,7 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
Password: urlOpt.Password, Password: urlOpt.Password,
ConnTimeout: int64(urlOpt.DialTimeout.Seconds()), ConnTimeout: int64(urlOpt.DialTimeout.Seconds()),
ExecTimeout: int64(urlOpt.ReadTimeout.Seconds()), ExecTimeout: int64(urlOpt.ReadTimeout.Seconds()),
SSLServerName: sslServerName,
} }
return return
} }

View File

@ -270,7 +270,7 @@ const onClose = () => {
const pasteFromClipboard = async () => { const pasteFromClipboard = async () => {
// url example: // url example:
// redis://user:password@localhost:6789/3?dial_timeout=3&db=1&read_timeout=6s&max_retries=2 // rediss://user:password@localhost:6789/3?dial_timeout=3&db=1&read_timeout=6s&max_retries=2
let opt = {} let opt = {}
try { try {
opt = await connectionStore.parseUrlFromClipboard() opt = await connectionStore.parseUrlFromClipboard()
@ -288,6 +288,13 @@ const pasteFromClipboard = async () => {
if (opt.execTimeout > 0) { if (opt.execTimeout > 0) {
generalForm.value.execTimeout = opt.execTimeout generalForm.value.execTimeout = opt.execTimeout
} }
const { sslServerName = null } = opt
if (sslServerName != null) {
generalForm.value.ssl.enable = true
if (!isEmpty(sslServerName)) {
generalForm.value.ssl.sni = sslServerName
}
}
$message.success(i18n.t('dialogue.connection.parse_pass', { url: opt.url })) $message.success(i18n.t('dialogue.connection.parse_pass', { url: opt.url }))
} }
</script> </script>