perf: support unix-socket via url string #142

This commit is contained in:
Lykin 2024-02-18 14:27:21 +08:00
parent a2331675d7
commit 09264134ec
2 changed files with 17 additions and 5 deletions

View File

@ -536,11 +536,19 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
return return
} }
addrPart := strings.Split(urlOpt.Addr, ":") var network, addr string
addr := addrPart[0] var port int
port := 6379 if urlOpt.Network == "unix" {
if len(addrPart) > 1 { network = urlOpt.Network
port, _ = strconv.Atoi(addrPart[1]) addr = urlOpt.Addr
} else {
network = "tcp"
addrPart := strings.Split(urlOpt.Addr, ":")
addr = addrPart[0]
port = 6379
if len(addrPart) > 1 {
port, _ = strconv.Atoi(addrPart[1])
}
} }
var sslServerName string var sslServerName string
if urlOpt.TLSConfig != nil { if urlOpt.TLSConfig != nil {
@ -548,6 +556,8 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
} }
resp.Success = true resp.Success = true
resp.Data = struct { resp.Data = struct {
Network string `json:"network"`
Sock string `json:"sock"`
Addr string `json:"addr"` Addr string `json:"addr"`
Port int `json:"port"` Port int `json:"port"`
Username string `json:"username"` Username string `json:"username"`
@ -556,6 +566,7 @@ func (c *connectionService) ParseConnectURL(url string) (resp types.JSResp) {
ExecTimeout int64 `json:"execTimeout"` ExecTimeout int64 `json:"execTimeout"`
SSLServerName string `json:"sslServerName,omitempty"` SSLServerName string `json:"sslServerName,omitempty"`
}{ }{
Network: network,
Addr: addr, Addr: addr,
Port: port, Port: port,
Username: urlOpt.Username, Username: urlOpt.Username,

View File

@ -278,6 +278,7 @@ const pasteFromClipboard = async () => {
$message.error(i18n.t('dialogue.connection.parse_fail', { reason: e.message })) $message.error(i18n.t('dialogue.connection.parse_fail', { reason: e.message }))
return return
} }
generalForm.value.network = opt.network || 'tcp'
generalForm.value.name = generalForm.value.addr = opt.addr generalForm.value.name = generalForm.value.addr = opt.addr
generalForm.value.port = opt.port generalForm.value.port = opt.port
generalForm.value.username = opt.username generalForm.value.username = opt.username