You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a batch file to select and test all IPs in specific range from ip.txt.
@echo off
setlocal enabledelayedexpansion
rem Set the path to the file containing the IP ranges
set "all_ips_list=ipv4_all_cf_official.txt"
rem Define the default value by its content
set "default_value=188.114.96.0/20"
rem Check if the file exists
if not exist "%all_ips_list%" (
echo File "%all_ips_list%" not found!
pause
exit /b
)
rem Display the content of the file and list options for the user
echo Please select one IP range from the following list:
echo.
set count=0
set default_index=0
for /f "usebackq tokens=*" %%A in ("%all_ips_list%") do (
set /a count+=1
set "current_line=%%A"
rem Check if the line contains a CIDR block (e.g., has a "/")
for /f "tokens=1,2 delims=/" %%B in ("%%A") do (
set "base_ip=%%B"
set "cidr_mask=%%C"
)
rem Calculate the number of IPs if it's a CIDR block
if defined cidr_mask (
set /a bits_to_shift=32-!cidr_mask!
call :CalculateIPs !bits_to_shift!
echo !count!. %%A ^(!num_ips! IPs^)
) else (
echo !count!. %%A
)
rem Store the IP range in an array
set "ip[!count!]=%%A"
rem Check if the current line matches the default value
if "%%A"=="%default_value%" set default_index=!count!
)
rem Validate if the file is empty
if "%count%"=="0" (
echo The file "%all_ips_list%" is empty.
pause
exit /b
)
rem Validate if the default value exists in the list
if "%default_index%"=="0" (
echo Default value "%default_value%" not found in %all_ips_list%.
set default_index=1
echo Defaulting to the first IP range: !ip[1]!
)
rem Prompt the user to select an option, showing the default value
set /p selection=Enter the number of the IP range to select (default is [%default_index%] %default_value%):
rem If the user does not enter anything, use the default index
if "%selection%"=="" set selection=%default_index%
rem Validate the selection (ensure it's numeric)
for /f "delims=0123456789" %%C in ("%selection%") do (
echo Invalid input! Please enter a valid number.
pause
exit /b
)
rem Validate the selection against range
if %selection% lss 1 (
echo Invalid selection! Must be between 1 and %count%.
pause
exit /b
)
if %selection% gtr %count% (
echo Invalid selection! Must be between 1 and %count%.
pause
exit /b
)
rem Retrieve the selected IP range
set "selected_ip_range=!ip[%selection%]!"
rem Run the CloudflareST.exe command with the selected IP range
echo Running command: CloudflareST.exe -p 25 -ip %selected_ip_range% -o result_specific_ips_cf.csv -allip
CloudflareST.exe -p 25 -ip %selected_ip_range% -o result_specific_ips_cf.csv -allip
rem Function to calculate 2^(32-mask)
:CalculateIPs
set "result=1"
for /l %%I in (1,1,%1) do set /a result*=2
set "num_ips=%result%"
goto :eof
endlocal
预期目标
I wrote a batch file to select and test all IPs in specific range from ip.txt.
This discussion was converted from issue #561 on December 19, 2024 01:23.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
功能需求
I wrote a batch file to select and test all IPs in specific range from ip.txt.
预期目标
I wrote a batch file to select and test all IPs in specific range from ip.txt.
Beta Was this translation helpful? Give feedback.
All reactions