File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ from v2ray2proxy .base import V2RayProxy , V2RayCore
2+ from asyncio import run
3+ import logging , requests
4+ from time import time
5+
6+ # Set up logging
7+ logging .basicConfig (level = logging .INFO , format = "%(asctime)s - %(levelname)s - %(message)s" , handlers = [logging .StreamHandler ()])
8+
9+ # Test V2Ray link
10+ TEST_LINK = "vless://cb5d5224-b21f-4522-b756-237205084ba9@94.103.169.120:51569?type=tcp&security=none#TelegramMask-rkn-sosat"
11+
12+
13+ async def main ():
14+ try :
15+ # Measure startup time
16+ start_time = time ()
17+ logging .info ("Initializing V2Ray..." )
18+ proxy = V2RayProxy (TEST_LINK , socks_port = None )
19+ init_time = time ()
20+ logging .info (f"V2Ray initialized in { init_time - start_time :.2f} seconds" )
21+
22+ # Measure check time
23+ check_start = time ()
24+ logging .info ("Checking V2Ray configuration..." )
25+ with open ("./v2ray_config.json" , "w" ) as f :
26+ f .write (open (proxy .config_file_path , "r" ).read ())
27+ check_end = time ()
28+ logging .info (f"Configuration check completed in { check_end - check_start :.2f} seconds" )
29+
30+ # request_start = time()
31+ # requests.get(
32+ # "https://api.ipify.org?format=json",
33+ # proxies={"http": proxy.http_proxy_url, "https": proxy.http_proxy_url},
34+ # timeout=30
35+ # )
36+ # request_end = time()
37+ # logging.info(f"request duration: {request_end - request_start:.2f} seconds")
38+
39+ # Measure stop time
40+ stop_start = time ()
41+ logging .info ("Stopping V2Ray..." )
42+ proxy .stop ()
43+ stop_end = time ()
44+ logging .info (f"V2Ray stopped in { stop_end - stop_start :.2f} seconds" )
45+
46+ logging .info (f"Test took { stop_end - start_time :.2f} seconds" )
47+
48+ except Exception as e :
49+ logging .error (f"Error during performance test: { e } " )
50+ raise
51+
52+
53+ if __name__ == "__main__" :
54+ run (main ())
You can’t perform that action at this time.
0 commit comments