do not allow restart on windows

master
Kevin Froman 2020-02-05 20:31:38 -06:00
parent 938e1bddd3
commit 7c7e5de091
10 changed files with 83 additions and 11 deletions

View File

@ -23,7 +23,8 @@ import filepaths
DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA"
PASSWORD_LENGTH = 25
ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net'
ONIONR_VERSION = '1.1.0'
ONIONR_VERSION = '2.0.0'
ONIONR_VERSION_CODENAME = 'Genesis'
ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION)
API_VERSION = '0' # increments of 1; only change when something fundamental about how the API works changes. This way other nodes know how to communicate without learning too much information about you.
MIN_PY_VERSION = 7 # min version of 7 so we can take advantage of non-cyclic type hints

View File

@ -4,6 +4,7 @@ Misc client API endpoints too small to need their own file and that need access
"""
import os
import subprocess
import platform
from flask import Response, Blueprint, request, send_from_directory, abort
from gevent import spawn
@ -131,3 +132,7 @@ class PrivateEndpoints:
def set_onboarding():
return Response(config.onboarding.set_config_from_onboarding(request.get_json()))
@private_endpoints_bp.route('/os')
def get_os_system():
return Response(platform.system().lower())

View File

@ -36,6 +36,10 @@ SCRIPT_NAME = os.path.dirname(os.path.realpath(
def restart():
"""Tell the Onionr daemon to restart."""
if platform.system() == 'Windows':
logger.warn('Cannot restart Onionr on Windows. Run stop and manually restart.', terminal=True)
return
logger.info('Restarting Onionr', terminal=True)
# On platforms where we can, fork out to prevent locking
@ -44,8 +48,7 @@ def restart():
if pid != 0:
return
except (AttributeError, OSError):
if platform.platform() != 'Windows':
logger.warn('Could not fork on restart')
logger.warn('Could not fork on restart')
daemonlaunch.kill_daemon()
while localcommand.local_command('ping', maxWait=8) == 'pong!':

View File

@ -10,6 +10,7 @@ from onionrutils import epoch
from . import uicheck, inserttest, stresstest
from . import ownnode
from .webpasstest import webpass_test
from .osver import test_os_ver_endpoint
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -30,7 +31,8 @@ RUN_TESTS = [uicheck.check_ui,
ownnode.test_tor_adder,
ownnode.test_own_node,
stresstest.stress_test_block_insert,
webpass_test
webpass_test,
test_os_ver_endpoint
]
SUCCESS_FILE = os.path.dirname(os.path.realpath(__file__)) + '/../../tests/runtime-result.txt'

8
src/runtests/osver.py Normal file
View File

@ -0,0 +1,8 @@
import platform
from onionrutils import localcommand
def test_os_ver_endpoint(test_manager):
if localcommand.local_command('os') != platform.system().lower():
raise ValueError('could not get proper os platform from endpoint /os')

View File

@ -51,11 +51,6 @@
Shutdown
</a>
</p>
<p class="control">
<a class="button is-warning is-outlined" id='restartNode'>
Restart
</a>
</p>
</div>
</div>
</div>

View File

@ -17,6 +17,7 @@
<script defer src="/shared/eventsource.js"></script>
<script defer src="/shared/loadabout.js"></script>
<script defer src="/shared/misc.js"></script>
<script defer src="/shared/getos.js"></script>
<script defer src="/shared/main/stats.js"></script>
<script defer src="/shared/main/torstats.js"></script>
<script defer src="/shared/panel.js"></script>
@ -25,7 +26,8 @@
<script defer src="/shared/main/apicheck.js"></script>
<script defer src="/private/js/console.js"></script>
<script defer src="/private/js/motd.js"></script>
<script defer src='/shared/navbar.js'></script>
<script defer src="/shared/navbar.js"></script>
<script defer src="/private/js/windows.js"></script>
<script>alert("Content security policy appears to not be working. Your browser security is weak!")</script>
</head>

View File

@ -0,0 +1,26 @@
/*
Onionr - Private P2P Communication
Hide restart button if node OS is windows
since restart is broken on windows
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
var hideRestartIfWindows = function(){
if (onionrNodeOS === 'windows'){
document.getElementById('restartNode').style.display = 'none'
}
}
setTimeout(function(){hideRestartIfWindows()}, 500)

View File

@ -0,0 +1,30 @@
/*
Onionr - Private P2P Communication
Get node OS version (not browser)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
onionrNodeOS = ""
fetch('/os', {
method: 'GET',
headers: {
"token": webpass
}})
.then((resp) => resp.text()) // Transform the data into text
.then(function(os) {
onionrNodeOS = os
})

View File

@ -1 +1 @@
1580888911
1580971981