mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Make port scans non-blocking
This commit is contained in:
		
							parent
							
								
									4f0bbfc667
								
							
						
					
					
						commit
						e6823edde7
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		
							
								
								
									
										5
									
								
								quickemu
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								quickemu
									
										
									
									
									
								
							|  | @ -136,8 +136,9 @@ function get_port() { | ||||||
|     local PORT_RANGE=$((PORT_START+$2)) |     local PORT_RANGE=$((PORT_START+$2)) | ||||||
|     local PORT |     local PORT | ||||||
|     for ((PORT = PORT_START; PORT <= PORT_RANGE; PORT++)); do |     for ((PORT = PORT_START; PORT <= PORT_RANGE; PORT++)); do | ||||||
|         (echo -n "" >/dev/tcp/127.0.0.1/"${PORT}") >/dev/null 2>&1 |         # Make sure port scans do not block too long. | ||||||
|         if [ ${?} -ne 0 ]; then |         timeout 0.1s bash -c "echo >/dev/tcp/127.0.0.1/${PORT}" >/dev/null 2>&1 | ||||||
|  |         if [ ${?} -eq 1 ]; then | ||||||
|             echo "${PORT}" |             echo "${PORT}" | ||||||
|             break |             break | ||||||
|         fi |         fi | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue