|
|
| from __future__ import annotations
|
| from dataclasses import dataclass ,field ,asdict
|
| from typing import Optional ,List ,Dict ,Any
|
| import json
|
| import time
|
|
|
|
|
|
|
|
|
|
|
|
|
| TRANSPORT_TYPES =["tcp","grpc"]
|
|
|
|
|
| CANDIDATE_PORTS =[443 ,80 ,8443 ,2053 ,2083 ,2087 ,9443 ]
|
|
|
|
|
| SNI_DOMAINS =[
|
|
|
| "download.nvidia.com",
|
| "swscan.apple.com",
|
| "updates.cdn-apple.com",
|
| "steamcdn-a.akamaihd.net",
|
| "dl.delivery.mp.microsoft.com",
|
| "download.windowsupdate.com",
|
| "cdn.cloudflare.steamstatic.com",
|
| "origin-a.akamaihd.net",
|
| "pkg-containers.githubusercontent.com",
|
| "download.jetbrains.com",
|
| "packages.ubuntu.com",
|
|
|
| "ajax.aspnetcdn.com",
|
| "github-releases.githubusercontent.com",
|
| "objects.githubusercontent.com",
|
| "software.download.prss.microsoft.com",
|
|
|
|
|
|
|
| ]
|
|
|
| FINGERPRINTS =["chrome","firefox","edge","safari","ios","random","randomized"]
|
|
|
|
|
| ALPN_OPTIONS =[
|
| ["h2","http/1.1"],
|
| ["h2"],
|
| ["http/1.1"],
|
| ]
|
|
|
| FRAGMENT_STRATEGIES =["none","tlshello","all"]
|
|
|
| MUX_CONCURRENCY_VALUES =[0 ,1 ,2 ,4 ,8 ,16 ,32 ]
|
|
|
| SHORT_ID_LENGTHS =[4 ,8 ,16 ]
|
|
|
| XHTTP_MODES =["packet-up","streaming"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| @dataclass
|
| class VlessConfig :
|
|
|
| transport_type :str ="tcp"
|
| proxy_port :int =443
|
|
|
|
|
| dest_domain :str ="download.nvidia.com"
|
| short_id :str ="abcdef01"
|
| spider_x :str ="/"
|
|
|
|
|
| fingerprint :str ="chrome"
|
| alpn :List [str ]=field (default_factory =lambda :["h2","http/1.1"])
|
|
|
|
|
| grpc_service_name :str ="grpc"
|
| xhttp_mode :str ="packet-up"
|
|
|
|
|
| fragment_strategy :str ="none"
|
| fragment_length_min :int =50
|
| fragment_length_max :int =100
|
| fragment_interval_min :int =1
|
| fragment_interval_max :int =5
|
|
|
|
|
| padding_enabled :bool =False
|
| padding_min :int =0
|
| padding_max :int =0
|
|
|
|
|
| mux_concurrency :int =0
|
|
|
|
|
| extra_headers :Dict [str ,str ]=field (default_factory =dict )
|
|
|
| def to_dict (self )->dict :
|
| return asdict (self )
|
|
|
| @classmethod
|
| def from_dict (cls ,d :dict )->"VlessConfig":
|
| return cls (**d )
|
|
|
| def to_json (self )->str :
|
| return json .dumps (self .to_dict ())
|
|
|
| @classmethod
|
| def from_json (cls ,s :str )->"VlessConfig":
|
| return cls .from_dict (json .loads (s ))
|
|
|
|
|
|
|
|
|
|
|
|
|
| @dataclass
|
| class EpisodeMetrics :
|
| episode_id :str =""
|
| timestamp :float =field (default_factory =time .time )
|
|
|
|
|
| connected :bool =False
|
| connect_time_ms :float =0.0
|
|
|
|
|
| stability_ratio :float =0.0
|
| reconnect_count :int =0
|
| drop_count :int =0
|
|
|
|
|
| throughput_mbps :float =0.0
|
| throughput_ratio :float =0.0
|
|
|
|
|
| avg_ping_ms :float =0.0
|
| max_ping_ms :float =0.0
|
| packet_loss_ratio :float =0.0
|
|
|
|
|
| error_message :Optional [str ]=None
|
| samples :int =0
|
|
|
| def to_dict (self )->dict :
|
| return asdict (self )
|
|
|
| @classmethod
|
| def from_dict (cls ,d :dict )->"EpisodeMetrics":
|
| return cls (**d )
|
|
|
|
|
|
|
|
|
|
|
|
|
| @dataclass
|
| class EpisodeCommand :
|
| episode_id :str =""
|
| config :Optional [dict ]=None
|
| duration_seconds :int =90
|
| server_ip :str =""
|
| server_port :int =443
|
| uuid :str =""
|
|
|
| def to_dict (self )->dict :
|
| return asdict (self )
|
|
|
| @classmethod
|
| def from_dict (cls ,d :dict )->"EpisodeCommand":
|
| obj =cls (**{k :v for k ,v in d .items ()if k !="config"})
|
| obj .config =d .get ("config")
|
| return obj
|
|
|
|
|
| @dataclass
|
| class ClientStatus :
|
| episode_id :str =""
|
| partial_metrics :Optional [dict ]=None
|
| phase :str ="idle"
|
|
|