Skip to content

Commit 059b835

Browse files
committed
simple-dnscrypt: Fix extraction & persistence, refactor uninstaller logic
1 parent 5d9773c commit 059b835

1 file changed

Lines changed: 47 additions & 28 deletions

File tree

bucket/simple-dnscrypt.json

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"version": "0.7.1",
3-
"description": "An easy to use GUI for dnscrypt-proxy",
4-
"homepage": "https://simplednscrypt.org/",
5-
"license": "MIT",
3+
"description": "A simple management tool to configure dnscrypt-proxy on windows based systems.",
4+
"homepage": "https://simplednscrypt.org",
5+
"license": {
6+
"identifier": "MIT",
7+
"url": "https://github.com/bitbeans/SimpleDnsCrypt/blob/HEAD/LICENSE.md"
8+
},
69
"suggest": {
7-
"vcredist": "extras/vcredist2022"
10+
"Microsoft Visual C++ 2015-2022 Redistributable": "extras/vcredist2022"
811
},
912
"architecture": {
1013
"64bit": {
@@ -17,9 +20,14 @@
1720
}
1821
},
1922
"pre_install": [
20-
"if (!(Test-Path \"$env:LOCALAPPDATA\\SimpleDnsCrypt\")) { New-Item \"$env:LOCALAPPDATA\\SimpleDnsCrypt\" -ItemType Directory -Force | Out-Null }",
21-
"'blacklist.txt', 'blocked.log', 'query.log', 'domain-blacklist.txt', 'domain-whitelist.txt' | ForEach-Object {",
22-
" if (!(Test-Path \"$persist_dir\\$_\")) { New-Item \"$dir\\$_\" | Out-Null }",
23+
"if (Test-Path -Path \"$dir\\APPDIR\" -PathType Container) {",
24+
" Copy-Item -Path \"$dir\\APPDIR\\*\" -Destination $dir -Force -Recurse",
25+
" Remove-Item -Path \"$dir\\APPDIR\" -Recurse -Force -ErrorAction SilentlyContinue",
26+
"}",
27+
"'*.log', '*.txt' | ForEach-Object {",
28+
" if (Test-Path -Path \"$persist_dir\\$_\" -PathType Leaf) {",
29+
" Copy-Item -Path \"$persist_dir\\$_\" -Destination \"$dir\\dnscrypt-proxy\" -Force",
30+
" }",
2331
"}"
2432
],
2533
"shortcuts": [
@@ -28,30 +36,41 @@
2836
"Simple DnsCrypt"
2937
]
3038
],
31-
"bin": "SimpleDnsCrypt.exe",
32-
"persist": [
33-
"dnscrypt-proxy\\dnscrypt-proxy.toml",
34-
"dnscrypt-proxy\\blacklist.txt",
35-
"dnscrypt-proxy\\blocked.log",
36-
"dnscrypt-proxy\\query.log",
37-
"dnscrypt-proxy\\domain-blacklist.txt",
38-
"dnscrypt-proxy\\domain-whitelist.txt"
39-
],
39+
"persist": "dnscrypt-proxy\\dnscrypt-proxy.toml",
4040
"pre_uninstall": [
41-
"if (!(is_admin)) { error \"$app requires admin rights to $cmd\"; break }",
42-
"",
43-
"Start-Process -Wait \"$dir\\Uninstall.exe\" | Out-Null",
44-
"if (Get-Process -Name 'SimpleDnsCrypt' -ErrorAction SilentlyContinue) { Stop-Process -Name 'SimpleDnsCrypt' | Out-Null }",
45-
"$service = Get-Service -Name 'dnscrypt-proxy' -ErrorAction SilentlyContinue",
46-
"if (($service) -and ($service.Status -ne 'Stopped')) {",
47-
" if (!(is_admin)) { error 'Admin rights are required to stop dnscrypt-proxy service'; break }",
48-
" Stop-Service -Name 'dnscrypt-proxy' | Out-Null",
49-
"}",
50-
"if (($service) -and ($cmd -eq 'uninstall')) {",
51-
" if (!(is_admin)) { error 'Admin rights are required to remove dnscrypt-proxy service'; break }",
52-
" Remove-Service -Name 'dnscrypt-proxy' | Out-Null",
41+
"'*.log', '*.txt' | ForEach-Object {",
42+
" if (Test-Path -Path \"$dir\\dnscrypt-proxy\\$_\" -PathType Leaf) {",
43+
" Copy-Item -Path \"$dir\\dnscrypt-proxy\\$_\" -Destination $persist_dir -Force",
44+
" }",
5345
"}"
5446
],
47+
"uninstaller": {
48+
"script": [
49+
"$base_service_name = 'dnscrypt-proxy'",
50+
"$path_regex = [regex]::Escape((Split-Path -Path $dir -Parent))",
51+
"Stop-Process -Name 'SimpleDnsCrypt' -Force -ErrorAction SilentlyContinue",
52+
"if ($PSVersionTable.PSVersion -ge [version]::new(6, 0)) {",
53+
" $services = Get-Service -Name \"*$base_service_name*\" -ErrorAction SilentlyContinue",
54+
"} else {",
55+
" $name_filter = \"Name like '%$base_service_name%'\"",
56+
" $services = Get-CimInstance -ClassName Win32_Service -Filter $name_filter -ErrorAction SilentlyContinue |",
57+
" Select-Object -Property *, @{ Name = 'BinaryPathName'; Expression = { $_.PathName } }",
58+
"}",
59+
"$service = $services | Where-Object { $_.BinaryPathName -match $path_regex }",
60+
"if ($null -ne $service) {",
61+
" if (-not (is_admin)) { abort \"`n[ERROR] $app requires admin rights to $cmd.\" }",
62+
" Stop-Service -Name $service.Name -Force -ErrorAction SilentlyContinue",
63+
" Stop-Process -Name 'dnscrypt-proxy' -Force -ErrorAction SilentlyContinue",
64+
" Start-Sleep -Milliseconds 1500",
65+
" if ($cmd -ne 'uninstall') { return }",
66+
" if ($PSVersionTable.PSVersion -ge [version]::new(6, 0)) {",
67+
" Remove-Service -Name 'dnscrypt-proxy' -ErrorAction SilentlyContinue",
68+
" } else {",
69+
" Start-Process -FilePath 'sc.exe' -ArgumentList @('delete', 'dnscrypt-proxy') -NoNewWindow -Wait",
70+
" }",
71+
"}"
72+
]
73+
},
5574
"checkver": {
5675
"github": "https://github.com/bitbeans/SimpleDnsCrypt"
5776
},

0 commit comments

Comments
 (0)