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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/contexts/MainContextProvider/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const colorOnDark = localStorage.colorOnDark ? (localStorage.colorOnDark === 'tr
const threads = localStorage.threads ? parseFloat(localStorage.threads) : 1;
const timeout = localStorage.timeout ? parseFloat(localStorage.timeout) : 250;
const noClosed = localStorage.noClosed ? (localStorage.noClosed === 'true') : false;
const exportNoClosed = localStorage.exportNoClosed ? (localStorage.exportNoClosed === 'true') : true;
const sort = localStorage.sort ? (localStorage.sort === 'true') : true;
const themeToggle = localStorage.themeToggle ? (localStorage.themeToggle === 'true') : true;

Expand Down Expand Up @@ -45,6 +46,7 @@ const initState = {
threads,
timeout,
noClosed,
exportNoClosed,
sort,
scanResults: null,
themeToggle,
Expand Down
3 changes: 2 additions & 1 deletion src/languages/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"export": "Export",
"exportSuccessful": "Export successful",
"runningLatestVersion": "You are running the latest version.",
"themeToggleInTopBar": "Toggle theme in top bar"
"themeToggleInTopBar": "Toggle theme in top bar",
"exportIncludeClosedPorts": "Include closed ports in exports"
}
3 changes: 2 additions & 1 deletion src/languages/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"export": "Exportar",
"exportSuccessful": "Exportación exitosa",
"runningLatestVersion": "Estás ejecutando la última versión.",
"themeToggleInTopBar": "Alternar tema en la barra superior"
"themeToggleInTopBar": "Alternar tema en la barra superior",
"exportIncludeClosedPorts": "Incluir puertos cerrados en las exportaciones"
}
3 changes: 2 additions & 1 deletion src/languages/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"export": "Exporter",
"exportSuccessful": "Exportation réussie",
"runningLatestVersion": "Vous utilisez la dernière version.",
"themeToggleInTopBar": "Basculer le thème dans la barre supérieure"
"themeToggleInTopBar": "Basculer le thème dans la barre supérieure",
"exportIncludeClosedPorts": "Inclure les ports fermés dans les exportations"
}
3 changes: 2 additions & 1 deletion src/languages/it_it.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"export": "Export",
"exportSuccessful": "Esportazione completata",
"runningLatestVersion": "La versione in uso è aggiornata.",
"themeToggleInTopBar": "Attiva/disattiva tema nella barra superiore"
"themeToggleInTopBar": "Attiva/disattiva tema nella barra superiore",
"exportIncludeClosedPorts": "Includi porte chiuse nelle esportazioni"
}
3 changes: 2 additions & 1 deletion src/languages/nl_nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"export": "Exporteren",
"exportSuccessful": "Exporteren succesvol",
"runningLatestVersion": "U gebruikt de laatste versie.",
"themeToggleInTopBar": "Thema toggle in de bovenste balk"
"themeToggleInTopBar": "Thema toggle in de bovenste balk",
"exportIncludeClosedPorts": "Gesloten poorten opnemen in export"
}
3 changes: 2 additions & 1 deletion src/languages/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"export": "导出",
"exportSuccessful": "导出成功",
"runningLatestVersion": "已是最新版本!",
"themeToggleInTopBar": "在顶部栏显示明暗主题切换"
"themeToggleInTopBar": "在顶部栏显示明暗主题切换",
"exportIncludeClosedPorts": "导出时包含关闭的端口"
}
1 change: 1 addition & 0 deletions src/reducers/MainReducer/Actions/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export const SET_NO_CLOSED = 'SET_NO_CLOSED';
export const SET_SORT = 'SET_SORT';
export const SET_SCAN_RESULTS = 'SET_SCAN_RESULTS';
export const SET_THEME_TOGGLE = 'SET_THEME_TOGGLE';
export const SET_EXPORT_NO_CLOSED = 'SET_EXPORT_NO_CLOSED';
6 changes: 6 additions & 0 deletions src/reducers/MainReducer/Actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SET_COLOR_ON_DARK,
SET_END_PORT,
SET_ERROR,
SET_EXPORT_NO_CLOSED,
SET_IS_SCANNING,
SET_LANGUAGE_INDEX,
SET_LOADING,
Expand Down Expand Up @@ -151,3 +152,8 @@ export const setThemeToggle = (value) => ({
type: SET_THEME_TOGGLE,
payload: value,
});

export const setExportNoClosed = (value) => ({
type: SET_EXPORT_NO_CLOSED,
payload: value,
});
8 changes: 7 additions & 1 deletion src/reducers/MainReducer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SET_THREADS,
SET_TIMEOUT,
SET_UPDATE,
SET_THEME_TOGGLE,
SET_THEME_TOGGLE, SET_EXPORT_NO_CLOSED,
} from './Actions/actionTypes';

const MainReducer = (state, action) => {
Expand Down Expand Up @@ -160,6 +160,12 @@ const MainReducer = (state, action) => {
...state,
themeToggle: action.payload,
};
case SET_EXPORT_NO_CLOSED:
localStorage.exportNoClosed = action.payload;
return {
...state,
exportNoClosed: action.payload,
};
default:
return state;
}
Expand Down
13 changes: 10 additions & 3 deletions src/routes/Home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const Home = () => {
const [state, d1] = useContext(MainContext);

const {
languages, languageIndex, address, startPort, endPort,
timeout, threads, noClosed, sort, isScanning, scanResults,
languages, languageIndex, address, startPort, endPort, timeout,
threads, noClosed, sort, isScanning, scanResults, exportNoClosed,
} = state;
const language = languages[languageIndex];

Expand Down Expand Up @@ -155,17 +155,24 @@ const Home = () => {

if (type === 'text/plain') {
res.forEach((e) => {
if (!exportNoClosed && e.portStatus === 'Closed') return;
toExport += `${e.address} ${e.port} ${e.hostName} ${e.portStatus} ${e.scanDate}\n`;
});
} else if (type === 'application/json') {
toExport = JSON.stringify(res, null, 2);
let exportJson = JSON.parse(JSON.stringify(res));
if (!exportNoClosed) {
exportJson = exportJson.filter((e) => e.portStatus !== 'Closed');
}
toExport = JSON.stringify(exportJson, null, 2);
} else if (type === 'text/csv') {
res.forEach((e) => {
if (!exportNoClosed && e.portStatus === 'Closed') return;
toExport += `"${e.address.replaceAll('"', '""')}","${e.port}","${e.hostName.replaceAll('"', '""')}","${e.portStatus.replaceAll('"', '""')}","${e.scanDate.replaceAll('"', '""')}",\n`;
});
} else if (type === 'text/html') {
toExport = '<!DOCTYPE html><html lang="en"><head><title>Advanced PortChecker</title><style>table, th, td {border: 1px solid black;}</style></head><body><table><thead><tr><th>Address</th><th>Port</th><th>Host Name</th><th>Port Status</th><th>Scan Date</th></tr></thead><tbody>';
res.forEach((e) => {
if (!exportNoClosed && e.portStatus === 'Closed') return;
toExport += `<tr><td>${e.address}</td><td>${e.port}</td><td>${e.hostName}</td><td>${e.portStatus}</td><td>${e.scanDate}</td></tr>`;
});
toExport += '</tbody></table></body></html>';
Expand Down
14 changes: 12 additions & 2 deletions src/routes/Settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
setAutoUpdate,
setCheckedForUpdates,
setColorOnDark,
setError,
setError, setExportNoClosed,
setLanguageIndex,
setNoClosed,
setPageIndex,
Expand All @@ -63,7 +63,7 @@ const Settings = () => {

const {
languageIndex, autoUpdate, colorOnDark, themeIndex, themeType,
threads, timeout, noClosed, sort, themeToggle,
threads, timeout, noClosed, sort, themeToggle, exportNoClosed,
} = state;
const language = state.languages[languageIndex];

Expand Down Expand Up @@ -245,6 +245,16 @@ const Settings = () => {
)}
label={language.hideClosedPorts}
/>
<FormControlLabel
control={(
<Checkbox
checked={exportNoClosed}
onChange={(e) => d1(setExportNoClosed(e.target.checked))}
value="exportNoClosed"
/>
)}
label={language.exportIncludeClosedPorts}
/>
<FormControlLabel
control={(
<Checkbox
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3519,15 +3519,15 @@ __metadata:
linkType: hard

"iterator.prototype@npm:^1.1.2":
version: 1.1.2
resolution: "iterator.prototype@npm:1.1.2"
version: 1.1.3
resolution: "iterator.prototype@npm:1.1.3"
dependencies:
define-properties: "npm:^1.2.1"
get-intrinsic: "npm:^1.2.1"
has-symbols: "npm:^1.0.3"
reflect.getprototypeof: "npm:^1.0.4"
set-function-name: "npm:^2.0.1"
checksum: 10c0/a32151326095e916f306990d909f6bbf23e3221999a18ba686419535dcd1749b10ded505e89334b77dc4c7a58a8508978f0eb16c2c8573e6d412eb7eb894ea79
checksum: 10c0/68b0320c14291fbb3d8ed5a17e255d3127e7971bec19108076667e79c9ff4c7d69f99de4b0b3075c789c3f318366d7a0a35bb086eae0f2cf832dd58465b2f9e6
languageName: node
linkType: hard

Expand Down