mirror of
https://github.com/amnezia-vpn/amneziawg-windows-client.git
synced 2026-07-03 14:05:10 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f352b8f383 | |||
| 07aa1d2256 | |||
| 3f69137ed4 | |||
| fdcd8ebc7a | |||
| 7d34e94e5e | |||
| 32ca5b77bc | |||
| 3f898ed0f5 | |||
| 65e5e07077 |
@@ -4,7 +4,7 @@ rem Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
set BUILDDIR=%~dp0
|
||||
set PATH=%BUILDDIR%.deps\llvm-mingw-20231128-ucrt-x86_64\bin;%BUILDDIR%.deps\go\bin;%BUILDDIR%.deps;%PATH%
|
||||
set PATH=%BUILDDIR%.deps\llvm-mingw-20231128-ucrt-x86_64\bin;%BUILDDIR%.deps\go-legacy-win7\bin;%BUILDDIR%.deps;%PATH%
|
||||
set PATHEXT=.exe
|
||||
cd /d %BUILDDIR% || exit /b 1
|
||||
|
||||
@@ -13,7 +13,7 @@ if exist .deps\prepared goto :render
|
||||
rmdir /s /q .deps 2> NUL
|
||||
mkdir .deps || goto :error
|
||||
cd .deps || goto :error
|
||||
call :download go.zip https://go.dev/dl/go1.22.12.windows-amd64.zip 2ceda04074eac51f4b0b85a9fcca38bcd49daee24bed9ea1f29958a8e22673a6 || goto :error
|
||||
call :download go-legacy-win7.zip https://github.com/thongtech/go-legacy-win7/releases/download/v1.24.0-1/go-legacy-win7-1.24.0-1.windows_amd64.zip 6767df9ab0140b2c9a302af2dad338f6ba7aae6674feb004483e9a155e41e172 || goto :error
|
||||
call :download llvm-mingw-20231128-ucrt-x86_64.zip https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-x86_64.zip 7a344dafa6942de2c1f4643b3eb5c5ce5317fbab671a887e4d39f326b331798f || goto :error
|
||||
rem Mirror of https://imagemagick.org/download/binaries/ImageMagick-7.0.8-42-portable-Q16-x64.zip
|
||||
call :download imagemagick.zip https://download.wireguard.com/windows-toolchain/distfiles/ImageMagick-7.0.8-42-portable-Q16-x64.zip 584e069f56456ce7dde40220948ff9568ac810688c892c5dfb7f6db902aa05aa "convert.exe colors.xml delegates.xml" || goto :error
|
||||
@@ -35,7 +35,7 @@ if exist .deps\prepared goto :render
|
||||
set GOOS=windows
|
||||
set GOARM=7
|
||||
set GOPATH=%BUILDDIR%.deps\gopath
|
||||
set GOROOT=%BUILDDIR%.deps\go
|
||||
set GOROOT=%BUILDDIR%.deps\go-legacy-win7
|
||||
if "%GoGenerate%"=="yes" (
|
||||
echo [+] Regenerating files
|
||||
go generate ./... || exit /b 1
|
||||
|
||||
+6
-1
@@ -78,7 +78,7 @@ func newEditDialog(owner walk.Form, tunnel *manager.Tunnel) (*EditDialog, error)
|
||||
dlg.SetIcon(owner.Icon())
|
||||
dlg.SetTitle(title)
|
||||
dlg.SetLayout(layout)
|
||||
dlg.SetMinMaxSize(walk.Size{500, 400}, walk.Size{0, 0})
|
||||
dlg.SetMinMaxSize(walk.Size{500, 500}, walk.Size{0, 0})
|
||||
if icon, err := loadSystemIcon("imageres", -114, 32); err == nil {
|
||||
dlg.SetIcon(icon)
|
||||
}
|
||||
@@ -152,6 +152,7 @@ func newEditDialog(owner walk.Form, tunnel *manager.Tunnel) (*EditDialog, error)
|
||||
dlg.SetCancelButton(cancelButton)
|
||||
dlg.SetDefaultButton(dlg.saveButton)
|
||||
|
||||
dlg.syntaxEdit.TextChanged().Attach(dlg.onSyntaxEditTextChanged)
|
||||
dlg.syntaxEdit.PrivateKeyChanged().Attach(dlg.onSyntaxEditPrivateKeyChanged)
|
||||
dlg.syntaxEdit.BlockUntunneledTrafficStateChanged().Attach(dlg.onBlockUntunneledTrafficStateChanged)
|
||||
dlg.syntaxEdit.SetText(dlg.config.ToWgQuick())
|
||||
@@ -312,6 +313,10 @@ func (dlg *EditDialog) onSyntaxEditPrivateKeyChanged(privateKey string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (dlg *EditDialog) onSyntaxEditTextChanged() {
|
||||
dlg.saveButton.SetEnabled(dlg.syntaxEdit.HaveErrors())
|
||||
}
|
||||
|
||||
func (dlg *EditDialog) onSaveButtonClicked() {
|
||||
newName := dlg.nameEdit.Text()
|
||||
if newName == "" {
|
||||
|
||||
+144
-6
@@ -8,7 +8,12 @@
|
||||
|
||||
package syntax
|
||||
|
||||
import "unsafe"
|
||||
import (
|
||||
"strconv"
|
||||
"unsafe"
|
||||
|
||||
"github.com/amnezia-vpn/amneziawg-go/device"
|
||||
)
|
||||
|
||||
type highlight int
|
||||
|
||||
@@ -37,6 +42,7 @@ const (
|
||||
highlightH2
|
||||
highlightH3
|
||||
highlightH4
|
||||
highlightWarning
|
||||
highlightError
|
||||
)
|
||||
|
||||
@@ -578,15 +584,15 @@ func (hsa *highlightSpanArray) highlightValue(parent, s stringSpan, section fiel
|
||||
case fieldAddress, fieldDNS, fieldAllowedIPs:
|
||||
hsa.highlightMultivalue(parent, s, section)
|
||||
case fieldJc:
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 128), highlightJc))
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 65_535), highlightJc))
|
||||
case fieldJmin:
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 1280), highlightJmin))
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 65_535), highlightJmin))
|
||||
case fieldJmax:
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 1280), highlightJmax))
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 65_535), highlightJmax))
|
||||
case fieldS1:
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 150), highlightS1))
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 65_535), highlightS1))
|
||||
case fieldS2:
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 150), highlightS2))
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 65_535), highlightS2))
|
||||
case fieldH1:
|
||||
hsa.append(parent.s, s, validateHighlight(s.isValidUint(false, 0, 2_147_483_647), highlightH1))
|
||||
case fieldH2:
|
||||
@@ -683,3 +689,135 @@ func highlightConfig(config string) []highlightSpan {
|
||||
}
|
||||
return ([]highlightSpan)(ret)
|
||||
}
|
||||
|
||||
func highlightASecConfig(cfg string, spans []highlightSpan) {
|
||||
const (
|
||||
maxMTU = 1500
|
||||
diffMTU = 80
|
||||
)
|
||||
|
||||
var (
|
||||
mtu = 0
|
||||
jc = 0
|
||||
jmin = 0
|
||||
jmax = 0
|
||||
s1 = 0
|
||||
s2 = 0
|
||||
h1 = 0
|
||||
h2 = 0
|
||||
h3 = 0
|
||||
h4 = 0
|
||||
)
|
||||
|
||||
var err error
|
||||
|
||||
for i := range spans {
|
||||
span := &spans[i]
|
||||
switch span.t {
|
||||
case highlightError:
|
||||
return
|
||||
case highlightMTU:
|
||||
if mtu, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightJc:
|
||||
if jc, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightJmin:
|
||||
if jmin, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightJmax:
|
||||
if jmax, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightS1:
|
||||
if s1, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightS2:
|
||||
if s2, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightH1:
|
||||
if h1, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightH2:
|
||||
if h2, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightH3:
|
||||
if h3, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
case highlightH4:
|
||||
if h4, err = strconv.Atoi(cfg[span.s : span.s+span.len]); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if mtu == 0 {
|
||||
mtu = device.DefaultMTU
|
||||
}
|
||||
if h1 <= 4 {
|
||||
h1 = 1
|
||||
}
|
||||
if h2 <= 4 {
|
||||
h2 = 2
|
||||
}
|
||||
if h3 <= 4 {
|
||||
h3 = 3
|
||||
}
|
||||
if h4 <= 4 {
|
||||
h4 = 4
|
||||
}
|
||||
|
||||
for i := range spans {
|
||||
span := &spans[i]
|
||||
switch span.t {
|
||||
case highlightJc:
|
||||
if jc > 128 {
|
||||
span.t = highlightWarning
|
||||
}
|
||||
case highlightJmin:
|
||||
if (jc != 0 || jmin != 0 || jmax != 0) && (jmin >= jmax || jmin >= mtu+diffMTU || jmin >= maxMTU) {
|
||||
span.t = highlightWarning
|
||||
}
|
||||
case highlightJmax:
|
||||
if (jc != 0 || jmin != 0 || jmax != 0) && (jmax <= jmin || jmax > mtu+diffMTU || jmax > maxMTU) {
|
||||
span.t = highlightWarning
|
||||
}
|
||||
case highlightS1:
|
||||
if s1+device.MessageInitiationSize == s2+device.MessageResponseSize {
|
||||
span.t = highlightError
|
||||
} else if s1 > mtu-device.MessageInitiationSize+diffMTU || s1 > maxMTU-device.MessageInitiationSize {
|
||||
span.t = highlightWarning
|
||||
}
|
||||
case highlightS2:
|
||||
if s1+device.MessageInitiationSize == s2+device.MessageResponseSize {
|
||||
span.t = highlightError
|
||||
} else if s2 > mtu-device.MessageResponseSize+diffMTU || s2 > maxMTU-device.MessageResponseSize {
|
||||
span.t = highlightWarning
|
||||
}
|
||||
case highlightH1:
|
||||
if h1 > 4 && (h1 == h2 || h1 == h3 || h1 == h4) {
|
||||
span.t = highlightError
|
||||
}
|
||||
case highlightH2:
|
||||
if h2 > 4 && (h2 == h1 || h2 == h3 || h2 == h4) {
|
||||
span.t = highlightError
|
||||
}
|
||||
case highlightH3:
|
||||
if h3 > 4 && (h3 == h1 || h3 == h2 || h3 == h4) {
|
||||
span.t = highlightError
|
||||
}
|
||||
case highlightH4:
|
||||
if h4 > 4 && (h4 == h1 || h4 == h2 || h4 == h3) {
|
||||
span.t = highlightError
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ type SyntaxEdit struct {
|
||||
irich *win.IRichEditOle
|
||||
idoc *win.ITextDocument
|
||||
lastBlockState BlockState
|
||||
haveErrors bool
|
||||
yheight int
|
||||
highlightGuard uint32
|
||||
textChangedPublisher walk.EventPublisher
|
||||
@@ -72,6 +73,10 @@ func (se *SyntaxEdit) SetText(text string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (se *SyntaxEdit) HaveErrors() bool {
|
||||
return se.haveErrors
|
||||
}
|
||||
|
||||
func (se *SyntaxEdit) TextChanged() *walk.Event {
|
||||
return se.textChangedPublisher.Event()
|
||||
}
|
||||
@@ -105,6 +110,16 @@ var stylemap = map[highlight]spanStyle{
|
||||
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)},
|
||||
highlightJc: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightJmin: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightJmax: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightS1: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightS2: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightH1: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightH2: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightH3: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightH4: {color: win.RGB(0x64, 0x38, 0x20)},
|
||||
highlightWarning: {color: win.RGB(0xC4, 0x1A, 0x16), effects: win.CFE_UNDERLINE},
|
||||
highlightError: {color: win.RGB(0xC4, 0x1A, 0x16), effects: win.CFE_UNDERLINE},
|
||||
}
|
||||
|
||||
@@ -191,6 +206,18 @@ done:
|
||||
}
|
||||
}
|
||||
|
||||
func (se *SyntaxEdit) evaluateHaveErrors(spans []highlightSpan) {
|
||||
for i := range spans {
|
||||
span := &spans[i]
|
||||
switch span.t {
|
||||
case highlightError:
|
||||
se.haveErrors = false
|
||||
return
|
||||
}
|
||||
}
|
||||
se.haveErrors = true
|
||||
}
|
||||
|
||||
func (se *SyntaxEdit) highlightText() error {
|
||||
if !atomic.CompareAndSwapUint32(&se.highlightGuard, 0, 1) {
|
||||
return nil
|
||||
@@ -220,7 +247,9 @@ func (se *SyntaxEdit) highlightText() error {
|
||||
cfg := strings.Replace(string(msg[:msgCount]), "\r", "\n", -1)
|
||||
|
||||
spans := highlightConfig(cfg)
|
||||
highlightASecConfig(cfg, spans)
|
||||
se.evaluateUntunneledBlocking(cfg, spans)
|
||||
se.evaluateHaveErrors(spans)
|
||||
|
||||
se.idoc.Undo(win.TomSuspend, nil)
|
||||
win.SendMessage(hWnd, win.EM_SETEVENTMASK, 0, 0)
|
||||
|
||||
@@ -69,6 +69,7 @@ func NewTunnelsPage() (*TunnelsPage, error) {
|
||||
vlayout.SetAlignment(walk.AlignHNearVCenter)
|
||||
vlayout.SetMargins(walk.Margins{})
|
||||
tp.currentTunnelContainer.SetLayout(vlayout)
|
||||
hlayout.SetStretchFactor(tp.currentTunnelContainer, 100)
|
||||
|
||||
if tp.fillerContainer, err = walk.NewComposite(tp); err != nil {
|
||||
return nil, err
|
||||
@@ -78,6 +79,7 @@ func NewTunnelsPage() (*TunnelsPage, error) {
|
||||
vlayout.SetAlignment(walk.AlignHCenterVCenter)
|
||||
vlayout.SetMargins(walk.Margins{})
|
||||
tp.fillerContainer.SetLayout(vlayout)
|
||||
hlayout.SetStretchFactor(tp.fillerContainer, 100)
|
||||
|
||||
fillerButtonContainer, _ := walk.NewComposite(tp.fillerContainer)
|
||||
hlayout = walk.NewHBoxLayout()
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
officialCommonName = "WireGuard LLC"
|
||||
officialCommonName = "Privacy Technologies OU"
|
||||
evPolicyOid = "2.23.140.1.3"
|
||||
policyExtensionOid = "2.5.29.32"
|
||||
)
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@
|
||||
package version
|
||||
|
||||
const (
|
||||
Number = "1.0.1"
|
||||
Number = "1.0.2"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user