Added custom port and bind address args
This commit is contained in:
		
							parent
							
								
									b1ef248ee9
								
							
						
					
					
						commit
						ae359de562
					
				
					 5 changed files with 26 additions and 21 deletions
				
			
		
							
								
								
									
										21
									
								
								onionr.sh
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								onionr.sh
									
										
									
									
									
								
							|  | @ -2,22 +2,5 @@ | ||||||
| ORIG_ONIONR_RUN_DIR=`pwd` | ORIG_ONIONR_RUN_DIR=`pwd` | ||||||
| export ORIG_ONIONR_RUN_DIR | export ORIG_ONIONR_RUN_DIR | ||||||
| cd "$(dirname "$0")" | cd "$(dirname "$0")" | ||||||
| 
 | cd src | ||||||
| [[ -n "$USE_TOR" ]] || USE_TOR=1 | ./__init__.py "$@" | ||||||
| [[ -n "$PORT" ]] || PORT=8080 |  | ||||||
| [[ -n "$KEEP_LOG" ]] || KEEP_LOG=0 |  | ||||||
| [[ -n "$STORE_PLAINTEXT" ]] || STORE_PLAINTEXT=1 |  | ||||||
| 
 |  | ||||||
| PRIVKEY_OPT="" |  | ||||||
| [[ -f "privkey.key" ]] && PRIVKEY_OPT="--private-key privkey.key" |  | ||||||
| 
 |  | ||||||
| python run-onionr-node.py \ |  | ||||||
| 	--open-ui 0 \ |  | ||||||
| 	--onboarding 0 \ |  | ||||||
| 	--bind-address 0.0.0.0 \ |  | ||||||
| 	--port $PORT \ |  | ||||||
| 	--use-tor $USE_TOR \ |  | ||||||
| 	--keep-log-on-exit $KEEP_LOG \ |  | ||||||
| 	--store-plaintext $STORE_PLAINTEXT \ |  | ||||||
| 	$PRIVKEY_OPT \ |  | ||||||
| 	"$@" |  | ||||||
|  | @ -55,6 +55,12 @@ def show_info(p: Process): | ||||||
| 
 | 
 | ||||||
| parser = argparse.ArgumentParser() | parser = argparse.ArgumentParser() | ||||||
| 
 | 
 | ||||||
|  | parser.add_argument( | ||||||
|  |     "--bind-address", help="Address to bind to. Be very careful with non-loopback", | ||||||
|  |     type=str, default="") | ||||||
|  | parser.add_argument( | ||||||
|  |     "--port", help="Port to bind to, must be available and possible", | ||||||
|  |     type=int, default=0) | ||||||
| parser.add_argument( | parser.add_argument( | ||||||
|     "--use-bootstrap-file", help="Use bootstrap node list file", |     "--use-bootstrap-file", help="Use bootstrap node list file", | ||||||
|     type=int, default=1) |     type=int, default=1) | ||||||
|  | @ -129,6 +135,13 @@ config['general']['dev_mode'] = False | ||||||
| config['general']['store_plaintext_blocks'] = True | config['general']['store_plaintext_blocks'] = True | ||||||
| config['general']['use_bootstrap_list'] = True | config['general']['use_bootstrap_list'] = True | ||||||
| config['transports']['tor'] = True | config['transports']['tor'] = True | ||||||
|  | config['general']['bind_port'] = 0  # client api server port | ||||||
|  | config['general']['bind_address'] = ''  # client api server address | ||||||
|  | 
 | ||||||
|  | if args.bind_address: | ||||||
|  |     config['general']['bind_address'] = args.bind_address | ||||||
|  | if args.port: | ||||||
|  |     config['client']['client']['port'] = args.port | ||||||
| 
 | 
 | ||||||
| if not args.use_bootstrap_file: | if not args.use_bootstrap_file: | ||||||
|     config['general']['use_bootstrap_list'] = False |     config['general']['use_bootstrap_list'] = False | ||||||
|  |  | ||||||
|  | @ -50,11 +50,18 @@ class PrivateAPI: | ||||||
| 
 | 
 | ||||||
|         self.startTime = epoch.get_epoch() |         self.startTime = epoch.get_epoch() | ||||||
|         app = flask.Flask(__name__) |         app = flask.Flask(__name__) | ||||||
|  |          | ||||||
|  | 
 | ||||||
|         bind_port = int(config.get('client.client.port', 59496)) |         bind_port = int(config.get('client.client.port', 59496)) | ||||||
|         self.bindPort = bind_port |         self.bindPort = bind_port | ||||||
| 
 | 
 | ||||||
|         self.clientToken = config.get('client.webpassword') |         self.clientToken = config.get('client.webpassword') | ||||||
| 
 | 
 | ||||||
|  |         if config.get('general.bind_address'): | ||||||
|  |             with open(private_API_host_file, 'w') as bindFile: | ||||||
|  |                 bindFile.write(config.get('general.bind_address')) | ||||||
|  |             self.host = config.get('general.bind_address') | ||||||
|  |         else: | ||||||
|             self.host = httpapi.apiutils.setbindip.set_bind_IP( |             self.host = httpapi.apiutils.setbindip.set_bind_IP( | ||||||
|                 private_API_host_file) |                 private_API_host_file) | ||||||
|         logger.info('Running api on %s:%s' % (self.host, self.bindPort)) |         logger.info('Running api on %s:%s' % (self.host, self.bindPort)) | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
|     "general": { |     "general": { | ||||||
|         "allow_public_api_dns_rebinding": false, |         "allow_public_api_dns_rebinding": false, | ||||||
|         "announce_node": true, |         "announce_node": true, | ||||||
|  |         "bind_address": "", | ||||||
|         "dev_mode": false, |         "dev_mode": false, | ||||||
|         "display_header": true, |         "display_header": true, | ||||||
|         "ephemeral_tunnels": false, |         "ephemeral_tunnels": false, | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ class OnionrConfig(unittest.TestCase): | ||||||
|             self.assertEqual(conf['allocations']['disk'], 1073741824) |             self.assertEqual(conf['allocations']['disk'], 1073741824) | ||||||
|             self.assertEqual(conf['allocations']['disk'], 1073741824) |             self.assertEqual(conf['allocations']['disk'], 1073741824) | ||||||
|             self.assertEqual(conf['general']['announce_node'], True) |             self.assertEqual(conf['general']['announce_node'], True) | ||||||
|  |             self.assertEqual(conf['general']['bind_address'], '') | ||||||
|             self.assertEqual(conf['general']['dev_mode'], False) |             self.assertEqual(conf['general']['dev_mode'], False) | ||||||
|             self.assertEqual(conf['general']['display_header'], True) |             self.assertEqual(conf['general']['display_header'], True) | ||||||
|             self.assertEqual(conf['general']['ephemeral_tunnels'], False) |             self.assertEqual(conf['general']['ephemeral_tunnels'], False) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue