Merge pull request #194 from gnh1201/dev

Update the installer profile, Dns Query, and namespaces
This commit is contained in:
Namhyeon Go 2025-03-20 11:29:15 +09:00 committed by GitHub
commit f6b222e469
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 97 additions and 25 deletions

View File

@ -43,12 +43,12 @@
this.runAsAdministratorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.globalSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startCodeEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openMicrosoftCopilotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.openLauncherToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openCodeEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openMicrosoftCopilotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
@ -184,11 +184,18 @@
this.startCodeEditorToolStripMenuItem.Text = "Start the code editor...";
this.startCodeEditorToolStripMenuItem.Click += new System.EventHandler(this.startCodeEditorToolStripMenuItem_Click);
//
// openMicrosoftCopilotToolStripMenuItem
//
this.openMicrosoftCopilotToolStripMenuItem.Name = "openMicrosoftCopilotToolStripMenuItem";
this.openMicrosoftCopilotToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.openMicrosoftCopilotToolStripMenuItem.Text = "Open Microsoft Copilot...";
this.openMicrosoftCopilotToolStripMenuItem.Click += new System.EventHandler(this.openMicrosoftCopilotToolStripMenuItem_Click);
//
// notifyIcon1
//
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = global::WelsonJS.Launcher.Properties.Resources.favicon;
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Text = "WelsonJS Launcher";
//
// contextMenuStrip1
//
@ -218,13 +225,6 @@
this.exitToolStripMenuItem.Size = new System.Drawing.Size(198, 22);
this.exitToolStripMenuItem.Text = "Exit";
//
// openMicrosoftCopilotToolStripMenuItem
//
this.openMicrosoftCopilotToolStripMenuItem.Name = "openMicrosoftCopilotToolStripMenuItem";
this.openMicrosoftCopilotToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.openMicrosoftCopilotToolStripMenuItem.Text = "Open Microsoft Copilot...";
this.openMicrosoftCopilotToolStripMenuItem.Click += new System.EventHandler(this.openMicrosoftCopilotToolStripMenuItem_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);

View File

@ -5,6 +5,7 @@ using System.IO.Compression;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Windows.Forms;
using WelsonJS.Launcher.Tools;
namespace WelsonJS.Launcher
{

View File

@ -3,6 +3,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using WelsonJS.Launcher.Tools;
namespace WelsonJS.Launcher
{

View File

@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Linq;
namespace WelsonJS.Launcher
namespace WelsonJS.Launcher.Tools
{
public class DnsQuery
{
private static readonly Random _random = new Random();
private readonly string _dnsServer;
private const int DnsPort = 53;
private const int Timeout = 5000;
@ -52,6 +54,21 @@ namespace WelsonJS.Launcher
{
List<string> records = new List<string>();
// Validate domain format
if (string.IsNullOrWhiteSpace(domain))
{
records.Add("Error: Domain cannot be empty");
return records;
}
// Basic domain format validation
if (domain.Length > 255 ||
!domain.Split('.').All(part => part.Length > 0 && part.Length <= 63))
{
records.Add("Error: Invalid domain format");
return records;
}
try
{
UdpClient udpClient = new UdpClient(_dnsServer, DnsPort);
@ -76,11 +93,10 @@ namespace WelsonJS.Launcher
private byte[] CreateDnsQuery(string domain, ushort type)
{
Random rand = new Random();
byte[] query = new byte[512];
query[0] = (byte)rand.Next(0, 256);
query[1] = (byte)rand.Next(0, 256);
query[0] = (byte)_random.Next(0, 256);
query[1] = (byte)_random.Next(0, 256);
query[2] = 0x01;
query[3] = 0x00;
query[4] = 0x00;
@ -114,6 +130,24 @@ namespace WelsonJS.Launcher
{
List<string> results = new List<string>();
// Check response code from DNS server
int responseCode = response[3] & 0x0F;
if (responseCode != 0)
{
string errorMessage = "DNS server returned error: ";
switch (responseCode)
{
case 1: errorMessage += "Format Error"; break;
case 2: errorMessage += "Server Failure"; break;
case 3: errorMessage += "Name Error (Domain does not exist)"; break;
case 4: errorMessage += "Not Implemented"; break;
case 5: errorMessage += "Refused"; break;
default: errorMessage += $"Unknown Error ({responseCode})"; break;
}
results.Add(errorMessage);
return results;
}
int answerCount = (response[6] << 8) | response[7];
if (answerCount == 0)
{
@ -193,10 +227,38 @@ namespace WelsonJS.Launcher
results.Add($"SRV: Priority {prioritySrv}, Weight {weight}, Port {port}, Target {target}");
break;
case 35:
results.Add($"NAPTR: {BitConverter.ToString(data)}");
if (data.Length >= 7)
{
ushort order = (ushort)((data[0] << 8) | data[1]);
ushort preference = (ushort)((data[2] << 8) | data[3]);
// Extract flags, services, regexp and replacement
results.Add($"NAPTR: Order {order}, Preference {preference}");
}
else
{
results.Add($"NAPTR: Invalid data length: {BitConverter.ToString(data)}");
}
break;
case 257:
results.Add($"CAA: {BitConverter.ToString(data)}");
if (data.Length >= 2)
{
byte flags = data[0];
int tagLen = data[1];
if (data.Length >= 2 + tagLen)
{
string tag = Encoding.ASCII.GetString(data, 2, tagLen);
string value = Encoding.ASCII.GetString(data, 2 + tagLen, data.Length - 2 - tagLen);
results.Add($"CAA: Flags {flags}, Tag {tag}, Value {value}");
}
else
{
results.Add($"CAA: Invalid data length: {BitConverter.ToString(data)}");
}
}
else
{
results.Add($"CAA: Invalid data length: {BitConverter.ToString(data)}");
}
break;
default:
results.Add($"Unknown Type {recordType}: {BitConverter.ToString(data)}");

View File

@ -7,7 +7,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace WelsonJS.Launcher
namespace WelsonJS.Launcher.Tools
{
public class ExecutablesCollector
{

View File

@ -11,7 +11,7 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
namespace WelsonJS.Launcher
namespace WelsonJS.Launcher.Tools
{
public class ResourceServer
{
@ -291,7 +291,7 @@ namespace WelsonJS.Launcher
private byte[] GetResource(string resourceName)
{
// Try to fetch embedded resource.
byte[] data = GetEmbeddedResource(typeof(ResourceServer).Namespace + "." + resourceName);
byte[] data = GetEmbeddedResource(typeof(Program).Namespace + "." + resourceName);
if (data != null) return data;
// Fallback: Try to fetch resource from ResourceManager.

View File

@ -72,14 +72,14 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="DnsQuery.cs" />
<Compile Include="Tools\DnsQuery.cs" />
<Compile Include="EnvForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="EnvForm.Designer.cs">
<DependentUpon>EnvForm.cs</DependentUpon>
</Compile>
<Compile Include="ExecutablesCollector.cs" />
<Compile Include="Tools\ExecutablesCollector.cs" />
<Compile Include="InstancesForm.cs">
<SubType>Form</SubType>
</Compile>
@ -100,7 +100,7 @@
<Compile Include="GlobalSettingsForm.Designer.cs">
<DependentUpon>GlobalSettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="ResourceServer.cs" />
<Compile Include="Tools\ResourceServer.cs" />
<EmbeddedResource Include="EnvForm.resx">
<DependentUpon>EnvForm.cs</DependentUpon>
</EmbeddedResource>

View File

@ -1,5 +1,5 @@
; @created_on 2020-06-26
; @updated_on 2024-07-30
; @updated_on 2025-03-20
; @author Namhyeon Go (Catswords Research) <abuse@catswords.net>
[Setup]
@ -41,8 +41,10 @@ Source: "*.md"; DestDir: "{app}";
Source: "bootstrap.bat"; DestDir: "{app}";
Source: "uriloader.js"; DestDir: "{app}";
Source: "webloader.js"; DestDir: "{app}";
Source: "testloader.js"; DestDir: "{app}";
Source: "bootstrap.js"; DestDir: "{app}";
Source: "scriptcontrol.js"; DestDir: "{app}";
Source: "settings.example.ini"; DestDir: "{app}";
Source: "defaultService.example.js"; DestDir: "{app}";
Source: "app\*"; DestDir: "{app}/app"; Flags: ignoreversion recursesubdirs;
Source: "lib\*"; DestDir: "{app}/lib"; Flags: ignoreversion recursesubdirs;
Source: "bin\*"; DestDir: "{app}/bin"; Flags: ignoreversion recursesubdirs;
@ -53,16 +55,22 @@ Source: "data\*"; DestDir: "{app}/data"; Flags: ignoreversion recursesubdirs;
[Dirs]
Name: "{app}\tmp";
[InstallDelete]
Type: files; Name: "{app}\settings.ini"
Type: files; Name: "{app}\defaultService.js"
[Icons]
Name: "{group}\Start {cm:AppName}"; Filename: "{app}\bootstrap.bat"; AfterInstall: SetElevationBit('{group}\Start {cm:AppName}.lnk');
Name: "{group}\{cm:AppName} Launcher"; Filename: "{app}\bin\x86\WelsonJS.Launcher.exe"; AfterInstall: SetElevationBit('{group}\{cm:AppName} Launcher.lnk');
Name: "{group}\Uninstall {cm:AppName}"; Filename: "{uninstallexe}"; AfterInstall: SetElevationBit('{group}\Uninstall {cm:AppName}.lnk');
[Run]
; Filename: {app}\bin\gtk2-runtime-2.24.33-2021-01-30-ts-win64.exe;
; Filename: {app}\bin\nmap-7.92\VC_redist.x86.exe;
; Filename: {app}\bin\nmap-7.92\npcap-1.50.exe;
Filename: "{cmd}"; Parameters: "/C rename "{app}\settings.example.ini" "settings.ini""; Flags: runhidden
Filename: "{cmd}"; Parameters: "/C rename "{app}\defaultService.example.js" "defaultService.js""; Flags: runhidden
Filename: {app}\installService.bat;
Filename: {app}\bootstrap.bat;
Filename: {app}\bin\x86\WelsonJS.Launcher.exe;
[UninstallRun]
; Filename: {code:GetProgramFiles}\GTK2-Runtime Win64\gtk2_runtime_uninst.exe;