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

minor changes in colors #485

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
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
28 changes: 14 additions & 14 deletions python/cfscanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ def _init_pool():
try:
create_dir(CONFIGDIR)
except Exception as e:
console.log("[red]Could not create config directory[/red]")
console.log("[red1]Could not create config directory[/red1]")
logger.exception("Could not create config directory")
exit(1)
console.log(f"[blue]Config directory created \"{CONFIGDIR}\"[/blue]")
console.log(f"[bright_blue]Config directory created \"{CONFIGDIR}\"[/bright_blue]")
configFilePath = args.config_path

with console.status(f"[green]Creating results directory \"{RESULTDIR}\"[/green]"):
try:
create_dir(RESULTDIR)
except Exception as e:
console.log("[red]Could not create results directory[/red]")
console.log("[red1]Could not create results directory[/red1]")
logger.exception("Could not create results directory")
exit(1)
console.log(f"[blue]Results directory created \"{RESULTDIR}\"[/blue]")
console.log(f"[bright_blue]Results directory created \"{RESULTDIR}\"[/bright_blue]")

# create empty result file
with console.status(f"[green]Creating empty result file {INTERIM_RESULTS_PATH}[/green]"):
Expand All @@ -99,7 +99,7 @@ def _init_pool():
empty_file.write(",".join(titles) + "\n")
except Exception as e:
console.log(
f"[red]Could not create empty result file:\n\"{INTERIM_RESULTS_PATH}\"[/red]"
f"[red1]Could not create empty result file:\n\"{INTERIM_RESULTS_PATH}\"[/red1]"
)
logger.exception("Could not create empty result file")
exit(1)
Expand All @@ -111,27 +111,27 @@ def _init_pool():
try:
cidr_list = read_cidrs(args.subnets)
except SubnetsReadError as e:
console.log(f"[red]Could not read subnets.[/red]")
console.log(f"[red1]Could not read subnets.[/red1]")
logger.exception(f"Could not read subnets")
exit(1)
except Exception as e:
console.log(f"Unknown error in reading subnets: {e}")
logger.exception(f"Unknown error in reading subnets: {e}")
exit(1)
console.log(
f"[blue]Subnets successfully read from \"{args.subnets}\"[/blue]")
f"[bright_blue]Subnets successfully read from \"{args.subnets}\"[/bright_blue]")
else:
subnets_default_address = "https://raw.githubusercontent.com/MortezaBashsiz/CFScanner/main/config/cf.local.iplist"
console.log(
f"[blue]Subnets not provided. Default address will be used:\n\"{subnets_default_address}\"[/blue]"
f"[bright_blue]Subnets not provided. Default address will be used:\n\"{subnets_default_address}\"[/bright_blue]"
)
with console.status(f"[green]Retrieving subnets from \"{subnets_default_address}\"[/green]"):
try:
cidr_list = read_cidrs(
"https://raw.githubusercontent.com/MortezaBashsiz/CFScanner/main/config/cf.local.iplist"
)
except SubnetsReadError as e:
console.log(f"[red]Could not read subnets. {e}[/red]")
console.log(f"[red1]Could not read subnets. {e}[/red1]")
logger.exception(e)
exit(1)
except Exception as e:
Expand All @@ -150,13 +150,13 @@ def _init_pool():
test_config = TestConfig.from_args(args)
except TemplateReadError as e:
console.log(
f"[red]Could not read template from file \"{args.template_path}\"[/red]"
f"[red1]Could not read template from file \"{args.template_path}\"[/red1]"
)
logger.exception(e)
exit(1)
except BinaryNotFoundError:
console.log(
f"[red]Could not find xray/v2ray binary from path \"{args.binpath}\"[/red]")
f"[red1]Could not find xray/v2ray binary from path \"{args.binpath}\"[/red1]")
logger.exception(e)
exit(1)
except Exception as e:
Expand All @@ -168,7 +168,7 @@ def _init_pool():
cidr,
sample_size=test_config.sample_size
) for cidr in cidr_list)
console.log(f"[blue]Starting to scan {n_total_ips} ips...[/blue]")
console.log(f"[bright_blue]Starting to scan {n_total_ips} ips...[/bright_blue]")

cidr_ip_lists = [
cidr_to_ip_list(
Expand Down Expand Up @@ -237,7 +237,7 @@ def _init_pool():
progress.remove_task(cidr_prog_tasks[res.cidr])
except StartProxyServiceError as e:
progress.stop()
console.log(f"[red]{e}[/red]")
console.log(f"[red1]{e}[/red1]")
pool.terminate()
logger.exception("Error in starting xray service.")
break
Expand All @@ -258,6 +258,6 @@ def _init_pool():
pool.terminate()
break
except Exception as e:
progress.log("[red]Unknown error![/red]")
progress.log("[red1]Unknown error![/red1]")
console.print_exception()
logger.exception(e)
8 changes: 4 additions & 4 deletions python/report/print.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def no_and_kill(
process (Popen): the process (xray) to be killed
"""
process.kill()
return f"[bold red]NO[/bold red] [orange]{ip:15s}[/orange] [yellow]{message}[/yellow]"
return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3] [yellow1]{message}[/yellow1]"


def ok_message(
Expand All @@ -36,15 +36,15 @@ def ok_message(
mean_up_speed = mean(scan_result["upload"]["speed"])
mean_down_latency = mean(scan_result["download"]["latency"])
mean_up_latency = mean(scan_result["upload"]["latency"])
return f"[green]"\
f"OK [green][blue_violet]{scan_result['ip']:15s}[/blue_violet][blue] "\
return f"[bold green1]"\
f"OK [/bold green1][cyan1]{scan_result['ip']:15s}[/cyan1][bright_blue] "\
f"avg_down_speed: {mean_down_speed:7.4f}mbps "\
f"avg_up_speed: {mean_up_speed:7.4f}mbps "\
f"avg_down_latency: {mean_down_latency:7.2f}ms "\
f"avg_up_latency: {mean_up_latency:7.2f}ms "\
f"avg_down_jitter: {down_mean_jitter:7.2f}ms "\
f"avg_up_jitter: {up_mean_jitter:4.2f}ms"\
f"[/blue]"
f"[/bright_blue]"


def color_text(text: str, rgb: tuple, bold: bool = False):
Expand Down
10 changes: 5 additions & 5 deletions python/speedtest/fronting.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ def fronting_test(
headers={"Host": "speed.cloudflare.com"}
)
if r.status_code != 200:
return f"[red]NO[/red] [dark_orange3]{ip:15s}[/dark_orange3][yellow] fronting error {r.status_code} [/yellow]"
return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting error {r.status_code} [/yellow1]"
else:
success = True
except requests.exceptions.ConnectTimeout as e:
return f"[red]NO[/red] [dark_orange3]{ip:15s}[/dark_orange3][yellow] fronting connect timeout[/yellow]"
return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting connect timeout[/yellow1]"
except requests.exceptions.ReadTimeout as e:
return f"[red]NO[/red] [dark_orange3]{ip:15s}[/dark_orange3][yellow] fronting read timeout[/yellow]"
return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting read timeout[/yellow1]"
except requests.exceptions.ConnectionError as e:
return f"[red]NO[/red] [dark_orange3]{ip:15s}[/dark_orange3][yellow] fronting connection error[/yellow]"
return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting connection error[/yellow1]"
except Exception as e:
return f"[red]NO[/red] [dark_orange3]{ip:15s}[/dark_orange3][yellow] fronting Unknown error[/yellow]"
return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting Unknown error[/yellow1]"

return "OK"
2 changes: 1 addition & 1 deletion python/xray/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def download_binary(
raise BinaryDownloadError(
f"Unknown error - detected system: {str(system_info)}")
else:
console.log(f"[blue]Binary file already exists {bin_path}[/blue]")
console.log(f"[bright_blue]Binary file already exists {bin_path}[/bright_blue]")
return bin_path


Expand Down