Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "advanced-portchecker",
"private": true,
"version": "2.1.0",
"version": "2.2.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -24,7 +24,7 @@
"@tauri-apps/plugin-os": "^2.2.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-router-dom": "^7.5.0"
"react-router-dom": "^7.5.1"
},
"devDependencies": {
"@eslint/js": "^9.24.0",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "advanced-portchecker"
version = "2.1.0"
version = "2.2.0"
description = "A lightweight TCP/IP port scanner with an intuitive UI."
authors = ["CodeDead <admin@codedead.com>"]
license = "GPL-3.0-only"
Expand Down
10 changes: 10 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::sync::{Arc, Mutex};
use std::thread::available_parallelism;
use std::time::Duration;
use std::{fs, thread};
use tauri::Manager;

mod result;

Expand All @@ -26,6 +27,15 @@ fn main() {
};

tauri::Builder::default()
.setup(|app| {
#[cfg(debug_assertions)] // only include this code on debug builds
{
let window = app.get_webview_window("main").unwrap();
window.open_devtools();
window.close_devtools();
}
Ok(())
})
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_dialog::init())
.manage(shared_state)
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"productName": "advanced-portchecker",
"mainBinaryName": "advanced-portchecker",
"version": "2.1.0",
"version": "2.2.0",
"identifier": "com.codedead.advancedportchecker",
"plugins": {},
"app": {
Expand Down
11 changes: 7 additions & 4 deletions src/components/Layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { Suspense, useContext, useEffect } from 'react';
import Box from '@mui/material/Box';
import CssBaseline from '@mui/material/CssBaseline';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { platform } from '@tauri-apps/plugin-os';
import { getVersion } from '@tauri-apps/api/app';
import { platform, arch } from '@tauri-apps/plugin-os';
import { Outlet } from 'react-router-dom';
import packageJson from '../../../package.json';
import { MainContext } from '../../contexts/MainContextProvider';
import {
getNumberOfThreads,
Expand Down Expand Up @@ -49,7 +49,7 @@ const Layout = () => {
/**
* Check for updates
*/
const checkForUpdates = () => {
const checkForUpdates = async () => {
if (loading) {
return;
}
Expand All @@ -59,7 +59,10 @@ const Layout = () => {

try {
const res = platform();
Updater(res.toLowerCase(), packageJson.version)
const archRes = arch();
const ver = 'v' + (await getVersion());

Updater(res.toLowerCase(), archRes.toLowerCase(), ver)
.then((up) => {
d1(setUpdate(up));
})
Expand Down
11 changes: 7 additions & 4 deletions src/routes/Settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import RadioGroup from '@mui/material/RadioGroup';
import Select from '@mui/material/Select';
import TextField from '@mui/material/TextField';
import Typography from '@mui/material/Typography';
import { platform } from '@tauri-apps/plugin-os';
import packageJson from '../../../package.json';
import { getVersion } from '@tauri-apps/api/app';
import { platform, arch } from '@tauri-apps/plugin-os';
import AlertDialog from '../../components/AlertDialog';
import GridList from '../../components/GridList';
import Theme from '../../components/Theme';
Expand Down Expand Up @@ -146,7 +146,7 @@ const Settings = () => {
/**
* Check for updates
*/
const checkForUpdates = () => {
const checkForUpdates = async () => {
if (loading) {
return;
}
Expand All @@ -156,7 +156,10 @@ const Settings = () => {

try {
const res = platform();
Updater(res.toLowerCase(), packageJson.version)
const archRes = arch();
const ver = 'v' + (await getVersion());

Updater(res.toLowerCase(), archRes.toLowerCase(), ver)
.then((up) => {
d1(setUpdate(up));
d1(setCheckedForUpdates(true));
Expand Down
83 changes: 44 additions & 39 deletions src/utils/Updater/index.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,62 @@
const Updater = (os, currentVersion) => {
const Updater = (os, architectureName, currentVersion) => {
/**
* Check whether version b is newer than version a
* @param a Version a
* @param b Version b
* @returns {boolean} True if version b is newer than version a, otherwise false
* Compare two semantic versions
* @param ver1 Version 1
* @param ver2 Version 2
* @returns {number} 1 if ver1 > ver2, -1 if ver1 < ver2, 0 if equal
*/
const isNewer = (a, b) => {
const partsA = a.split('.');
const partsB = b.split('.');
const numParts =
partsA.length > partsB.length ? partsA.length : partsB.length;
const semverCompare = (ver1, ver2) => {
const v1Parts = ver1.slice(1).split('.').map(Number);
const v2Parts = ver2.slice(1).split('.').map(Number);

for (let i = 0; i < numParts; i += 1) {
if ((parseInt(partsB[i], 10) || 0) !== (parseInt(partsA[i], 10) || 0)) {
return (parseInt(partsB[i], 10) || 0) > (parseInt(partsA[i], 10) || 0);
}
for (let i = 0; i < 3; i++) {
if (v1Parts[i] > v2Parts[i]) return 1;
if (v1Parts[i] < v2Parts[i]) return -1;
}

return false;
return 0;
};

/**
* Parse the information inside an external update
* @param update The update data
* @returns {{infoUrl: null, updateUrl: boolean, downloadUrl: null, version: null}}
* Parse the update data
* @param data The update data
* @returns {{updateUrl, infoUrl: *, version: SemVer, updateAvailable: boolean}} The parsed update data
*/
const parseUpdate = (update) => {
const platform = update.platforms[os];
const data = {
updateUrl: false,
downloadUrl: null,
infoUrl: null,
version: null,
};
const parseUpdate = (data) => {
const platform = data.platforms.find(
(p) => p.platformName.toLowerCase() === os.toLowerCase(),
);
if (!platform) {
throw new Error(`Platform ${os} not found`);
}

if (
isNewer(
currentVersion,
`${platform.version.majorVersion}.${platform.version.minorVersion}.${platform.version.buildVersion}.${platform.version.revisionVersion}`,
)
) {
data.updateAvailable = true;
// Find the architecture
const architecture = platform.architectures.find(
(a) => a.name === architectureName,
);
if (!architecture) {
throw new Error(
`Architecture ${architectureName} not found for platform ${os}`,
);
}

data.updateUrl = platform.updateUrl;
data.infoUrl = platform.infoUrl;
data.version = `${platform.version.majorVersion}.${platform.version.minorVersion}.${platform.version.buildVersion}.${platform.version.revisionVersion}`;
// Sort releases by semver in descending order
const sortedReleases = architecture.releases.sort((a, b) => {
return semverCompare(b.semver, a.semver);
});

return data;
return {
updateUrl: sortedReleases[0].downloadUrl,
infoUrl: sortedReleases[0].infoUrl,
version: sortedReleases[0].semver,
updateAvailable:
semverCompare(currentVersion, sortedReleases[0].semver) < 0,
};
};

return new Promise((resolve, reject) => {
fetch('https://codedead.com/Software/Advanced%20PortChecker/version.json')
fetch(
'https://api.codedead.com/api/v1/applications/47cd7e8f-2744-443c-850e-619df5d5c43f',
)
.then((res) => {
if (!res.ok) {
throw Error(res.statusText);
Expand Down
34 changes: 13 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2727,13 +2727,6 @@ __metadata:
languageName: node
linkType: hard

"@types/cookie@npm:^0.6.0":
version: 0.6.0
resolution: "@types/cookie@npm:0.6.0"
checksum: 10c0/5b326bd0188120fb32c0be086b141b1481fec9941b76ad537f9110e10d61ee2636beac145463319c71e4be67a17e85b81ca9e13ceb6e3bb63b93d16824d6c149
languageName: node
linkType: hard

"@types/eslint@npm:^8.4.5":
version: 8.56.12
resolution: "@types/eslint@npm:8.56.12"
Expand Down Expand Up @@ -3013,7 +3006,7 @@ __metadata:
prettier: "npm:^3.5.3"
react: "npm:^19.1.0"
react-dom: "npm:^19.1.0"
react-router-dom: "npm:^7.5.0"
react-router-dom: "npm:^7.5.1"
vite: "npm:^6.3.1"
vite-plugin-eslint: "npm:^1.8.1"
vite-plugin-svgr: "npm:^4.3.0"
Expand Down Expand Up @@ -3712,9 +3705,9 @@ __metadata:
linkType: hard

"electron-to-chromium@npm:^1.5.73":
version: 1.5.137
resolution: "electron-to-chromium@npm:1.5.137"
checksum: 10c0/678613e0a3d023563a1acca4d8103a69d389168efeb3b78c1fcc683ed0778d81bfb00c6f621d6535f3fa9530664fc948fc8f2ed27e7548d46cd3987d4b0add6a
version: 1.5.138
resolution: "electron-to-chromium@npm:1.5.138"
checksum: 10c0/f8e8b334857c3f858bb9ba1fa78b211e4174682fcc62316669a7cad6c86bbd01883a6433841b32effec694f90542bc439f28926826bb7e48d285ba951b4772ec
languageName: node
linkType: hard

Expand Down Expand Up @@ -5900,23 +5893,22 @@ __metadata:
languageName: node
linkType: hard

"react-router-dom@npm:^7.5.0":
version: 7.5.0
resolution: "react-router-dom@npm:7.5.0"
"react-router-dom@npm:^7.5.1":
version: 7.5.1
resolution: "react-router-dom@npm:7.5.1"
dependencies:
react-router: "npm:7.5.0"
react-router: "npm:7.5.1"
peerDependencies:
react: ">=18"
react-dom: ">=18"
checksum: 10c0/30fccb394869cf316d005367d55162401e650fdd146c53273e218ca7c7e42e539130ee663d0c5fbf546005bea6ee9bc5ce91b6698fd24b9282a2d13c6d951609
checksum: 10c0/52446158f883b599385f4feb2e11491440b350bc67e3b39b9eb79f76c20706075c813c3f9383b24a56a24dc2f22e9ee1c9910019b775248aa99485bcb6933e0e
languageName: node
linkType: hard

"react-router@npm:7.5.0":
version: 7.5.0
resolution: "react-router@npm:7.5.0"
"react-router@npm:7.5.1":
version: 7.5.1
resolution: "react-router@npm:7.5.1"
dependencies:
"@types/cookie": "npm:^0.6.0"
cookie: "npm:^1.0.1"
set-cookie-parser: "npm:^2.6.0"
turbo-stream: "npm:2.4.0"
Expand All @@ -5926,7 +5918,7 @@ __metadata:
peerDependenciesMeta:
react-dom:
optional: true
checksum: 10c0/fc1b4ed3eeb615f40727b81dfab7469429a0b662bff5f91434966751d48ce4b470d9627dcbc93dad9b1a535a0f9bd1b2267d8ff88ca4e636535bcbfe7d76cea3
checksum: 10c0/54e9f77ede0bf36c12685a59c5d965f77f2223d01cd922ce7b6ef4f8fa5435e66c796f9f5da3487bde0cb98dadd64f5a406696d4f52e031af812857aaab0f76b
languageName: node
linkType: hard

Expand Down