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

View File

@ -270,7 +270,7 @@ const onClose = () => {
const pasteFromClipboard = async () => {
// 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 = {}
try {
opt = await connectionStore.parseUrlFromClipboard()
@ -288,6 +288,13 @@ const pasteFromClipboard = async () => {
if (opt.execTimeout > 0) {
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 }))
}
</script>