@@ -137,7 +137,7 @@ def https_routes(inventory: Inventory, name: str) -> list[dict[str, Any]]:
137137 routes : list [dict [str , Any ]] = []
138138 entry_title = https .title or _host_title (name )
139139 if https .direct :
140- routes .append ({"name" : "direct" , "hostname" : https .endpoint , "title" : entry_title , "country_code" : name .split ("_" , 1 )[0 ].upper (), "port" : inventory .settings .https_chain_backend_port , "chain" : None , "probe_resistance" : https .probe_resistance .model_dump (mode = "json" )})
140+ routes .append ({"name" : "direct" , "hostname" : https .endpoint , "is_ip" : _is_ip ( https . endpoint ), " title" : entry_title , "country_code" : name .split ("_" , 1 )[0 ].upper (), "port" : inventory .settings .https_chain_backend_port , "chain" : None , "probe_resistance" : https .probe_resistance .model_dump (mode = "json" )})
141141 if inventory .settings .https_chains_enabled and https .chain_entry :
142142 configured_pairs = [pair for pair in inventory .settings .https_chain_pairs if pair .entry == name ]
143143 allowed_exits = {pair .exit for pair in configured_pairs } if inventory .settings .https_chain_pairs else None
@@ -153,9 +153,11 @@ def https_routes(inventory: Inventory, name: str) -> list[dict[str, Any]]:
153153 ]
154154 for index , (exit_name , exit_https ) in enumerate (exits , start = len (routes )):
155155 probe_resistance = pair_probe_resistance .get (exit_name ) or https .probe_resistance
156+ route_hostname = pair_hostnames .get (exit_name ) or f"{ _dns_label (name )} -via-{ _dns_label (exit_name )} .{ inventory .settings .https_chain_domain } "
156157 routes .append ({
157158 "name" : f"via-{ exit_name } " ,
158- "hostname" : pair_hostnames .get (exit_name ) or f"{ _dns_label (name )} -via-{ _dns_label (exit_name )} .{ inventory .settings .https_chain_domain } " ,
159+ "hostname" : route_hostname ,
160+ "is_ip" : _is_ip (route_hostname ),
159161 "title" : pair_titles .get (exit_name ) or entry_title ,
160162 "country_code" : pair_country_codes .get (exit_name ) or exit_name .split ("_" , 1 )[0 ].upper (),
161163 "port" : inventory .settings .https_chain_backend_port + index ,
@@ -169,6 +171,14 @@ def _dns_label(value: str) -> str:
169171 return re .sub (r"[^a-z0-9-]+" , "-" , value .lower ()).strip ("-" )
170172
171173
174+ def _is_ip (value : str ) -> bool :
175+ try :
176+ ipaddress .ip_address (value )
177+ except ValueError :
178+ return False
179+ return True
180+
181+
172182def _host_title (name : str ) -> str :
173183 parts = name .split ("_" )
174184 if parts [- 1 :] == ["proxy" ]:
0 commit comments