diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-12-09 17:53:59 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-12-09 23:13:56 +0100 |
commit | 182247f5c830f93bfdb2a843a0ce3d394008c6d0 (patch) | |
tree | a2e3c0356c6c5ff2fcb8b572654d39e4735c4850 /ui | |
parent | build: update to go 1.17.4 and drop upstreamed patches (diff) | |
download | wireguard-windows-182247f5c830f93bfdb2a843a0ce3d394008c6d0.tar.xz wireguard-windows-182247f5c830f93bfdb2a843a0ce3d394008c6d0.zip |
global: apply gofumpt
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | ui/aboutdialog.go | 6 | ||||
-rw-r--r-- | ui/confview.go | 2 | ||||
-rw-r--r-- | ui/filesave.go | 2 | ||||
-rw-r--r-- | ui/listview.go | 2 | ||||
-rw-r--r-- | ui/managewindow.go | 2 | ||||
-rw-r--r-- | ui/raise.go | 2 | ||||
-rw-r--r-- | ui/syntax/highlighter.go | 8 | ||||
-rw-r--r-- | ui/syntax/syntaxedit.go | 32 | ||||
-rw-r--r-- | ui/tray.go | 2 | ||||
-rw-r--r-- | ui/tunnelspage.go | 4 | ||||
-rw-r--r-- | ui/ui.go | 10 |
11 files changed, 37 insertions, 35 deletions
diff --git a/ui/aboutdialog.go b/ui/aboutdialog.go index 4d7cf7f1..feee2efc 100644 --- a/ui/aboutdialog.go +++ b/ui/aboutdialog.go @@ -18,8 +18,10 @@ import ( "golang.zx2c4.com/wireguard/windows/version" ) -var easterEggIndex = -1 -var showingAboutDialog *walk.Dialog +var ( + easterEggIndex = -1 + showingAboutDialog *walk.Dialog +) func onAbout(owner walk.Form) { showError(runAboutDialog(owner), owner) diff --git a/ui/confview.go b/ui/confview.go index 3d16f38f..b2bcb126 100644 --- a/ui/confview.go +++ b/ui/confview.go @@ -605,7 +605,7 @@ func (cv *ConfView) onToggleActiveClicked() { }() } -func (cv *ConfView) onTunnelChanged(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) { +func (cv *ConfView) onTunnelChanged(tunnel *manager.Tunnel, state, globalState manager.TunnelState, err error) { cv.Synchronize(func() { cv.interfaze.toggleActive.updateGlobal(globalState) if cv.tunnel != nil && cv.tunnel.Name == tunnel.Name { diff --git a/ui/filesave.go b/ui/filesave.go index 8cedec27..63f50dd5 100644 --- a/ui/filesave.go +++ b/ui/filesave.go @@ -24,7 +24,7 @@ func writeFileWithOverwriteHandling(owner walk.Form, filePath string, write func return true } - file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0600) + file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0o600) if err != nil { if os.IsExist(err) { if walk.DlgCmdNo == walk.MsgBox(owner, l18n.Sprintf("Writing file failed"), l18n.Sprintf(`File ā%sā already exists. diff --git a/ui/listview.go b/ui/listview.go index 13608b4e..428d8330 100644 --- a/ui/listview.go +++ b/ui/listview.go @@ -181,7 +181,7 @@ func (tv *ListView) StyleCell(style *walk.CellStyle) { } } -func (tv *ListView) onTunnelChange(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) { +func (tv *ListView) onTunnelChange(tunnel *manager.Tunnel, state, globalState manager.TunnelState, err error) { tv.Synchronize(func() { idx := -1 for i := range tv.model.tunnels { diff --git a/ui/managewindow.go b/ui/managewindow.go index 15e93e9c..d02e223a 100644 --- a/ui/managewindow.go +++ b/ui/managewindow.go @@ -161,7 +161,7 @@ func (mtw *ManageTunnelsWindow) updateProgressIndicator(globalState manager.Tunn } } -func (mtw *ManageTunnelsWindow) onTunnelChange(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) { +func (mtw *ManageTunnelsWindow) onTunnelChange(tunnel *manager.Tunnel, state, globalState manager.TunnelState, err error) { mtw.Synchronize(func() { mtw.updateProgressIndicator(globalState) diff --git a/ui/raise.go b/ui/raise.go index 2d748a5c..c402bea7 100644 --- a/ui/raise.go +++ b/ui/raise.go @@ -55,7 +55,7 @@ func WaitForRaiseUIThenQuit() { var handle win.HWINEVENTHOOK runtime.LockOSThread() defer runtime.UnlockOSThread() - handle, err := win.SetWinEventHook(win.EVENT_OBJECT_CREATE, win.EVENT_OBJECT_CREATE, 0, func(hWinEventHook win.HWINEVENTHOOK, event uint32, hwnd win.HWND, idObject int32, idChild int32, idEventThread uint32, dwmsEventTime uint32) uintptr { + handle, err := win.SetWinEventHook(win.EVENT_OBJECT_CREATE, win.EVENT_OBJECT_CREATE, 0, func(hWinEventHook win.HWINEVENTHOOK, event uint32, hwnd win.HWND, idObject, idChild int32, idEventThread, dwmsEventTime uint32) uintptr { class := make([]uint16, len(manageWindowWindowClass)+2) /* Plus 2, one for the null terminator, and one to see if this is only a prefix */ n, err := win.GetClassName(hwnd, &class[0], len(class)) if err != nil || n != len(manageWindowWindowClass) || windows.UTF16ToString(class) != manageWindowWindowClass { diff --git a/ui/syntax/highlighter.go b/ui/syntax/highlighter.go index 47946093..d8e6a2a7 100644 --- a/ui/syntax/highlighter.go +++ b/ui/syntax/highlighter.go @@ -222,7 +222,7 @@ func (s stringSpan) isValidIPv6() bool { return true } -func (s stringSpan) isValidUint(supportHex bool, min uint64, max uint64) bool { +func (s stringSpan) isValidUint(supportHex bool, min, max uint64) bool { // Bound this around 32 bits, so that we don't have to write overflow logic. if s.len > 10 || s.len == 0 { return false @@ -444,7 +444,7 @@ func (hsa *highlightSpanArray) append(o *byte, s stringSpan, t highlight) { *hsa = append(*hsa, highlightSpan{t, int((uintptr(unsafe.Pointer(s.s))) - (uintptr(unsafe.Pointer(o)))), s.len}) } -func (hsa *highlightSpanArray) highlightMultivalueValue(parent stringSpan, s stringSpan, section field) { +func (hsa *highlightSpanArray) highlightMultivalueValue(parent, s stringSpan, section field) { switch section { case fieldDNS: if s.isValidIPv4() || s.isValidIPv6() { @@ -477,7 +477,7 @@ func (hsa *highlightSpanArray) highlightMultivalueValue(parent stringSpan, s str } } -func (hsa *highlightSpanArray) highlightMultivalue(parent stringSpan, s stringSpan, section field) { +func (hsa *highlightSpanArray) highlightMultivalue(parent, s stringSpan, section field) { currentSpan := stringSpan{s.s, 0} lenAtLastSpace := 0 for i := 0; i < s.len; i++ { @@ -506,7 +506,7 @@ func (hsa *highlightSpanArray) highlightMultivalue(parent stringSpan, s stringSp } } -func (hsa *highlightSpanArray) highlightValue(parent stringSpan, s stringSpan, section field) { +func (hsa *highlightSpanArray) highlightValue(parent, s stringSpan, section field) { switch section { case fieldPrivateKey: hsa.append(parent.s, s, validateHighlight(s.isValidKey(), highlightPrivateKey)) diff --git a/ui/syntax/syntaxedit.go b/ui/syntax/syntaxedit.go index 42f6e7b7..18b51436 100644 --- a/ui/syntax/syntaxedit.go +++ b/ui/syntax/syntaxedit.go @@ -90,22 +90,22 @@ type spanStyle struct { } var stylemap = map[highlight]spanStyle{ - highlightSection: spanStyle{color: win.RGB(0x32, 0x6D, 0x74), effects: win.CFE_BOLD}, - highlightField: spanStyle{color: win.RGB(0x9B, 0x23, 0x93), effects: win.CFE_BOLD}, - highlightPrivateKey: spanStyle{color: win.RGB(0x64, 0x38, 0x20)}, - highlightPublicKey: spanStyle{color: win.RGB(0x64, 0x38, 0x20)}, - highlightPresharedKey: spanStyle{color: win.RGB(0x64, 0x38, 0x20)}, - highlightIP: spanStyle{color: win.RGB(0x0E, 0x0E, 0xFF)}, - highlightCidr: spanStyle{color: win.RGB(0x81, 0x5F, 0x03)}, - highlightHost: spanStyle{color: win.RGB(0x0E, 0x0E, 0xFF)}, - highlightPort: spanStyle{color: win.RGB(0x81, 0x5F, 0x03)}, - highlightMTU: spanStyle{color: win.RGB(0x1C, 0x00, 0xCF)}, - highlightTable: spanStyle{color: win.RGB(0x1C, 0x00, 0xCF)}, - highlightKeepalive: spanStyle{color: win.RGB(0x1C, 0x00, 0xCF)}, - highlightComment: spanStyle{color: win.RGB(0x53, 0x65, 0x79), effects: win.CFE_ITALIC}, - highlightDelimiter: spanStyle{color: win.RGB(0x00, 0x00, 0x00)}, - highlightCmd: spanStyle{color: win.RGB(0x63, 0x75, 0x89)}, - highlightError: spanStyle{color: win.RGB(0xC4, 0x1A, 0x16), effects: win.CFE_UNDERLINE}, + highlightSection: {color: win.RGB(0x32, 0x6D, 0x74), effects: win.CFE_BOLD}, + highlightField: {color: win.RGB(0x9B, 0x23, 0x93), effects: win.CFE_BOLD}, + highlightPrivateKey: {color: win.RGB(0x64, 0x38, 0x20)}, + highlightPublicKey: {color: win.RGB(0x64, 0x38, 0x20)}, + highlightPresharedKey: {color: win.RGB(0x64, 0x38, 0x20)}, + highlightIP: {color: win.RGB(0x0E, 0x0E, 0xFF)}, + highlightCidr: {color: win.RGB(0x81, 0x5F, 0x03)}, + highlightHost: {color: win.RGB(0x0E, 0x0E, 0xFF)}, + highlightPort: {color: win.RGB(0x81, 0x5F, 0x03)}, + highlightMTU: {color: win.RGB(0x1C, 0x00, 0xCF)}, + highlightTable: {color: win.RGB(0x1C, 0x00, 0xCF)}, + highlightKeepalive: {color: win.RGB(0x1C, 0x00, 0xCF)}, + highlightComment: {color: win.RGB(0x53, 0x65, 0x79), effects: win.CFE_ITALIC}, + highlightDelimiter: {color: win.RGB(0x00, 0x00, 0x00)}, + highlightCmd: {color: win.RGB(0x63, 0x75, 0x89)}, + highlightError: {color: win.RGB(0xC4, 0x1A, 0x16), effects: win.CFE_UNDERLINE}, } func (se *SyntaxEdit) evaluateUntunneledBlocking(cfg string, spans []highlightSpan) { @@ -252,7 +252,7 @@ func (tray *Tray) rebalanceTunnelsMenu() { } } -func (tray *Tray) onTunnelChange(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) { +func (tray *Tray) onTunnelChange(tunnel *manager.Tunnel, state, globalState manager.TunnelState, err error) { tray.mtw.Synchronize(func() { tray.updateGlobalState(globalState) if err == nil { diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go index a62cb0ce..4c687a39 100644 --- a/ui/tunnelspage.go +++ b/ui/tunnelspage.go @@ -280,7 +280,7 @@ func (tp *TunnelsPage) updateConfView() { func (tp *TunnelsPage) importFiles(paths []string) { go func() { - syncedMsgBox := func(title string, message string, flags walk.MsgBoxStyle) { + syncedMsgBox := func(title, message string, flags walk.MsgBoxStyle) { tp.Synchronize(func() { walk.MsgBox(tp.Form(), title, message, flags) }) @@ -422,7 +422,6 @@ func (tp *TunnelsPage) addTunnel(config *conf.Config) { if err != nil { showErrorCustom(tp.Form(), l18n.Sprintf("Unable to create tunnel"), err.Error()) } - } // Handlers @@ -519,7 +518,6 @@ func (tp *TunnelsPage) onDelete() { tunnelsToDelete := make([]manager.Tunnel, len(indices)) for i, j := range indices { tunnelsToDelete[i] = tp.listView.model.tunnels[j] - } go func() { tp.listView.SetSuspendTunnelsUpdate(true) @@ -20,10 +20,12 @@ import ( "golang.zx2c4.com/wireguard/windows/version" ) -var noTrayAvailable = false -var shouldQuitManagerWhenExiting = false -var startTime = time.Now() -var IsAdmin = false // A global, because this really is global for the process +var ( + noTrayAvailable = false + shouldQuitManagerWhenExiting = false + startTime = time.Now() + IsAdmin = false // A global, because this really is global for the process +) func RunUI() { runtime.LockOSThread() |