mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Improvments of port scanning. (#79)
* Fix port scan. Don't send a new line character when scanning. * Fix port scanning. Possible infinite loop when all range of ports is busy. Changed port scanning scheme from random to linear because this is the same faster but more predictable. * Fix port scan. Don't send a new line character when scanning. echo -n "" for clarity instead of cat < /dev/null Co-authored-by: navycat <navycat@ultrasparc>
This commit is contained in:
		
							parent
							
								
									d1afc10857
								
							
						
					
					
						commit
						018fb1c454
					
				
					 1 changed files with 5 additions and 5 deletions
				
			
		
							
								
								
									
										10
									
								
								quickemu
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								quickemu
									
										
									
									
									
								
							|  | @ -84,12 +84,12 @@ function snapshot_info() { | |||
| 
 | ||||
| function get_port() { | ||||
|     local PORT_START=$1 | ||||
|     local PORT_RANGE=$2 | ||||
|     while true; do | ||||
|         local CANDIDATE=$((PORT_START + (RANDOM % PORT_RANGE))) | ||||
|         (echo "" >/dev/tcp/127.0.0.1/${CANDIDATE}) >/dev/null 2>&1 | ||||
|     local PORT_RANGE=$((PORT_START+$2)) | ||||
|     local PORT | ||||
|     for ((PORT = PORT_START; PORT <= PORT_RANGE; PORT++)); do | ||||
|         (echo -n "" >/dev/tcp/127.0.0.1/${CANDIDATE}) >/dev/null 2>&1 | ||||
|         if [ ${?} -ne 0 ]; then | ||||
|             echo "${CANDIDATE}" | ||||
|             echo "${PORT}" | ||||
|             break | ||||
|         fi | ||||
|     done | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue