mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add link to node stats in the settings
This commit is contained in:
+23
-19
@@ -117,15 +117,18 @@ const createMainWindow = () => {
|
|||||||
// only open valid https urls to prevent remote execution
|
// only open valid https urls to prevent remote execution
|
||||||
// will throw if url isn't valid
|
// will throw if url isn't valid
|
||||||
const validatedUrl = new URL(originalUrl);
|
const validatedUrl = new URL(originalUrl);
|
||||||
if (validatedUrl.protocol !== 'https:') {
|
let serializedUrl = '';
|
||||||
throw Error(`can't open url '${originalUrl}' not https`);
|
|
||||||
|
// make an exception for ipfs stats
|
||||||
|
if (validatedUrl.toString() === 'http://localhost:5001/webui/') {
|
||||||
|
serializedUrl = validatedUrl.toString();
|
||||||
|
} else if (validatedUrl.protocol === 'https:') {
|
||||||
|
// open serialized url to prevent remote execution
|
||||||
|
serializedUrl = validatedUrl.toString();
|
||||||
|
} else {
|
||||||
|
throw Error(`can't open url '${originalUrl}', it's not https and not the allowed http exception`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not open http protocol, not private
|
|
||||||
// do not open any other protocol, will lead to remote execution
|
|
||||||
|
|
||||||
// open serialized url to prevent remote execution
|
|
||||||
const serializedUrl = validatedUrl.toString();
|
|
||||||
shell.openExternal(serializedUrl);
|
shell.openExternal(serializedUrl);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
@@ -136,7 +139,7 @@ const createMainWindow = () => {
|
|||||||
// open links (with target="_blank") in external browser
|
// open links (with target="_blank") in external browser
|
||||||
// do not open links in plebchan or will lead to remote execution
|
// do not open links in plebchan or will lead to remote execution
|
||||||
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
||||||
const originalUrl = url
|
const originalUrl = url;
|
||||||
try {
|
try {
|
||||||
// do not let the user open any url with shell.openExternal
|
// do not let the user open any url with shell.openExternal
|
||||||
// or it will lead to remote execution https://benjamin-altpeter.de/shell-openexternal-dangers/
|
// or it will lead to remote execution https://benjamin-altpeter.de/shell-openexternal-dangers/
|
||||||
@@ -144,25 +147,26 @@ const createMainWindow = () => {
|
|||||||
// only open valid https urls to prevent remote execution
|
// only open valid https urls to prevent remote execution
|
||||||
// will throw if url isn't valid
|
// will throw if url isn't valid
|
||||||
const validatedUrl = new URL(originalUrl);
|
const validatedUrl = new URL(originalUrl);
|
||||||
if (validatedUrl.protocol !== 'https:') {
|
let serializedUrl = '';
|
||||||
throw Error(`can't open url '${originalUrl}' not https`);
|
|
||||||
|
// make an exception for ipfs stats
|
||||||
|
if (validatedUrl.toString() === 'http://localhost:5001/webui/') {
|
||||||
|
serializedUrl = validatedUrl.toString();
|
||||||
|
} else if (validatedUrl.protocol === 'https:') {
|
||||||
|
// open serialized url to prevent remote execution
|
||||||
|
serializedUrl = validatedUrl.toString();
|
||||||
|
} else {
|
||||||
|
throw Error(`can't open url '${originalUrl}', it's not https and not the allowed http exception`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not open http protocol, not private
|
|
||||||
// do not open any other protocol, will lead to remote execution
|
|
||||||
|
|
||||||
// open serialized url to prevent remote execution
|
|
||||||
const serializedUrl = validatedUrl.toString();
|
|
||||||
shell.openExternal(serializedUrl);
|
shell.openExternal(serializedUrl);
|
||||||
setImmediate(() => {
|
|
||||||
shell.openExternal(serializedUrl)
|
|
||||||
})
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
}
|
}
|
||||||
return {action: 'deny'}
|
return {action: 'deny'};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// deny permissions like location, notifications, etc https://www.electronjs.org/docs/latest/tutorial/security#5-handle-session-permission-requests-from-remote-content
|
// deny permissions like location, notifications, etc https://www.electronjs.org/docs/latest/tutorial/security#5-handle-session-permission-requests-from-remote-content
|
||||||
mainWindow.webContents.session.setPermissionRequestHandler((webContents, permission, callback) => {
|
mainWindow.webContents.session.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||||
// deny all permissions
|
// deny all permissions
|
||||||
|
|||||||
@@ -223,7 +223,13 @@ const SettingsModal = ({ isOpen, closeModal }) => {
|
|||||||
<div className="panel">
|
<div className="panel">
|
||||||
<div className="panel-header">
|
<div className="panel-header">
|
||||||
<span id="version">
|
<span id="version">
|
||||||
v{version}
|
v{version} -
|
||||||
|
{window.electron && window.electron.isElectron ? (
|
||||||
|
<Link className="all-button" id="node-stats" to="http://localhost:5001/webui/" target="_blank" rel="noreferrer">
|
||||||
|
full node
|
||||||
|
</Link>
|
||||||
|
) : (<span>web</span>)
|
||||||
|
}
|
||||||
</span>
|
</span>
|
||||||
Settings
|
Settings
|
||||||
<Link to="" onClick={handleCloseModal}>
|
<Link to="" onClick={handleCloseModal}>
|
||||||
|
|||||||
@@ -417,4 +417,8 @@ export const StyledModal = styled(Modal)`
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
#node-stats {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
Reference in New Issue
Block a user