nord-config-generator 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,7 @@ class Server:
25
25
  station: str
26
26
  load: int
27
27
  country: str
28
+ country_code: str
28
29
  city: str
29
30
  latitude: float
30
31
  longitude: float
@@ -113,6 +114,7 @@ class ConfigurationOrchestrator:
113
114
  return None
114
115
 
115
116
  processed_servers = await self._process_server_data(all_servers_data, user_location)
117
+
116
118
  sorted_servers = sorted(processed_servers, key=lambda s: (s.load, s.distance))
117
119
  best_servers_by_location = self._get_best_servers(sorted_servers)
118
120
 
@@ -174,7 +176,7 @@ class ConfigurationOrchestrator:
174
176
  def _create_save_task(self, server: Server, subfolder: str, progress, task_id):
175
177
  config_str = self._generate_wireguard_config_string(server, self._preferences, self._private_key)
176
178
  path = self._output_dir / subfolder / self._sanitize_path_part(server.country) / self._sanitize_path_part(server.city)
177
- filename = f"{self._sanitize_path_part(server.name)}.conf"
179
+ filename = self._generate_compliant_filename(server)
178
180
  return self._save_config_file(config_str, path, filename, progress, task_id)
179
181
 
180
182
  async def _save_config_file(self, config_string: str, path: Path, filename: str, progress, task_id):
@@ -184,6 +186,17 @@ class ConfigurationOrchestrator:
184
186
  await f.write(config_string)
185
187
  progress.update(task_id, advance=1)
186
188
 
189
+ @staticmethod
190
+ def _generate_compliant_filename(server: Server) -> str:
191
+ server_number_match = re.search(r'\d+$', server.name)
192
+ if not server_number_match:
193
+ fallback_name = f"wg{server.station.replace('.', '')}"
194
+ return f"{fallback_name[:15]}.conf"
195
+
196
+ server_number = server_number_match.group(0)
197
+ base_name = f"{server.country_code}{server_number}"
198
+ return f"{base_name[:15]}.conf"
199
+
187
200
  @staticmethod
188
201
  def _generate_wireguard_config_string(server: Server, preferences: UserPreferences, private_key: str) -> str:
189
202
  endpoint = server.station if preferences.use_ip_for_endpoint else server.hostname
@@ -193,6 +206,8 @@ class ConfigurationOrchestrator:
193
206
  def _parse_server_data(server_data: Dict[str, Any], user_location: Tuple[float, float]) -> Optional[Server]:
194
207
  try:
195
208
  location = server_data['locations'][0]
209
+ country_info = location['country']
210
+
196
211
  public_key = next(
197
212
  m['value'] for t in server_data['technologies']
198
213
  if t['identifier'] == 'wireguard_udp'
@@ -204,7 +219,8 @@ class ConfigurationOrchestrator:
204
219
  return Server(
205
220
  name=server_data['name'], hostname=server_data['hostname'],
206
221
  station=server_data['station'], load=int(server_data.get('load', 0)),
207
- country=location['country']['name'], city=location['country'].get('city', {}).get('name', 'Unknown'),
222
+ country=country_info['name'], country_code=country_info['code'].lower(),
223
+ city=country_info.get('city', {}).get('name', 'Unknown'),
208
224
  latitude=location['latitude'], longitude=location['longitude'],
209
225
  public_key=public_key, distance=distance
210
226
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nord-config-generator
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: A command-line tool for generating optimized NordVPN WireGuard configurations.
5
5
  Author-email: Ahmed Touhami <mustafachyi272@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/mustafachyi/NordVPN-WireGuard-Config-Generator
@@ -0,0 +1,8 @@
1
+ nord_config_generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ nord_config_generator/main.py,sha256=vCBDo5-xWBhp7Qw39OtGi1PAX8aNnvmp3Giy2zbM950,14895
3
+ nord_config_generator/ui.py,sha256=r9ulCF3t8h9WlepXM4_LAdDLi8TFM9HufXrO95cMOOM,3148
4
+ nord_config_generator-1.0.3.dist-info/METADATA,sha256=ue3-udbGR-jWDw-8hBJWlJawc5Mx-5hgT_Qrw9YmcH8,3876
5
+ nord_config_generator-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ nord_config_generator-1.0.3.dist-info/entry_points.txt,sha256=TEZSrG2vKDWS4hcLAy-s65yjdxzcXAGbExHwWSYqd04,71
7
+ nord_config_generator-1.0.3.dist-info/top_level.txt,sha256=wGNt1MATKpHqIKJ3G0ByTkE2thqRe6xPZWrIU0FstSo,22
8
+ nord_config_generator-1.0.3.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- nord_config_generator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- nord_config_generator/main.py,sha256=EELR_yx8D6vUfg5wo6go69FVwbFxFnLvrg5WTl70p7o,14294
3
- nord_config_generator/ui.py,sha256=r9ulCF3t8h9WlepXM4_LAdDLi8TFM9HufXrO95cMOOM,3148
4
- nord_config_generator-1.0.1.dist-info/METADATA,sha256=cTwpoyCRtFxIeFKaIpZhJfcJ5ojHwzmIU-cRDDeeOww,3876
5
- nord_config_generator-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- nord_config_generator-1.0.1.dist-info/entry_points.txt,sha256=TEZSrG2vKDWS4hcLAy-s65yjdxzcXAGbExHwWSYqd04,71
7
- nord_config_generator-1.0.1.dist-info/top_level.txt,sha256=wGNt1MATKpHqIKJ3G0ByTkE2thqRe6xPZWrIU0FstSo,22
8
- nord_config_generator-1.0.1.dist-info/RECORD,,