MCPcopy Index your code
hub / github.com/WireGuard/wireguard-windows / onSaveButtonClicked

Method onSaveButtonClicked

ui/editdialog.go:311–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

309}
310
311func (dlg *EditDialog) onSaveButtonClicked() {
312 newName := dlg.nameEdit.Text()
313 if newName == "" {
314 showWarningCustom(dlg, l18n.Sprintf("Invalid name"), l18n.Sprintf("A name is required."))
315 return
316 }
317 if !conf.TunnelNameIsValid(newName) {
318 showWarningCustom(dlg, l18n.Sprintf("Invalid name"), l18n.Sprintf("Tunnel name ‘%s’ is invalid.", newName))
319 return
320 }
321 newNameLower := strings.ToLower(newName)
322
323 if newNameLower != strings.ToLower(dlg.config.Name) {
324 existingTunnelList, err := manager.IPCClientTunnels()
325 if err != nil {
326 showWarningCustom(dlg, l18n.Sprintf("Unable to list existing tunnels"), err.Error())
327 return
328 }
329 for _, tunnel := range existingTunnelList {
330 if strings.ToLower(tunnel.Name) == newNameLower {
331 showWarningCustom(dlg, l18n.Sprintf("Tunnel already exists"), l18n.Sprintf("Another tunnel already exists with the name ‘%s’.", newName))
332 return
333 }
334 }
335 }
336
337 cfg, err := conf.FromWgQuick(dlg.syntaxEdit.Text(), newName)
338 if err != nil {
339 showErrorCustom(dlg, l18n.Sprintf("Unable to create new configuration"), err.Error())
340 return
341 }
342
343 dlg.config = *cfg
344 dlg.Accept()
345}

Callers

nothing calls this directly

Calls 8

SprintfFunction · 0.92
TunnelNameIsValidFunction · 0.92
IPCClientTunnelsFunction · 0.92
FromWgQuickFunction · 0.92
showWarningCustomFunction · 0.85
showErrorCustomFunction · 0.85
TextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected