Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate serverName Random #453

Merged
merged 2 commits into from
Apr 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 36 additions & 38 deletions bash/cfScanner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,14 @@ function fncCheckIPList {
configHost="${6}"
configPort="${7}"
configPath="${8}"
configServerName="${9}"
fileSize="${10}"
osVersion="${11}"
v2rayCommand="${12}"
tryCount="${13}"
downThreshold="${14}"
upThreshold="${15}"
downloadOrUpload="${16}"
vpnOrNot="${17}"
fileSize="${9}"
osVersion="${10}"
v2rayCommand="${11}"
tryCount="${12}"
downThreshold="${13}"
upThreshold="${14}"
downloadOrUpload="${15}"
vpnOrNot="${16}"
binDir="$scriptDir/../bin"
tempConfigDir="$scriptDir/tempConfig"
uploadFile="$tempConfigDir/upload_file"
Expand Down Expand Up @@ -212,6 +211,9 @@ function fncCheckIPList {
domainFronting=$($timeoutCommand 1 curl -k -s -w "%{http_code}\n" --tlsv1.2 -H "Host: speed.cloudflare.com" --resolve "speed.cloudflare.com:443:$ip" "https://speed.cloudflare.com/__down?bytes=1000" -o /dev/null)
if [[ "$domainFronting" == "200" ]]
then
mainDomain=$(echo "$configHost" | awk -F '.' '{ print $2"."$3}')
randomUUID=$(cat /proc/sys/kernel/random/uuid)
configServerName="$randomUUID.$mainDomain"
ipConfigFile="$tempConfigDir/config.json.$ip"
cp "$scriptDir"/config.json.temp "$ipConfigFile"
ipO1=$(echo "$ip" | awk -F '.' '{print $1}')
Expand Down Expand Up @@ -474,8 +476,7 @@ function fncValidateConfig {
configHost=$(jq --raw-output .host "$config")
configPort=$(jq --raw-output .port "$config")
configPath=$(jq --raw-output .path "$config")
configServerName=$(jq --raw-output .serverName "$config")
if ! [[ "$configId" ]] || ! [[ $configHost ]] || ! [[ $configPort ]] || ! [[ $configPath ]] || ! [[ $configServerName ]]
if ! [[ "$configId" ]] || ! [[ $configHost ]] || ! [[ $configPort ]] || ! [[ $configPath ]]
then
echo "config is not correct"
exit 1
Expand All @@ -501,7 +502,7 @@ function fncCreateDir {
# Function fncMainCFFindSubnet
# main Function for Subnet
function fncMainCFFindSubnet {
local threads progressBar resultFile scriptDir configId configHost configPort configPath configServerName fileSize osVersion parallelVersion subnetsFile breakedSubnets network netmask downloadOrUpload tryCount downThreshold upThreshold vpnOrNot
local threads progressBar resultFile scriptDir configId configHost configPort configPath fileSize osVersion parallelVersion subnetsFile breakedSubnets network netmask downloadOrUpload tryCount downThreshold upThreshold vpnOrNot
threads="${1}"
progressBar="${2}"
resultFile="${3}"
Expand All @@ -510,15 +511,14 @@ function fncMainCFFindSubnet {
configHost="${6}"
configPort="${7}"
configPath="${8}"
configServerName="${9}"
fileSize="${10}"
osVersion="${11}"
subnetsFile="${12}"
tryCount="${13}"
downThreshold="${14}"
upThreshold="${15}"
downloadOrUpload="${16}"
vpnOrNot="${17}"
fileSize="${9}"
osVersion="${10}"
subnetsFile="${11}"
tryCount="${12}"
downThreshold="${13}"
upThreshold="${14}"
downloadOrUpload="${15}"
vpnOrNot="${16}"

if [[ "$osVersion" == "Linux" ]]
then
Expand Down Expand Up @@ -591,10 +591,10 @@ function fncMainCFFindSubnet {
tput cuu1; tput ed # rewrites Parallel's bar
if [[ $parallelVersion -gt 20220515 ]];
then
parallel --ll --bar -j "$threads" fncCheckIPList ::: "$ipList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$configServerName" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
parallel --ll --bar -j "$threads" fncCheckIPList ::: "$ipList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
else
echo -e "${RED}$progressBar${NC}"
parallel -j "$threads" fncCheckIPList ::: "$ipList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$configServerName" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
parallel -j "$threads" fncCheckIPList ::: "$ipList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
fi
killall v2ray > /dev/null 2>&1
passedIpsCount=$(( passedIpsCount+1 ))
Expand All @@ -607,7 +607,7 @@ function fncMainCFFindSubnet {
# Function fncMainCFFindIP
# main Function for IP
function fncMainCFFindIP {
local threads progressBar resultFile scriptDir configId configHost configPort configPath configServerName fileSize osVersion parallelVersion IPFile downloadOrUpload downThreshold upThreshold
local threads progressBar resultFile scriptDir configId configHost configPort configPath fileSize osVersion parallelVersion IPFile downloadOrUpload downThreshold upThreshold
threads="${1}"
progressBar="${2}"
resultFile="${3}"
Expand All @@ -616,15 +616,14 @@ function fncMainCFFindIP {
configHost="${6}"
configPort="${7}"
configPath="${8}"
configServerName="${9}"
fileSize="${10}"
osVersion="${11}"
IPFile="${12}"
tryCount="${13}"
downThreshold="${14}"
upThreshold="${15}"
downloadOrUpload="${16}"
vpnOrNot="${17}"
fileSize="${9}"
osVersion="${10}"
IPFile="${11}"
tryCount="${12}"
downThreshold="${13}"
upThreshold="${14}"
downloadOrUpload="${15}"
vpnOrNot="${16}"

if [[ "$osVersion" == "Linux" ]]
then
Expand All @@ -644,10 +643,10 @@ function fncMainCFFindIP {
tput cuu1; tput ed # rewrites Parallel's bar
if [[ $parallelVersion -gt 20220515 ]];
then
parallel --ll --bar -j "$threads" fncCheckIPList ::: "$cfIPList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$configServerName" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
parallel --ll --bar -j "$threads" fncCheckIPList ::: "$cfIPList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
else
echo -e "${RED}$progressBar${NC}"
parallel -j "$threads" fncCheckIPList ::: "$cfIPList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$configServerName" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
parallel -j "$threads" fncCheckIPList ::: "$cfIPList" ::: "$progressBar" ::: "$resultFile" ::: "$scriptDir" ::: "$configId" ::: "$configHost" ::: "$configPort" ::: "$configPath" ::: "$fileSize" ::: "$osVersion" ::: "$v2rayCommand" ::: "$tryCount" ::: "$downThreshold" ::: "$upThreshold" ::: "$downloadOrUpload" ::: "$vpnOrNot"
fi
killall v2ray > /dev/null 2>&1
sort -n -k1 -t, "$resultFile" -o "$resultFile"
Expand Down Expand Up @@ -803,7 +802,6 @@ configId="NULL"
configHost="NULL"
configPort="NULL"
configPath="NULL"
configServerName="NULL"

progressBar=""

Expand Down Expand Up @@ -860,10 +858,10 @@ fncValidateConfig "$config"

if [[ "$subnetOrIP" == "SUBNET" ]]
then
fncMainCFFindSubnet "$threads" "$progressBar" "$resultFile" "$scriptDir" "$configId" "$configHost" "$configPort" "$configPath" "$configServerName" "$fileSize" "$osVersion" "$subnetIPFile" "$tryCount" "$downThreshold" "$upThreshold" "$downloadOrUpload" "$vpnOrNot"
fncMainCFFindSubnet "$threads" "$progressBar" "$resultFile" "$scriptDir" "$configId" "$configHost" "$configPort" "$configPath" "$fileSize" "$osVersion" "$subnetIPFile" "$tryCount" "$downThreshold" "$upThreshold" "$downloadOrUpload" "$vpnOrNot"
elif [[ "$subnetOrIP" == "IP" ]]
then
fncMainCFFindIP "$threads" "$progressBar" "$resultFile" "$scriptDir" "$configId" "$configHost" "$configPort" "$configPath" "$configServerName" "$fileSize" "$osVersion" "$subnetIPFile" "$tryCount" "$downThreshold" "$upThreshold" "$downloadOrUpload" "$vpnOrNot"
fncMainCFFindIP "$threads" "$progressBar" "$resultFile" "$scriptDir" "$configId" "$configHost" "$configPort" "$configPath" "$fileSize" "$osVersion" "$subnetIPFile" "$tryCount" "$downThreshold" "$upThreshold" "$downloadOrUpload" "$vpnOrNot"
else
echo "$subnetOrIP is not correct choose one SUBNET or IP"
exit 1
Expand Down