-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathncdns.nsi
2260 lines (1952 loc) · 83.2 KB
/
ncdns.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!ifndef NCDNS_PRODVER
#!ifdef POSIX_BUILD
!error "Must define NCDNS_PRODVER"
#!else
## This won't currently work for Go binaries, since they don't have any
## version information embedded in them.
# !system 'powershell -executionpolicy bypass -noninteractive -file getver.ps1 . < nul'
# !include '_ver.nsi'
# !delfile '_ver.nsi'
#!endif
!endif
!include "MUI2.nsh"
!include "FileFunc.nsh"
# INSTALLER SETTINGS
##############################################################################
OutFile "${OUTFN}"
# Jeremy Rand thinks people shouldn't change this because it might affect build
# determinism, so any PR which changes this should probably highlight him or
# something.
SetCompressor /SOLID lzma
!define MUI_ICON "media\namecoin.ico"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowCallback
# From https://docs.microsoft.com/en-US/windows/security/identity-protection/access-control/security-identifiers
!define SID_SYSTEM "*S-1-5-18"
!define SID_ADMINISTRATORS "*S-1-5-32-544"
!define SID_USERS "*S-1-5-32-545"
!include "namecoin-dialog.nsdinc"
!include "dns-dialog.nsdinc"
!include "darknet-dialog.nsdinc"
!include "tls-positive-dialog.nsdinc"
!include "tls-negative-dialog.nsdinc"
!include "exectolog.nsh"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
Page custom NamecoinDialogCreate NamecoinDialogLeave
Page custom DNSDialogCreate DNSDialogLeave
Page custom DarknetDialogCreate DarknetDialogLeave
Page custom TLSPositiveDialogCreate TLSPositiveDialogLeave
Page custom TLSNegativeDialogCreate TLSNegativeDialogLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE English
!ifdef NCDNS_64BIT
InstallDir $PROGRAMFILES64\ncdns
!else
InstallDir $PROGRAMFILES\ncdns
!endif
InstallDirRegKey HKLM "Software\Namecoin\ncdns" "InstallPath"
ShowInstDetails show
ShowUninstDetails show
RequestExecutionLevel admin
XPStyle on
CRCCheck on
# Branding.
Name "ncdns for Windows"
BrandingText "Namecoin"
# Installer .exe version tables.
VIAddVersionKey "ProductName" "ncdns"
VIAddVersionKey "ProductVersion" "${NCDNS_PRODVER}"
VIProductVersion "${NCDNS_PRODVER}"
VIAddVersionKey "InternalName" "ncdns"
VIAddVersionKey "FileDescription" "ncdns Installer"
VIAddVersionKey "FileVersion" "${NCDNS_PRODVER}"
!ifndef POSIX_BUILD
VIFileVersion "${NCDNS_PRODVER}"
!endif
VIAddVersionKey "OriginalFilename" "ncdns-install.exe"
VIAddVersionKey "CompanyName" "Namecoin Project"
VIAddVersionKey "LegalCopyright" "2017-2021 Namecoin Developers"
VIAddVersionKey "LegalTrademarks" "ncdns, Namecoin"
VIAddVersionKey "Comments" "ncdns Installer"
# VARIABLES
##############################################################################
Var /GLOBAL UnboundConfPath
Var /GLOBAL UnboundFragmentLocation
Var /GLOBAL DNSSECTriggerUninstallCommand
Var /GLOBAL NamecoinCoreUninstallCommand
Var /GLOBAL ElectrumNMCUninstallCommand
Var /GLOBAL NamecoinCoreDataDir
Var /GLOBAL UseUnbound
Var /GLOBAL UseNamecoinCore
Var /GLOBAL UseConsensusJ
Var /GLOBAL UseElectrumNMC
Var /GLOBAL UseTorBrowser
Var /GLOBAL UseTorSwitch
Var /GLOBAL NamecoinCoreDetected
Var /GLOBAL ElectrumNMCDetected
Var /GLOBAL UnboundDetected
Var /GLOBAL TorBrowserDetected
Var /GLOBAL TorBrowserDetectReturnCode
Var /GLOBAL CryptoAPIInjectionEnabled
Var /GLOBAL CryptoAPIEncayaEnabled
Var /GLOBAL Ncp11EnterpriseFirefoxEnabled
Var /GLOBAL CryptoAPINameConstraintsEnabled
Var /GLOBAL JREPath
Var /GLOBAL JREDetected
Var /GLOBAL JRE32Detected
Var /GLOBAL JRE64Detected
Var /GLOBAL VC2010_x86_32Detected
Var /GLOBAL VC2010_x86_64Detected
Var /GLOBAL VC2012_x86_32Detected
Var /GLOBAL VC2012_x86_64Detected
Var /GLOBAL VC2015_x86_32Detected
Var /GLOBAL VC2015_x86_64Detected
Var /GLOBAL BindRequirementsMet
Var /GLOBAL BindRequirementsURL
Var /GLOBAL BindRequirementsError
Var /GLOBAL BitcoinJRequirementsMet
Var /GLOBAL BitcoinJRequirementsError
Var /GLOBAL ETLD
Var /GLOBAL ElectrumNMCConfigReturnCode
Var /GLOBAL ElectrumNMCConfigOutput
Var /GLOBAL ServiceNcdnsCreateReturnCode
Var /GLOBAL ServiceNcdnsSidtypeReturnCode
Var /GLOBAL ServiceNcdnsDescriptionReturnCode
Var /GLOBAL ServiceNcdnsPrivsReturnCode
Var /GLOBAL ServiceNcdnsStartReturnCode
Var /GLOBAL ServiceEncayaCreateReturnCode
Var /GLOBAL ServiceEncayaSidtypeReturnCode
Var /GLOBAL ServiceEncayaDescriptionReturnCode
Var /GLOBAL ServiceEncayaPrivsReturnCode
Var /GLOBAL ServiceEncayaStartReturnCode
Var /GLOBAL ServiceStemNSCreateReturnCode
Var /GLOBAL ServiceStemNSSidtypeReturnCode
Var /GLOBAL ServiceStemNSDescriptionReturnCode
Var /GLOBAL ServiceStemNSPrivsReturnCode
Var /GLOBAL ServiceStemNSFailureReturnCode
Var /GLOBAL ServiceStemNSStartReturnCode
Var /GLOBAL CoreCookieDirReturnCode
Var /GLOBAL CoreCookieFileReturnCode
Var /GLOBAL EtcReturnCode
Var /GLOBAL EtcConfReturnCode
Var /GLOBAL EtcConfDReturnCode
Var /GLOBAL EtcConfElectrumReturnCode
Var /GLOBAL EtcConfXlogReturnCode
Var /GLOBAL EtcZskReturnCode
Var /GLOBAL EtcZskPrivReturnCode
Var /GLOBAL EtcZskPubReturnCode
Var /GLOBAL EtcZskDsReturnCode
Var /GLOBAL EtcKskReturnCode
Var /GLOBAL EtcKskPrivReturnCode
Var /GLOBAL EtcKskPubReturnCode
Var /GLOBAL EtcKskDsReturnCode
Var /GLOBAL EtcEncayaReturnCode
Var /GLOBAL EtcEncayaConfDReturnCode
Var /GLOBAL EtcEncayaConfReturnCode
Var /GLOBAL EtcEncayaConfXlogReturnCode
Var /GLOBAL EtcEncayaRootKeyReturnCode
Var /GLOBAL EtcEncayaListenChainReturnCode
Var /GLOBAL EtcEncayaListenKeyReturnCode
Var /GLOBAL EtcEncayaRootCertReturnCode
Var /GLOBAL EtcNCProp279ReturnCode
Var /GLOBAL EtcNCProp279ConfDReturnCode
Var /GLOBAL EtcNCProp279ConfCoreReturnCode
Var /GLOBAL EtcNCProp279ConfConsensusJReturnCode
Var /GLOBAL EtcNCProp279ConfElectrumReturnCode
Var /GLOBAL KeyDNSSECReturnCode
Var /GLOBAL KeyEncayaReturnCode
Var /GLOBAL TorRunningReturnCode
Var /GLOBAL TorBrowserConfigReturnCode
# PRELAUNCH CHECKS
##############################################################################
!Include WinVer.nsh
!include x64.nsh
Function .onInit
${IfNot} ${AtLeastWinVista}
MessageBox "MB_OK|MB_ICONSTOP" "ncdns requires Windows Vista or later." /SD IDOK
Abort
${EndIf}
# verifyctl.cmd uses "certutil -v -f -verifyCTL AuthRootWU".
# The verifyCTL command exists on Windows 8.0 Pro Build 9200, but is
# unavailable on Windows 7 and Windows Server 2008 R2 Standard Full.
${IfNot} ${AtLeastWin8}
MessageBox "MB_OKCANCEL|MB_ICONEXCLAMATION" "ncdns works best with Windows 8 or later. If you install ncdns, you will have degraded security. Would you like to continue installing anyway?" /SD IDOK IDOK win7okay IDCANCEL 0
Abort
win7okay:
${EndIf}
SetShellVarContext all
# Make sections mandatory.
Call ConfigSections
# Detect if already installed.
Call CheckReinstall
# Detect already installed dependencies.
Call DetectNamecoinCore
Call DetectElectrumNMC
Call DetectUnbound
Call DetectTorBrowser
Call DetectJRE
Call DetectVC2010_x86_32
Call DetectVC2010_x86_64
Call DetectVC2012_x86_32
Call DetectVC2012_x86_64
Call DetectVC2015_x86_32
Call DetectVC2015_x86_64
Call DetectBindRequirements
Call DetectBitcoinJRequirements
Call DetectETLD
# Default components: Namecoin
Push ${BST_CHECKED}
Pop $UseNamecoinCore
Push ${BST_UNCHECKED}
Pop $UseConsensusJ
Push ${BST_UNCHECKED}
Pop $UseElectrumNMC
# Default components: DNS
Push ${BST_CHECKED}
Pop $UseUnbound
# Default components: TLS
# CertInject temporarily disabled
#Push ${BST_CHECKED}
Push ${BST_UNCHECKED}
Pop $CryptoAPIInjectionEnabled
Push ${BST_CHECKED}
Pop $CryptoAPIEncayaEnabled
Push ${BST_CHECKED}
Pop $Ncp11EnterpriseFirefoxEnabled
Push ${BST_CHECKED}
Pop $CryptoAPINameConstraintsEnabled
FunctionEnd
Function un.onInit
SetShellVarContext all
FunctionEnd
Function CheckReinstall
ClearErrors
ReadRegStr $0 HKLM "System\CurrentControlSet\Services\ncdns" "ImagePath"
IfErrors not_installed
MessageBox "MB_OK|MB_ICONSTOP" "ncdns for Windows is already installed.$\n$\nTo reinstall ncdns for Windows, first uninstall it." /SD IDOK
Abort
not_installed:
FunctionEnd
Function DetectVC2010_x86_32
# https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
# https://stackoverflow.com/a/34199260
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" "Installed"
${If} $0 != "1"
Push 0
Pop $VC2010_x86_32Detected
${Else}
Push 1
Pop $VC2010_x86_32Detected
${EndIf}
FunctionEnd
Function DetectVC2010_x86_64
# https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
# https://stackoverflow.com/a/34199260
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64" "Installed"
${If} $0 != "1"
Push 0
Pop $VC2010_x86_64Detected
${Else}
Push 1
Pop $VC2010_x86_64Detected
${EndIf}
FunctionEnd
Function DetectVC2012_x86_32
# https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
# https://stackoverflow.com/a/34199260
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86" "Installed"
${If} $0 != "1"
Push 0
Pop $VC2012_x86_32Detected
${Else}
Push 1
Pop $VC2012_x86_32Detected
${EndIf}
FunctionEnd
Function DetectVC2012_x86_64
# https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
# https://stackoverflow.com/a/34199260
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x64" "Installed"
${If} $0 != "1"
Push 0
Pop $VC2012_x86_64Detected
${Else}
Push 1
Pop $VC2012_x86_64Detected
${EndIf}
FunctionEnd
Function DetectVC2015_x86_32
# https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
# https://stackoverflow.com/a/34199260
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
${If} $0 != "1"
Push 0
Pop $VC2015_x86_32Detected
${Else}
Push 1
Pop $VC2015_x86_32Detected
${EndIf}
FunctionEnd
Function DetectVC2015_x86_64
# https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
# https://stackoverflow.com/a/34199260
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
${If} $0 != "1"
Push 0
Pop $VC2015_x86_64Detected
${Else}
Push 1
Pop $VC2015_x86_64Detected
${EndIf}
FunctionEnd
Function DetectNamecoinCore
ClearErrors
ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Namecoin Core (32-bit)" "UninstallString"
IfErrors 0 found
ClearErrors
ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Namecoin Core (64-bit)" "UninstallString"
IfErrors 0 found
Goto absent
found:
Push 1
Pop $NamecoinCoreDetected
Return
absent:
Push 0
Pop $NamecoinCoreDetected
FunctionEnd
Function DetectElectrumNMC
ClearErrors
ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Electrum-NMC" "UninstallString"
IfErrors 0 found
Goto absent
found:
Push 1
Pop $ElectrumNMCDetected
Return
absent:
Push 0
Pop $ElectrumNMCDetected
FunctionEnd
Function DetectUnbound
ClearErrors
ReadRegDWORD $0 HKLM "System\CurrentControlSet\Services\unbound" "Type"
IfErrors absent 0
Push 1
Pop $UnboundDetected
Return
absent:
Push 0
Pop $UnboundDetected
FunctionEnd
Function DetectTorBrowser
File /oname=$PLUGINSDIR\detecttorbrowser.ps1 detecttorbrowser.ps1
File /oname=$PLUGINSDIR\detecttorbrowserchannel.ps1 detecttorbrowserchannel.ps1
SetOutPath "$PLUGINSDIR"
# "-inputformat none" works around a PowerShell v2 (Windows 7) bug that
# manifests as exit code 1 with stderr "Access to this path is denied". See
# http://forums.winamp.com/showthread.php?p=2969465
nsExec::ExecToStack 'powershell -executionpolicy bypass -inputformat none -noninteractive -file "$PLUGINSDIR\detecttorbrowser.ps1"'
Pop $TorBrowserDetectReturnCode
Pop $TorBrowserDetected
Delete $PLUGINSDIR\detecttorbrowserchannel.ps1
Delete $PLUGINSDIR\detecttorbrowser.ps1
SetOutPath "$INSTDIR"
${If} $TorBrowserDetectReturnCode != 0
MessageBox "MB_OK|MB_ICONSTOP" "Failed to detect Tor Browser: return code $TorBrowserDetectReturnCode:$\n$\n$TorBrowserDetected" /SD IDOK
Abort
${EndIf}
FunctionEnd
Var /GLOBAL DetectJRE_W
Function DetectJRE
StrCpy $JREDetected 0
# Check for 64-bit JRE
${If} ${RunningX64}
SetRegView 64
StrCpy $DetectJRE_W "SOFTWARE\JavaSoft\Java Runtime Environment"
Call DetectJREUnder
SetRegView lastused
${If} $JREDetected == 1
StrCpy $JRE32Detected 0
StrCpy $JRE64Detected 1
Return
${EndIf}
${EndIf}
# Check for 32-bit JRE
SetRegView 32
StrCpy $DetectJRE_W "SOFTWARE\JavaSoft\Java Runtime Environment"
Call DetectJREUnder
SetRegView lastused
${If} $JREDetected == 1
StrCpy $JRE32Detected 1
StrCpy $JRE64Detected 0
Return
${EndIf}
# No JRE detected
StrCpy $JRE32Detected 0
StrCpy $JRE64Detected 0
FunctionEnd
Function DetectJREUnder
ClearErrors
ReadRegStr $0 HKLM "$DetectJRE_W" "CurrentVersion"
IfErrors not_found
StrCmp $0 "" not_found
ClearErrors
ReadRegStr $JREPath HKLM "$DetectJRE_W\$0" "JavaHome"
IfErrors not_found
StrCmp $JREPath "" not_found
StrCpy $JREDetected 1
not_found:
Return
FunctionEnd
Function DetectBindRequirements
# BIND's binaries link against the Visual C++ 2015 Redistributable. Older
# versions linked against the Visual C++ 2012 Redistributable, but current
# versions don't.
${If} ${RunningX64}
#${If} $VC2012_x86_64Detected == 0
# Push 0
# Pop $BindRequirementsMet
# StrCpy $BindRequirementsURL "https://www.microsoft.com/en-us/download/details.aspx?id=30679"
# StrCpy $BindRequirementsError "ncdns for Windows requires the Microsoft Visual C++ 2012 (64-bit) Redistributable.$\n$\nYou can download it from:$\n$BindRequirementsURL"
# Return
#${EndIf}
${If} $VC2015_x86_64Detected == 0
Push 0
Pop $BindRequirementsMet
StrCpy $BindRequirementsURL "https://www.microsoft.com/en-us/download/details.aspx?id=53587"
StrCpy $BindRequirementsError "ncdns for Windows requires the Microsoft Visual C++ 2015 (64-bit) Redistributable.$\n$\nYou can download it from:$\n$BindRequirementsURL"
Return
${EndIf}
${Else}
#${If} $VC2012_x86_32Detected == 0
# Push 0
# Pop $BindRequirementsMet
# StrCpy $BindRequirementsURL "https://www.microsoft.com/en-us/download/details.aspx?id=30679"
# StrCpy $BindRequirementsError "ncdns for Windows requires the Microsoft Visual C++ 2012 (32-bit) Redistributable.$\n$\nYou can download it from:$\n$BindRequirementsURL"
# Return
#${EndIf}
${If} $VC2015_x86_32Detected == 0
Push 0
Pop $BindRequirementsMet
StrCpy $BindRequirementsURL "https://www.microsoft.com/en-us/download/details.aspx?id=53587"
StrCpy $BindRequirementsError "ncdns for Windows requires the Microsoft Visual C++ 2015 (32-bit) Redistributable.$\n$\nYou can download it from:$\n$BindRequirementsURL"
Return
${EndIf}
${EndIf}
Push 1
Pop $BindRequirementsMet
StrCpy $BindRequirementsError ""
FunctionEnd
Function FailIfBindRequirementsNotMet
${If} $BindRequirementsMet == 0
MessageBox "MB_OK|MB_ICONSTOP" "$BindRequirementsError" /SD IDOK
IfSilent abort_silently
ExecShell "open" "$BindRequirementsURL"
abort_silently:
Abort
${EndIf}
FunctionEnd
Function DetectBitcoinJRequirements
${If} $JRE64Detected == 1
${If} $VC2010_x86_64Detected == 1
Push 1
Pop $BitcoinJRequirementsMet
StrCpy $BitcoinJRequirementsError ""
Return
${EndIf}
${EndIf}
${If} $JRE32Detected == 1
${If} $VC2010_x86_32Detected == 1
Push 1
Pop $BitcoinJRequirementsMet
StrCpy $BitcoinJRequirementsError ""
Return
${EndIf}
${EndIf}
${If} $JREDetected == 0
StrCpy $BitcoinJRequirementsError "Java must be installed"
${Else}
StrCpy $BitcoinJRequirementsError "Microsoft Visual C++ 2010 Redistributable Package must be installed"
${EndIf}
Push 0
Pop $BitcoinJRequirementsMet
FunctionEnd
Function DetectETLD
ClearErrors
${GetOptions} $CMDLINE "/ETLD=" $ETLD
IfErrors 0 found
# If not found, use this default
StrCpy $ETLD "bit"
found:
FunctionEnd
# DIALOG HELPERS
##############################################################################
Function ShowCallback
SendMessage $mui.WelcomePage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_WELCOME_INFO_TEXT)$\n$\nThis software is open source and licenced under the GPLv3 License. It is distributed WITHOUT ANY WARRANTY."
FunctionEnd
Function NamecoinDialogCreate
Call NamecoinDialog_CreateSkeleton
# Restore state
${NSD_SetState} $NamecoinDialog_Core $UseNamecoinCore
${NSD_SetState} $NamecoinDialog_ConsensusJ $UseConsensusJ
${NSD_SetState} $NamecoinDialog_Electrum $UseElectrumNMC
${If} $UseNamecoinCore == ${BST_UNCHECKED}
${AndIf} $UseConsensusJ == ${BST_UNCHECKED}
${AndIf} $UseElectrumNMC == ${BST_UNCHECKED}
${NSD_Check} $NamecoinDialog_Manual
${Else}
${NSD_Uncheck} $NamecoinDialog_Manual
${EndIf}
${If} $NamecoinCoreDetected == 1
${NSD_SetText} $NamecoinDialog_Status "An existing Namecoin Core installation was detected."
${NSD_SetText} $NamecoinDialog_Core "Automatically configure Namecoin Core (recommended)"
${If} $BitcoinJRequirementsMet == 1
${NSD_SetText} $NamecoinDialog_ConsensusJ "Install and use ConsensusJ-Namecoin instead (lighter, less secure)"
${Else}
${NSD_SetText} $NamecoinDialog_ConsensusJ "Cannot use ConsensusJ-Namecoin ($BitcoinJRequirementsError)"
EnableWindow $NamecoinDialog_ConsensusJ 0
${EndIf}
${NSD_SetText} $NamecoinDialog_Manual "I will configure Namecoin Core myself (manual configuration required)"
${Else}
${NSD_SetText} $NamecoinDialog_Status "An existing Namecoin Core installation was not detected."
${If} $BitcoinJRequirementsMet == 1
${NSD_SetText} $NamecoinDialog_Core "Install and configure Namecoin Core (heavier, more secure)"
${NSD_SetText} $NamecoinDialog_ConsensusJ "Install and use ConsensusJ-Namecoin (lighter, less secure)"
${Else}
${NSD_SetText} $NamecoinDialog_Core "Install and configure Namecoin Core (recommended)"
${NSD_SetText} $NamecoinDialog_ConsensusJ "Cannot use ConsensusJ-Namecoin ($BitcoinJRequirementsError)"
EnableWindow $NamecoinDialog_ConsensusJ 0
${EndIf}
${NSD_SetText} $NamecoinDialog_Manual "I will provide my own Namecoin node (manual configuration required)"
${EndIf}
${If} $ElectrumNMCDetected == 1
${NSD_SetText} $NamecoinDialog_Electrum "Automatically configure Electrum-NMC (lighter, less secure)"
${Else}
${NSD_SetText} $NamecoinDialog_Electrum "Install and configure Electrum-NMC (lighter, less secure)"
${EndIf}
nsDialogs::Show
FunctionEnd
Function NamecoinDialogLeave
${NSD_GetState} $NamecoinDialog_Core $UseNamecoinCore
${NSD_GetState} $NamecoinDialog_ConsensusJ $UseConsensusJ
${NSD_GetState} $NamecoinDialog_Electrum $UseElectrumNMC
FunctionEnd
Function DNSDialogCreate
Call DNSDialog_CreateSkeleton
# Restore state
${NSD_SetState} $DNSDialog_Unbound $UseUnbound
${If} $UseUnbound == ${BST_UNCHECKED}
${NSD_Check} $DNSDialog_Manual
${Else}
${NSD_Uncheck} $DNSDialog_Manual
${EndIf}
${If} $UnboundDetected == 1
${NSD_SetText} $DNSDialog_Status "An existing Unbound installation was detected."
${NSD_SetText} $DNSDialog_Unbound "Automatically configure Unbound (recommended)"
${NSD_SetText} $DNSDialog_Manual "I will configure Unbound myself (manual configuration required)"
${Else}
${NSD_SetText} $DNSDialog_Status "An existing Unbound installation was not detected."
${NSD_SetText} $DNSDialog_Unbound "Install and configure Unbound/DNSSEC Trigger (recommended)"
${NSD_SetText} $DNSDialog_Manual "I will provide my own DNS resolver (manual configuration required)"
${EndIf}
nsDialogs::Show
FunctionEnd
Function DNSDialogLeave
${NSD_GetState} $DNSDialog_Unbound $UseUnbound
FunctionEnd
Function DarknetDialogCreate
Call DarknetDialog_CreateSkeleton
${If} $TorBrowserDetected != ""
${NSD_SetText} $DarknetDialog_TorStatus "An existing Tor Browser installation was detected."
# Restore state
${NSD_SetState} $DarknetDialog_Tor $UseTorBrowser
${Else}
${NSD_SetText} $DarknetDialog_TorStatus "An existing Tor Browser installation was not detected."
${NSD_SetState} $DarknetDialog_Tor ${BST_UNCHECKED}
EnableWindow $DarknetDialog_Tor 0
${EndIf}
nsDialogs::Show
FunctionEnd
Function DarknetDialogLeave
${NSD_GetState} $DarknetDialog_Tor $UseTorBrowser
Push ""
Pop $UseTorSwitch
${If} $UseTorBrowser == ${BST_CHECKED}
Push "-use_tor"
Pop $UseTorSwitch
${EndIf}
FunctionEnd
Function TLSPositiveDialogCreate
Call TLSPositiveDialog_CreateSkeleton
# Restore state
# CertInject temporarily disabled
#${NSD_SetState} $TLSPositiveDialog_CryptoAPILayer1 $CryptoAPIInjectionEnabled
${NSD_SetState} $TLSPositiveDialog_CryptoAPILayer2 $CryptoAPIEncayaEnabled
${NSD_SetState} $TLSPositiveDialog_FirefoxNcp11Enterprise $Ncp11EnterpriseFirefoxEnabled
nsDialogs::Show
FunctionEnd
Function TLSPositiveDialogLeave
# CertInject temporarily disabled
#${NSD_GetState} $TLSPositiveDialog_CryptoAPILayer1 $CryptoAPIInjectionEnabled
${NSD_GetState} $TLSPositiveDialog_CryptoAPILayer2 $CryptoAPIEncayaEnabled
${NSD_GetState} $TLSPositiveDialog_FirefoxNcp11Enterprise $Ncp11EnterpriseFirefoxEnabled
FunctionEnd
Function TLSNegativeDialogCreate
Call TLSNegativeDialog_CreateSkeleton
# Restore state
${NSD_SetState} $TLSNegativeDialog_CryptoAPINCProp $CryptoAPINameConstraintsEnabled
nsDialogs::Show
FunctionEnd
Function TLSNegativeDialogLeave
${NSD_GetState} $TLSNegativeDialog_CryptoAPINCProp $CryptoAPINameConstraintsEnabled
FunctionEnd
# INSTALL SECTIONS
##############################################################################
Section "ncdns" Sec_ncdns
!ifdef ENABLE_LOGGING
LogSet on
!endif
SetOutPath $INSTDIR
Call LogRequirementsChecks
Call Reg
Call DNSSECTrigger
Call NamecoinCoreConfig
Call NamecoinCore
Call ElectrumNMC
Call ServiceNcdns
Call Files
Call FilesConfig
Call BitcoinJ
Call TrustConfig
Call ServiceEncaya
Call ServiceStemNS
Call FilesSecurePre
Call KeyConfigDNSSEC
Call ElectrumNMCConfig
Call FilesSecure
Call FilesSecureEncayaPre
Call KeyConfigEncaya
Call FilesSecureEncaya
Call CertInjectEncaya
Call ServiceNcdnsEventLog
Call ServiceNcdnsStart
Call ServiceEncayaEventLog
Call ServiceEncayaStart
Call UnboundConfig
Call TorBrowserConfig
Call ServiceStemNSEventLog
Call ServiceStemNSStart
AddSize 12288 # Disk space estimation.
SectionEnd
# UNINSTALL SECTIONS
##############################################################################
Section "Uninstall"
Call un.UnboundConfig
Call un.TrustConfig
Call un.ServiceNcdns
Call un.ServiceEncaya
Call un.ServiceStemNS
Call un.TrustEncayaConfig
Call un.TorBrowserConfig
Call un.Files
Call un.NamecoinCore
Call un.ElectrumNMC
Call un.BitcoinJ
Call un.DNSSECTrigger
Call un.Reg
RMDir "$INSTDIR"
SectionEnd
Function LogRequirementsChecks
${If} $JREDetected == 1
${If} $JRE32Detected == 1
DetailPrint "JRE is 32-bit."
${EndIf}
${If} $JRE64Detected == 1
DetailPrint "JRE is 64-bit."
${EndIf}
${Else}
DetailPrint "JRE was NOT detected."
${EndIf}
${If} $VC2010_x86_32Detected == 1
DetailPrint "Microsoft Visual C++ 2010 Redistributable Package 32-bit was detected."
${Else}
DetailPrint "Microsoft Visual C++ 2010 Redistributable Package 32-bit was NOT detected."
${EndIf}
${If} $VC2010_x86_64Detected == 1
DetailPrint "Microsoft Visual C++ 2010 Redistributable Package 64-bit was detected."
${Else}
DetailPrint "Microsoft Visual C++ 2010 Redistributable Package 64-bit was NOT detected."
${EndIf}
${If} $VC2012_x86_32Detected == 1
DetailPrint "Microsoft Visual C++ 2012 Redistributable Package 32-bit was detected."
${Else}
DetailPrint "Microsoft Visual C++ 2012 Redistributable Package 32-bit was NOT detected."
${EndIf}
${If} $VC2012_x86_64Detected == 1
DetailPrint "Microsoft Visual C++ 2012 Redistributable Package 64-bit was detected."
${Else}
DetailPrint "Microsoft Visual C++ 2012 Redistributable Package 64-bit was NOT detected."
${EndIf}
${If} $VC2015_x86_32Detected == 1
DetailPrint "Microsoft Visual C++ 2015 Redistributable Package 32-bit was detected."
${Else}
DetailPrint "Microsoft Visual C++ 2015 Redistributable Package 32-bit was NOT detected."
${EndIf}
${If} $VC2015_x86_64Detected == 1
DetailPrint "Microsoft Visual C++ 2015 Redistributable Package 64-bit was detected."
${Else}
DetailPrint "Microsoft Visual C++ 2015 Redistributable Package 64-bit was NOT detected."
${EndIf}
${If} $BitcoinJRequirementsMet == 1
DetailPrint "BitcoinJ can be installed."
${Else}
DetailPrint "$BitcoinJRequirementsError before BitcoinJ can be installed."
${EndIf}
DetailPrint "Using eTLD $ETLD."
FunctionEnd
# REGISTRY AND UNINSTALL INFORMATION INSTALLATION/UNINSTALLATION
##############################################################################
Function Reg
WriteRegStr HKLM "Software\Namecoin\ncdns" "InstallPath" "$INSTDIR"
# Uninstall information.
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "DisplayName" "Namecoin ncdns"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "DisplayVersion" "${NCDNS_PRODVER}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "UninstallString" '"$INSTDIR\uninst.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "QuietUninstallString" '"$INSTDIR\uninst.exe" /S'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "DisplayIcon" "$INSTDIR\namecoin.ico"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "Publisher" "Namecoin Project"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "HelpLink" "https://www.namecoin.org/"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "URLInfoAbout" "https://www.namecoin.org/"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "NoRepair" 1
FunctionEnd
Function un.Reg
DeleteRegKey HKLM "Software\Namecoin\ncdns"
DeleteRegKey HKLM "System\CurrentControlSet\Services\EventLog\Application\ncdns"
DeleteRegKey HKLM "System\CurrentControlSet\Services\EventLog\Application\encaya"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns"
FunctionEnd
# DNSSEC TRIGGER CHAIN INSTALLATION
##############################################################################
Function DNSSECTrigger
!ifndef NO_DNSSEC_TRIGGER
${If} $UnboundDetected == 1
# Already have Unbound
DetailPrint "An existing Unbound installation was detected. Not installing."
Return
${EndIf}
${If} $UseUnbound == ${BST_UNCHECKED}
DetailPrint "Not installing DNSSEC Trigger."
Return
${EndIf}
# Install DNSSEC Trigger
DetailPrint "Installing DNSSEC Trigger..."
File /oname=$PLUGINSDIR\dnssec_trigger_setup.exe ${ARTIFACTS}\${DNSSEC_TRIGGER_FN}
again:
IfSilent install_silent
# Install with NSIS GUI
ExecWait '"$PLUGINSDIR\dnssec_trigger_setup.exe"'
Goto detect
install_silent:
ExecWait '"$PLUGINSDIR\dnssec_trigger_setup.exe" /S'
detect:
Call DetectUnbound
${If} $UnboundDetected == 0
DetailPrint "DNSSEC Trigger was not installed correctly."
MessageBox "MB_OKCANCEL|MB_ICONSTOP" "DNSSEC Trigger was not installed correctly. Press OK to retry or Cancel to abort the installer." /SD IDCANCEL IDOK again
Abort
${EndIf}
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "ncdns_InstalledDNSSECTrigger" 1
Delete /REBOOTOK $PLUGINSDIR\dnssec_trigger_setup.exe
!endif
FunctionEnd
Function un.DNSSECTrigger
!ifndef NO_DNSSEC_TRIGGER
# Determine if we were responsible for installing DNSSEC Trigger; if so, we
# should offer to uninstall it.
ClearErrors
ReadRegDWORD $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "ncdns_InstalledDNSSECTrigger"
IfErrors done
IntCmp $0 0 done
# Detect DNSSEC Trigger uninstall command. If we cannot find it, don't offer
# to uninstall it, as we don't know how.
ClearErrors
ReadRegStr $DNSSECTriggerUninstallCommand HKLM "Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "QuietUninstallString"
IfErrors 0 found
ReadRegStr $DNSSECTriggerUninstallCommand HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "QuietUninstallString"
IfErrors 0 found
Goto done
found:
# Ask the user if they want to uninstall DNSSEC Trigger.
MessageBox MB_YESNO|MB_ICONQUESTION "When you installed ncdns for Windows, DNSSEC Trigger was installed automatically as a necessary dependency of ncdns for Windows. Would you like to remove it? If you leave it in place, you will not be able to connect to .bit domains, but will still enjoy DNSSEC-secured domain name lookups.$\n$\nSelect Yes to remove DNSSEC Trigger." /SD IDYES IDYES 0 IDNO done
# Uninstall DNSSEC Trigger.
DetailPrint "Uninstalling DNSSEC Trigger... $DNSSECTriggerUninstallCommand"
ExecWait $DNSSECTriggerUninstallCommand
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ncdns" "ncdns_InstalledDNSSECTrigger"
done:
# Didn't install/not uninstalling DNSSEC Trigger.
!endif
FunctionEnd
# NAMECOIN CORE CONFIG
##############################################################################
Function NamecoinCoreConfig
${If} $UseNamecoinCore == ${BST_UNCHECKED}
DetailPrint "Not configuring Namecoin Core."
Return
${EndIf}
DetailPrint "Configuring Namecoin Core..."
# We need the current user's $APPDATA for configuring Namecoin Core.
SetShellVarContext current
# We have to set 'server=1' in namecoin.conf. We can use cookies to get the
# rest, so that's all we need.
#
# The Namecoin Core installer provides the user an option to launch Namecoin
# Core at the end. Therefore, we must do this before we launch the Namecoin Core
# installer.
#
ClearErrors
ReadRegStr $NamecoinCoreDataDir HKCU "Software\Namecoin\Namecoin-Qt" "strDataDir"
IfErrors 0 haveDataDir
# We need to set the data directory pre-emptively so we can put a new namecoin.conf
# there.
StrCpy $NamecoinCoreDataDir "$APPDATA\Namecoin"
WriteRegStr HKCU "Software\Namecoin\Namecoin-Qt" "strDataDir" $NamecoinCoreDataDir
haveDataDir:
DetailPrint 'Creating directory "$NamecoinCoreDataDir"...'
CreateDirectory $NamecoinCoreDataDir
# Configure cookie directory.
CreateDirectory C:\ProgramData\NamecoinCookie
${ExecToLog} 'icacls "C:\ProgramData\NamecoinCookie" /inheritance:r /T /grant "${SID_SYSTEM}:(OI)(CI)F" "${SID_ADMINISTRATORS}:(OI)(CI)F" "${SID_USERS}:(OI)(CI)F"'
Pop $CoreCookieDirReturnCode
${If} $CoreCookieDirReturnCode != 0
DetailPrint "Failed to set ACL on Namecoin Core cookie directory: return code $CoreCookieDirReturnCode"
MessageBox "MB_OK|MB_ICONSTOP" "Failed to set ACL on Namecoin Core cookie directory." /SD IDOK
Abort
${EndIf}
${ExecToLog} 'icacls "C:\ProgramData\NamecoinCookie\.cookie" /reset'
Pop $CoreCookieFileReturnCode
# The cookie file might not exist, which will yield return code 2.
# See https://github.com/MicrosoftDocs/windowsserverdocs/issues/3303
${IfNot} $CoreCookieFileReturnCode == 0
${AndIfNot} $CoreCookieFileReturnCode == 2
DetailPrint "Failed to set ACL on Namecoin Core cookie file: return code $CoreCookieFileReturnCode"
MessageBox "MB_OK|MB_ICONSTOP" "Failed to set ACL on Namecoin Core cookie file." /SD IDOK
Abort
${EndIf}
# Now we need to make sure namecoin.conf exists and has 'server=1'.
# We'll do this with a powershell script, much as we do for configuring Unbound.
# Execute confignamecoinconf.ps1.
File /oname=$PLUGINSDIR\confignamecoinconf.ps1 confignamecoinconf.ps1
${ExecToLog} 'powershell -executionpolicy bypass -inputformat none -noninteractive -file "$PLUGINSDIR\confignamecoinconf.ps1" -data_dir "$NamecoinCoreDataDir" $UseTorSwitch'
Delete $PLUGINSDIR\confignamecoinconf.ps1
# Restore SetShellVarContext
SetShellVarContext all
FunctionEnd
# NAMECOIN CORE CHAIN INSTALLATION
##############################################################################
Function NamecoinCore
!ifndef NO_NAMECOIN_CORE
${If} $NamecoinCoreDetected == 1
# Already have Namecoin Core
DetailPrint "An existing Namecoin Core installation was detected. Not installing."
Return
${EndIf}
DetailPrint "An existing Namecoin Core installation was NOT detected."
${If} $UseNamecoinCore == ${BST_UNCHECKED}
DetailPrint "Not installing Namecoin Core."
Return