diff --git a/.github/workflows/build-rel.yml b/.github/workflows/build-rel.yml index 7523321..02c6095 100644 --- a/.github/workflows/build-rel.yml +++ b/.github/workflows/build-rel.yml @@ -21,7 +21,14 @@ jobs: with: dotnet-version: '8.0.x' - name: Build Preparation - run: ./assets/IspInfo/getispinfo.sh + run: | + chmod +x ./assets/IspInfo/getispinfo.sh + ./assets/IspInfo/getispinfo.sh + - name: Prepare Build Job + uses: actions/upload-artifact@v4 + with: + name: isp + path: assets/IspInfo/*.xml build: strategy: @@ -31,6 +38,13 @@ jobs: needs: address steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - uses: actions/download-artifact@v4 + with: + name: isp + path: assets/IspInfo - name: Solution Compilation run: dotnet build --configuration Release - name: Testing diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65626f0..d77c436 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: jobs: address: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -21,7 +21,14 @@ jobs: with: dotnet-version: '8.0.x' - name: Build Preparation - run: ./assets/IspInfo/getispinfo.ps1 + run: | + chmod +x ./assets/IspInfo/getispinfo.sh + ./assets/IspInfo/getispinfo.sh + - name: Prepare Build Job + uses: actions/upload-artifact@v4 + with: + name: isp + path: assets/IspInfo/*.xml build: strategy: @@ -31,6 +38,13 @@ jobs: needs: address steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - uses: actions/download-artifact@v4 + with: + name: isp + path: assets/IspInfo - name: Solution Compilation run: dotnet build --configuration Debug - name: Testing diff --git a/Nettify/MailAddress/IspTools.cs b/Nettify/MailAddress/IspTools.cs index df10006..8ff3946 100644 --- a/Nettify/MailAddress/IspTools.cs +++ b/Nettify/MailAddress/IspTools.cs @@ -21,6 +21,7 @@ using System; using System.IO; using System.Net; +using System.Reflection; using System.Text; using System.Xml.Serialization; @@ -35,33 +36,18 @@ public static class IspTools /// Gets the ISP configuration for the specified mail address /// /// The mail address to parse. Must include the ISP hostname. - /// Whether to use the Thunderbird staging server /// The ISP client config for specified mail address - public static ClientConfig GetIspConfig(string address, bool staging = false) + public static ClientConfig GetIspConfig(string address) { - // Database addresses - string databaseAddress = "https://autoconfig.thunderbird.net/v1.1/"; - string stagingDatabaseAddress = "https://autoconfig-stage.thunderbird.net/v1.1/"; - // Get the final database address string hostName = new Uri($"mailto:{address}").Host; - string finalDatabaseAddress = $"{databaseAddress}{hostName}"; - if (staging) - finalDatabaseAddress = $"{stagingDatabaseAddress}{hostName}"; - - // Apparently, the XML documents grabbed from the database don't have this below XML header - StringBuilder xmlBuilder = new StringBuilder(); - xmlBuilder.AppendLine(""); - - // Get the XML document for the ISP - WebClient client = new WebClient(); - xmlBuilder.AppendLine(client.DownloadString(finalDatabaseAddress)); - string xmlContent = xmlBuilder.ToString(); + var xmlStream = Assembly.GetAssembly(typeof(IspTools)).GetManifestResourceStream($"Nettify.{hostName}.xml"); + string xmlContent = new StreamReader(xmlStream).ReadToEnd(); // Get the client config ClientConfig clientConfig; - XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClientConfig), new XmlRootAttribute("clientConfig") { IsNullable = false }); - StringReader sr = new StringReader(xmlContent); + XmlSerializer xmlSerializer = new(typeof(ClientConfig), new XmlRootAttribute("clientConfig") { IsNullable = false }); + StringReader sr = new(xmlContent); clientConfig = (ClientConfig)xmlSerializer.Deserialize(sr); return clientConfig; } diff --git a/Nettify/Nettify.csproj b/Nettify/Nettify.csproj index 8b7c4f9..15349a6 100644 --- a/Nettify/Nettify.csproj +++ b/Nettify/Nettify.csproj @@ -25,6 +25,10 @@ ..\aptivi_snk.snk + + + + True @@ -50,4 +54,8 @@ + + + +