do not allow restart on windows
This commit is contained in:
		
							parent
							
								
									938e1bddd3
								
							
						
					
					
						commit
						7c7e5de091
					
				
					 10 changed files with 83 additions and 11 deletions
				
			
		| 
						 | 
					@ -23,7 +23,8 @@ import filepaths
 | 
				
			||||||
DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA"
 | 
					DENIABLE_PEER_ADDRESS = "OVPCZLOXD6DC5JHX4EQ3PSOGAZ3T24F75HQLIUZSDSMYPEOXCPFA"
 | 
				
			||||||
PASSWORD_LENGTH = 25
 | 
					PASSWORD_LENGTH = 25
 | 
				
			||||||
ONIONR_TAGLINE = 'Private P2P Communication - GPLv3 - https://Onionr.net'
 | 
					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)
 | 
					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.
 | 
					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
 | 
					MIN_PY_VERSION = 7 # min version of 7 so we can take advantage of non-cyclic type hints
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@ Misc client API endpoints too small to need their own file and that need access
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					import platform
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from flask import Response, Blueprint, request, send_from_directory, abort
 | 
					from flask import Response, Blueprint, request, send_from_directory, abort
 | 
				
			||||||
from gevent import spawn
 | 
					from gevent import spawn
 | 
				
			||||||
| 
						 | 
					@ -131,3 +132,7 @@ class PrivateEndpoints:
 | 
				
			||||||
        def set_onboarding():
 | 
					        def set_onboarding():
 | 
				
			||||||
            return Response(config.onboarding.set_config_from_onboarding(request.get_json()))
 | 
					            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())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,6 +36,10 @@ SCRIPT_NAME = os.path.dirname(os.path.realpath(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def restart():
 | 
					def restart():
 | 
				
			||||||
    """Tell the Onionr daemon to 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)
 | 
					    logger.info('Restarting Onionr', terminal=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # On platforms where we can, fork out to prevent locking
 | 
					    # On platforms where we can, fork out to prevent locking
 | 
				
			||||||
| 
						 | 
					@ -44,7 +48,6 @@ def restart():
 | 
				
			||||||
        if pid != 0:
 | 
					        if pid != 0:
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
    except (AttributeError, OSError):
 | 
					    except (AttributeError, OSError):
 | 
				
			||||||
        if platform.platform() != 'Windows':
 | 
					 | 
				
			||||||
        logger.warn('Could not fork on restart')
 | 
					        logger.warn('Could not fork on restart')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    daemonlaunch.kill_daemon()
 | 
					    daemonlaunch.kill_daemon()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@ from onionrutils import epoch
 | 
				
			||||||
from . import uicheck, inserttest, stresstest
 | 
					from . import uicheck, inserttest, stresstest
 | 
				
			||||||
from . import ownnode
 | 
					from . import ownnode
 | 
				
			||||||
from .webpasstest import webpass_test
 | 
					from .webpasstest import webpass_test
 | 
				
			||||||
 | 
					from .osver import test_os_ver_endpoint
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
    This program is free software: you can redistribute it and/or modify
 | 
					    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
 | 
					    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_tor_adder,
 | 
				
			||||||
             ownnode.test_own_node,
 | 
					             ownnode.test_own_node,
 | 
				
			||||||
             stresstest.stress_test_block_insert,
 | 
					             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'
 | 
					SUCCESS_FILE = os.path.dirname(os.path.realpath(__file__)) + '/../../tests/runtime-result.txt'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										8
									
								
								src/runtests/osver.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/runtests/osver.py
									
										
									
									
									
										Normal 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')
 | 
				
			||||||
| 
						 | 
					@ -51,11 +51,6 @@
 | 
				
			||||||
                                    Shutdown
 | 
					                                    Shutdown
 | 
				
			||||||
                                </a>
 | 
					                                </a>
 | 
				
			||||||
                            </p>
 | 
					                            </p>
 | 
				
			||||||
                            <p class="control">
 | 
					 | 
				
			||||||
                                <a class="button is-warning is-outlined" id='restartNode'>
 | 
					 | 
				
			||||||
                                    Restart
 | 
					 | 
				
			||||||
                                </a>
 | 
					 | 
				
			||||||
                            </p>
 | 
					 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,7 @@
 | 
				
			||||||
    <script defer src="/shared/eventsource.js"></script>
 | 
					    <script defer src="/shared/eventsource.js"></script>
 | 
				
			||||||
    <script defer src="/shared/loadabout.js"></script>
 | 
					    <script defer src="/shared/loadabout.js"></script>
 | 
				
			||||||
    <script defer src="/shared/misc.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/stats.js"></script>
 | 
				
			||||||
    <script defer src="/shared/main/torstats.js"></script>
 | 
					    <script defer src="/shared/main/torstats.js"></script>
 | 
				
			||||||
    <script defer src="/shared/panel.js"></script>
 | 
					    <script defer src="/shared/panel.js"></script>
 | 
				
			||||||
| 
						 | 
					@ -25,7 +26,8 @@
 | 
				
			||||||
    <script defer src="/shared/main/apicheck.js"></script>
 | 
					    <script defer src="/shared/main/apicheck.js"></script>
 | 
				
			||||||
    <script defer src="/private/js/console.js"></script>
 | 
					    <script defer src="/private/js/console.js"></script>
 | 
				
			||||||
    <script defer src="/private/js/motd.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>
 | 
					    <script>alert("Content security policy appears to not be working. Your browser security is weak!")</script>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								static-data/www/private/js/windows.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								static-data/www/private/js/windows.js
									
										
									
									
									
										Normal 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
									
								
								static-data/www/shared/getos.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								static-data/www/shared/getos.js
									
										
									
									
									
										Normal 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 @@
 | 
				
			||||||
1580888911
 | 
					1580971981
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue