Browse Source

do not allow restart on windows

delete-log-setting
Kevin Froman 5 months ago
parent
commit
7c7e5de091
10 changed files with 83 additions and 11 deletions
  1. +2
    -1
      src/etc/onionrvalues.py
  2. +5
    -0
      src/httpapi/miscclientapi/endpoints.py
  3. +5
    -2
      src/onionrcommands/restartonionr.py
  4. +3
    -1
      src/runtests/__init__.py
  5. +8
    -0
      src/runtests/osver.py
  6. +0
    -5
      static-data/www/onboarding/index.html
  7. +3
    -1
      static-data/www/private/index.html
  8. +26
    -0
      static-data/www/private/js/windows.js
  9. +30
    -0
      static-data/www/shared/getos.js
  10. +1
    -1
      tests/runtime-result.txt

+ 2
- 1
src/etc/onionrvalues.py 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


+ 5
- 0
src/httpapi/miscclientapi/endpoints.py 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
@@ -130,4 +131,8 @@ class PrivateEndpoints:
@private_endpoints_bp.route('/setonboarding', methods=['POST'])
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())


+ 5
- 2
src/onionrcommands/restartonionr.py 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!':


+ 3
- 1
src/runtests/__init__.py 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
- 0
src/runtests/osver.py 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')

+ 0
- 5
static-data/www/onboarding/index.html 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>


+ 3
- 1
static-data/www/private/index.html 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>



+ 26
- 0
static-data/www/private/js/windows.js 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)

+ 30
- 0
static-data/www/shared/getos.js 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
})

+ 1
- 1
tests/runtime-result.txt View File

@@ -1 +1 @@
1580888911
1580971981

Loading…
Cancel
Save