a2qlinux 0.2.0__tar.gz → 0.3.0__tar.gz

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.
Files changed (47) hide show
  1. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/CHANGELOG.md +36 -0
  2. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/PKG-INFO +5 -3
  3. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/README.md +4 -2
  4. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/_version.py +2 -2
  5. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/bin/questlog_ctl.exe +0 -0
  6. a2qlinux-0.3.0/a2qlinux/bin/wpcap.dll +0 -0
  7. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/config.py +33 -3
  8. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/launcher.py +190 -31
  9. a2qlinux-0.3.0/a2qlinux/pcap_bridge.py +285 -0
  10. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/setup_desktop.py +18 -12
  11. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/update.py +3 -0
  12. a2qlinux-0.3.0/bridge/build.sh +84 -0
  13. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/bridge/tests/bridge_client_test.c +24 -7
  14. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/bridge/wpcap_bridge.c +151 -48
  15. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/docs/ARCHITECTURE.md +238 -27
  16. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/docs/INSTALL.md +71 -17
  17. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/docs/TROUBLESHOOTING.md +4 -2
  18. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/docs/USING.md +66 -2
  19. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/test_config.py +47 -1
  20. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/test_launcher.py +238 -0
  21. a2qlinux-0.3.0/tests/test_pcap_bridge.py +216 -0
  22. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/test_update.py +3 -2
  23. a2qlinux-0.2.0/a2qlinux/bin/wpcap.dll +0 -0
  24. a2qlinux-0.2.0/a2qlinux/pcap_bridge.py +0 -205
  25. a2qlinux-0.2.0/bridge/build.sh +0 -26
  26. a2qlinux-0.2.0/tests/test_pcap_bridge.py +0 -120
  27. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/.gitignore +0 -0
  28. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/LICENSE +0 -0
  29. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/__init__.py +0 -0
  30. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/desktop.py +0 -0
  31. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/steam.py +0 -0
  32. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/a2qlinux/tray.py +0 -0
  33. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/bridge/questlog_ctl.c +0 -0
  34. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/bridge/tests/zorder_guard_test.c +0 -0
  35. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/docs/README.md +0 -0
  36. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/docs/RELEASE.md +0 -0
  37. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/docs/UPDATING.md +0 -0
  38. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/pyproject.toml +0 -0
  39. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/__init__.py +0 -0
  40. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/test_desktop.py +0 -0
  41. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/test_replay_stream.py +0 -0
  42. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/test_setup_desktop.py +0 -0
  43. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tests/test_steam.py +0 -0
  44. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tools/__init__.py +0 -0
  45. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tools/pcap2questlog.py +0 -0
  46. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tools/replay_stream.py +0 -0
  47. {a2qlinux-0.2.0 → a2qlinux-0.3.0}/tools/tcp_owner_probe.c +0 -0
@@ -3,6 +3,42 @@
3
3
  What changed for players, release by release. Technical details are in
4
4
  `docs/ARCHITECTURE.md`.
5
5
 
6
+ ## [0.3.0] — 2026-11-08
7
+
8
+ ### Added
9
+ - Playing through a VPN needs no setting. A2Qlinux listens on all network
10
+ connections at once (cable, Wi-Fi, VPN), and Questlog reads the game on
11
+ whichever one it uses. A VPN changing servers during play is picked up
12
+ within seconds, without a restart.
13
+ - When the VPN is switched off during play, the status window and a
14
+ notification say that the game's connection has lost its network and the
15
+ game has to reconnect.
16
+ - A warning in the status window and a notification when the game runs
17
+ through a connection that `interface` in the settings file leaves out.
18
+ - `interface` can name several connections, as a list:
19
+ `interface = ["eth0", "wg0"]`.
20
+
21
+ ### Changed
22
+ - A2Qlinux no longer refuses to start when the computer has more than one
23
+ network connection, for example with a VPN on.
24
+ - The status window no longer prints a line every time Questlog reconnects
25
+ to the game traffic, which it does on every zone change. It names the
26
+ connection Questlog follows, once, and again only when that changes;
27
+ problems are still reported as before.
28
+
29
+ ## [0.2.1] — 2026-11-05
30
+
31
+ ### Fixed
32
+ - `a2qlinux-setup --questlog-dir <folder>` now always takes effect: the
33
+ folder is written into the settings file even when that file already
34
+ exists, and the other settings in it stay as they were.
35
+
36
+ ### Changed
37
+ - Installing from the source code is one command, `install-from-source.sh`,
38
+ which builds, installs and sets up. The build looks for Wine's files where
39
+ the distributions in the install guide keep them, and names missing build
40
+ tools with the command that installs them.
41
+
6
42
  ## [0.2.0] — 2026-11-05
7
43
 
8
44
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: a2qlinux
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Questlog Desktop (AION 2 damage meter) on Linux under Proton, with live game traffic.
5
5
  Project-URL: homepage, https://github.com/raman78/A2Qlinux
6
6
  Project-URL: repository, https://github.com/raman78/A2Qlinux
@@ -116,12 +116,14 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
116
116
  | `a2qlinux/setup_desktop.py` | `a2qlinux-setup`: dependency and capture checks with install commands, Questlog installation, menu entry, icon |
117
117
  | `a2qlinux/bin/` | the built Windows parts (shipped in the package, not in git) |
118
118
  | `bridge/` | Windows parts in C: `wpcap.dll` stand-in, `questlog_ctl.exe`, their tests; `build.sh` |
119
+ | `install-from-source.sh` | installs this checkout for development: build, editable pipx install, setup |
119
120
  | `tests/` | Python tests: `python3 -m unittest` |
120
121
  | `tools/` | diagnostics: replay-file tools, TCP-owner probe |
121
122
 
122
123
  The Windows parts are built with `clang` against the installed Wine's headers
123
- (`bridge/build.sh`) — by the release workflow for the packages, by hand in a
124
- source checkout; built files are not kept in the repository. Releasing:
124
+ (`bridge/build.sh`) — by the release workflow for the packages, by
125
+ `install-from-source.sh` in a source checkout; built files are not kept in
126
+ the repository. Releasing:
125
127
  [docs/RELEASE.md](https://github.com/raman78/A2Qlinux/blob/main/docs/RELEASE.md).
126
128
 
127
129
  ## Not affiliated
@@ -74,12 +74,14 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
74
74
  | `a2qlinux/setup_desktop.py` | `a2qlinux-setup`: dependency and capture checks with install commands, Questlog installation, menu entry, icon |
75
75
  | `a2qlinux/bin/` | the built Windows parts (shipped in the package, not in git) |
76
76
  | `bridge/` | Windows parts in C: `wpcap.dll` stand-in, `questlog_ctl.exe`, their tests; `build.sh` |
77
+ | `install-from-source.sh` | installs this checkout for development: build, editable pipx install, setup |
77
78
  | `tests/` | Python tests: `python3 -m unittest` |
78
79
  | `tools/` | diagnostics: replay-file tools, TCP-owner probe |
79
80
 
80
81
  The Windows parts are built with `clang` against the installed Wine's headers
81
- (`bridge/build.sh`) — by the release workflow for the packages, by hand in a
82
- source checkout; built files are not kept in the repository. Releasing:
82
+ (`bridge/build.sh`) — by the release workflow for the packages, by
83
+ `install-from-source.sh` in a source checkout; built files are not kept in
84
+ the repository. Releasing:
83
85
  [docs/RELEASE.md](https://github.com/raman78/A2Qlinux/blob/main/docs/RELEASE.md).
84
86
 
85
87
  ## Not affiliated
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.2.0'
22
- __version_tuple__ = version_tuple = (0, 2, 0)
21
+ __version__ = version = '0.3.0'
22
+ __version_tuple__ = version_tuple = (0, 3, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
Binary file
@@ -39,8 +39,10 @@ class Setting:
39
39
  SETTINGS = {
40
40
  "questlog_dir": Setting("~/Games/Questlog", str,
41
41
  "Folder with Questlog.exe (the QUESTLOG_DIR environment variable overrides it)."),
42
- "interface": Setting("", str,
43
- "Network interface carrying the game's traffic; empty: the only one besides lo."),
42
+ "interface": Setting("", (str, list),
43
+ 'Network interfaces to capture on: a name, or a list such as ["eth0", "wg0"]; '
44
+ "empty: every one with an IPv4 address besides lo (Questlog follows the game's "
45
+ "connection on whichever it uses, a VPN included)."),
44
46
  "after_game": Setting("keep", str,
45
47
  '"keep": Questlog stays open after the game, and Steam sees the game as closed; '
46
48
  '"close": Questlog closes with the game.',
@@ -58,7 +60,7 @@ SETTINGS = {
58
60
  @dataclass(frozen=True)
59
61
  class Settings:
60
62
  questlog_dir: Path
61
- interface: str
63
+ interface: tuple
62
64
  after_game: str
63
65
  after_game_delay: float
64
66
  auto_update: bool
@@ -99,6 +101,10 @@ def load(path=CONFIG_PATH):
99
101
  problems.append(f"{where}: '{name}' must be {_kind_name(spec.kind)}, not {value!r}; "
100
102
  f"using {spec.default!r}.")
101
103
  continue
104
+ if isinstance(value, list) and not all(isinstance(item, str) and item for item in value):
105
+ problems.append(f"{where}: '{name}' must list interface names as quoted texts, not {value!r}; "
106
+ f"using {spec.default!r}.")
107
+ continue
102
108
  if spec.choices and value not in spec.choices:
103
109
  problems.append(f"{where}: '{name}' must be one of {', '.join(map(repr, spec.choices))}, "
104
110
  f"not {value!r}; using {spec.default!r}.")
@@ -110,6 +116,8 @@ def load(path=CONFIG_PATH):
110
116
  values[name] = value
111
117
  env_dir = os.environ.get("QUESTLOG_DIR")
112
118
  values["questlog_dir"] = Path(env_dir or values["questlog_dir"]).expanduser()
119
+ interface = values["interface"]
120
+ values["interface"] = tuple(interface) if isinstance(interface, list) else ((interface,) if interface else ())
113
121
  values["after_game_delay"] = float(values["after_game_delay"])
114
122
  values["update_check_hours"] = float(values["update_check_hours"])
115
123
  return Settings(**values), problems
@@ -120,6 +128,8 @@ def _kind_name(kind):
120
128
  return "true or false"
121
129
  if kind is str:
122
130
  return "a quoted text"
131
+ if kind == (str, list):
132
+ return "a quoted text or a list of them"
123
133
  return "a number"
124
134
 
125
135
 
@@ -140,6 +150,26 @@ def template(questlog_dir=None):
140
150
  return "\n".join(lines)
141
151
 
142
152
 
153
+ def set_questlog_dir(questlog_dir, path=CONFIG_PATH):
154
+ """Write `questlog_dir` into the settings file, for a2qlinux-setup --questlog-dir.
155
+
156
+ A missing file is created from template(); in an existing one only the
157
+ questlog_dir line changes (or is added), so the user's other settings and
158
+ comments stay as they are.
159
+ """
160
+ path = Path(path)
161
+ line = f"questlog_dir = {_toml(str(questlog_dir))}"
162
+ if not path.exists():
163
+ path.parent.mkdir(parents=True, exist_ok=True)
164
+ path.write_text(template(questlog_dir))
165
+ return
166
+ text = path.read_text()
167
+ new, count = re.subn(r"(?m)^[ \t]*questlog_dir[ \t]*=.*$", lambda _: line, text, count=1)
168
+ if not count:
169
+ new = text + ("" if text.endswith("\n") or not text else "\n") + line + "\n"
170
+ path.write_text(new)
171
+
172
+
143
173
  def _toml(value):
144
174
  if isinstance(value, bool):
145
175
  return "true" if value else "false"
@@ -6,9 +6,10 @@ C:\\Windows\\System32\\Npcap\\wpcap.dll. Npcap is a Windows driver that cannot
6
6
  work under Wine, so this launcher puts our own wpcap.dll there (built from
7
7
  bridge/wpcap_bridge.c) and feeds it from dumpcap on the Linux side:
8
8
 
9
- dumpcap (TCP 13328) -> BridgeServer on 127.0.0.1 -> wpcap.dll -> Questlog
9
+ dumpcap per interface (TCP 13328) -> BridgeServer on 127.0.0.1 -> wpcap.dll -> Questlog
10
10
 
11
- Questlog then runs its normal live capture loop, as on Windows.
11
+ Questlog then runs its normal live capture loop, as on Windows, and picks
12
+ the interface whose address its game connection uses (Captures).
12
13
 
13
14
  Run it as your normal user (dumpcap through the `wireshark` group). Questlog
14
15
  opens at once, game or not.
@@ -31,6 +32,7 @@ import shutil
31
32
  import signal
32
33
  import socket
33
34
  import stat
35
+ import struct
34
36
  import subprocess
35
37
  import sys
36
38
  import threading
@@ -247,7 +249,8 @@ def interface_address(name):
247
249
  return socket.inet_ntoa(result[20:24])
248
250
 
249
251
 
250
- def choose_interface(requested):
252
+ def usable_interfaces():
253
+ """{name: IPv4 address} of every interface besides lo that has one."""
251
254
  usable = {}
252
255
  for _, name in socket.if_nameindex():
253
256
  if name == "lo":
@@ -256,15 +259,7 @@ def choose_interface(requested):
256
259
  usable[name] = interface_address(name)
257
260
  except OSError:
258
261
  continue
259
- if requested:
260
- if requested not in usable:
261
- raise RuntimeError(f"Interface {requested} has no IPv4 address. Usable: {', '.join(usable) or 'none'}.")
262
- return requested, usable[requested]
263
- if len(usable) == 1:
264
- return next(iter(usable.items()))
265
- if not usable:
266
- raise RuntimeError("No network interface with an IPv4 address was found.")
267
- raise RuntimeError(f"Several interfaces are up ({', '.join(usable)}); choose one with --interface.")
262
+ return usable
268
263
 
269
264
 
270
265
  def start_dumpcap(dumpcap, interface, address):
@@ -283,17 +278,183 @@ def stop_process(process):
283
278
  process.wait(timeout=3)
284
279
 
285
280
 
286
- def pump_records(stream, server, status):
287
- """Thread body: hand dumpcap's packets to the bridge; record how it ended."""
281
+ # Link types Questlog's frame decoder reads (Ethernet; BSD loopback; raw IP, as
282
+ # on WireGuard and OpenVPN tun); frames of any other type it skips without a word.
283
+ QUESTLOG_LINKTYPES = {1: "Ethernet", 0: "loopback", 108: "loopback", 12: "raw IP", 101: "raw IP"}
284
+
285
+
286
+ def pump_records(name, stream, server, status, capture, log=log):
287
+ """Thread body: hand one interface's packets to the bridge; record how it ended."""
288
288
  try:
289
289
  for header, record in read_records(stream):
290
- server.publish(header, record)
290
+ if header is not None:
291
+ linktype = struct.unpack("<I", header[20:24])[0]
292
+ if linktype not in QUESTLOG_LINKTYPES:
293
+ log(f"Interface {name} delivers link type {linktype}, which Questlog cannot read "
294
+ f"(it reads {', '.join(sorted(set(QUESTLOG_LINKTYPES.values())))}); "
295
+ "game traffic on it will not be counted.")
296
+ server.publish(name, header, record)
291
297
  if record is not None:
292
298
  status["packets"] += 1
293
299
  status["last_packet"] = time.monotonic()
294
- status["error"] = "dumpcap stopped. Check capture permission: run a2qlinux-setup, which tests it and says what to do."
300
+ capture["error"] = "dumpcap stopped"
295
301
  except (ValueError, OSError) as error:
296
- status["error"] = f"Capture stream unreadable: {error}"
302
+ capture["error"] = f"capture stream unreadable: {error}"
303
+
304
+
305
+ CAPTURE_SCAN_EVERY = 3 # s between looks at which interfaces are up (a VPN coming up or going down)
306
+ CAPTURE_RETRY_EVERY = 30 # s before a dumpcap that failed on an interface still up is tried again
307
+
308
+
309
+ def interface_index(name):
310
+ """The kernel's index of an interface, or None when it is gone. An interface
311
+ deleted and created again under the same name (a VPN switching servers)
312
+ gets a new index, while a link going down and up keeps it."""
313
+ try:
314
+ return socket.if_nametoindex(name)
315
+ except OSError:
316
+ return None
317
+
318
+
319
+ def game_connection_addresses(path="/proc/net/tcp"):
320
+ """Local IPv4 addresses of established connections to the game's port, from the kernel's table."""
321
+ addresses = set()
322
+ for line in _read(path, limit=4 << 20).splitlines()[1:]:
323
+ fields = line.split()
324
+ if len(fields) < 4 or fields[3] != "01": # 01 = ESTABLISHED
325
+ continue
326
+ local, remote = fields[1], fields[2]
327
+ if int(remote.split(":")[1], 16) != GAME_PORT:
328
+ continue
329
+ addresses.add(socket.inet_ntoa(struct.pack("<I", int(local.split(":")[0], 16))))
330
+ return addresses
331
+
332
+
333
+ class Captures:
334
+ """One dumpcap per usable interface, kept in step with the interfaces that are up.
335
+
336
+ Each interface is a channel of the bridge; Questlog chooses among them by
337
+ the address of its game connection (pcap_findalldevs), so whichever one
338
+ the game uses - the network card, a VPN - is the one it reads. `wanted`
339
+ (settings `interface`, --interface) limits capture to those names; empty
340
+ means every interface with an IPv4 address besides lo.
341
+ """
342
+
343
+ def __init__(self, dumpcap, server, wanted, status, log=log, notify=None, interfaces=usable_interfaces,
344
+ start=None, game_addresses=game_connection_addresses, index_of=interface_index):
345
+ self.dumpcap = dumpcap
346
+ self.server = server
347
+ self.wanted = tuple(wanted)
348
+ self.status = status
349
+ self.log = log
350
+ self.notify = notify or (lambda text: None)
351
+ self.interfaces = interfaces
352
+ self.start = start or start_dumpcap
353
+ self.game_addresses = game_addresses
354
+ self.index_of = index_of
355
+ self.reported = set() # (name, address) whose failure was reported: once per launcher run
356
+ self.told_uncaptured = set()
357
+ self.running = {} # name -> {"address", "index", "process", "error"}
358
+ self.failed = {} # name -> (address, retry at): dumpcap failed there; retried at that time,
359
+ # or at once when the address changes
360
+ self.told_missing = set()
361
+ self.told_none = False
362
+ self.next_scan = 0.0
363
+
364
+ def scan(self, now=None):
365
+ now = time.monotonic() if now is None else now
366
+ if now < self.next_scan:
367
+ return
368
+ self.next_scan = now + CAPTURE_SCAN_EVERY
369
+ up = self.interfaces()
370
+ every_address = set(up.values()) # before the settings' filter: which addresses exist at all
371
+ if self.wanted:
372
+ for name in self.wanted:
373
+ if name not in up and name not in self.told_missing:
374
+ self.log(f"Interface {name} (from the settings) is not up or has no IPv4 address; "
375
+ f"capture starts on it when it comes up. Up now: {', '.join(up) or 'none'}.")
376
+ self.told_missing.add(name)
377
+ elif name in up:
378
+ self.told_missing.discard(name)
379
+ up = {name: address for name, address in up.items() if name in self.wanted}
380
+ for name, capture in list(self.running.items()):
381
+ if name not in up:
382
+ self._stop(name)
383
+ self.log(f"Interface {name} is gone (a VPN switched off?); capture there stopped.")
384
+ elif up[name] != capture["address"]:
385
+ self._stop(name)
386
+ self.log(f"Interface {name} changed its address from {capture['address']} to {up[name]}; "
387
+ "capturing there again.")
388
+ elif self.index_of(name) != capture["index"]:
389
+ # Deleted and created again between two scans (a VPN switching servers takes
390
+ # under a second): dumpcap ended with the old interface; not a failure.
391
+ self._stop(name)
392
+ self.log(f"Interface {name} was created anew (a VPN reconnecting?); capturing there again.")
393
+ elif capture["process"].poll() is not None:
394
+ self._stop(name)
395
+ self.failed[name] = (capture["address"], now + CAPTURE_RETRY_EVERY)
396
+ if (name, capture["address"]) in self.reported:
397
+ continue
398
+ self.reported.add((name, capture["address"]))
399
+ reason = capture["error"] or "dumpcap stopped"
400
+ self.log(f"Capture on {name} ({capture['address']}) ended: {reason} "
401
+ f"(dumpcap exit code {capture['process'].returncode}; its own message is above). "
402
+ "Run a2qlinux-setup, which tests capture permission and says what to do. "
403
+ f"{name} is tried again every {CAPTURE_RETRY_EVERY} s, and at once when its "
404
+ "address changes; this is not reported again.")
405
+ self.notify(f"Capture on {name} stopped, so Questlog gets no game data from it. "
406
+ "Details in the A2Qlinux window.")
407
+ for name in [n for n, (address, retry_at) in self.failed.items()
408
+ if address != up.get(n) or now >= retry_at]:
409
+ del self.failed[name]
410
+ for name, address in up.items():
411
+ if name in self.running or name in self.failed:
412
+ continue
413
+ self.server.add_interface(name, address)
414
+ capture = {"address": address, "index": self.index_of(name),
415
+ "process": self.start(self.dumpcap, name, address), "error": None}
416
+ self.running[name] = capture
417
+ threading.Thread(target=pump_records, args=(name, capture["process"].stdout, self.server,
418
+ self.status, capture, self.log), daemon=True).start()
419
+ self.log(f"Capturing on {name} ({address}), TCP port {GAME_PORT}.")
420
+ if not up and not self.told_none:
421
+ self.log("No network interface with an IPv4 address is up" + (" among those in the settings"
422
+ if self.wanted else "") + "; capture starts as soon as one is.")
423
+ self.told_none = True
424
+ elif up:
425
+ self.told_none = False
426
+ self._check_game_connection(every_address)
427
+
428
+ def _check_game_connection(self, every_address):
429
+ """Say so when the game's connection uses an address no capture covers: Questlog would get nothing."""
430
+ captured = {capture["address"]: name for name, capture in self.running.items()}
431
+ uncaptured = self.game_addresses() - set(captured)
432
+ for address in uncaptured - self.told_uncaptured:
433
+ if address not in every_address:
434
+ # The kernel keeps a connection "established" after its address has gone (a VPN
435
+ # switched off) until the game gives up on it; nothing passes there meanwhile.
436
+ self.log(f"AION 2's connection to its server still uses {address}, which no network interface "
437
+ "has any more (a VPN switched off?). Nothing can pass on that connection: the game "
438
+ "has to reconnect, and Questlog follows it once it has.")
439
+ self.notify(f"AION 2's connection lost its network ({address} is gone, a VPN switched off?); "
440
+ "the game has to reconnect.")
441
+ continue
442
+ why = (f"the setting 'interface' limits capture to {', '.join(self.wanted)}" if self.wanted
443
+ else "no capture runs on its interface")
444
+ self.log(f"AION 2's connection to its server uses {address}, which A2Qlinux does not capture on "
445
+ f"({why}), so Questlog gets no game data. Capturing on: "
446
+ f"{', '.join(f'{n} ({a})' for a, n in captured.items()) or 'nothing'}.")
447
+ self.notify(f"AION 2 uses {address}, which A2Qlinux does not capture on. Details in the A2Qlinux window.")
448
+ self.told_uncaptured = uncaptured
449
+
450
+ def _stop(self, name):
451
+ capture = self.running.pop(name)
452
+ self.server.remove_interface(name)
453
+ stop_process(capture["process"])
454
+
455
+ def stop(self):
456
+ for name in list(self.running):
457
+ self._stop(name)
297
458
 
298
459
 
299
460
  # ------------------------------------------------------------------- session
@@ -805,9 +966,9 @@ def close_questlog(prefix, protontricks, log_path):
805
966
  ender.wait(timeout=5)
806
967
 
807
968
 
808
- def launch_questlog(executable, server, address, protontricks, log_path, hidden=False):
969
+ def launch_questlog(executable, server, protontricks, log_path, hidden=False):
809
970
  env = os.environ.copy()
810
- env["QUESTLOG_PROTON_BRIDGE"] = server.environment_value(address)
971
+ env["QUESTLOG_PROTON_BRIDGE"] = server.environment_value()
811
972
  # Wine ships a builtin wpcap.dll and loads it instead of ours even when
812
973
  # Questlog names our file by full path; "n" makes it take the native file.
813
974
  overrides = [o for o in env.get("WINEDLLOVERRIDES", "").split(";") if o and not o.startswith("wpcap=")]
@@ -833,8 +994,9 @@ def main():
833
994
  parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter,
834
995
  epilog=f"Settings file: {config.CONFIG_PATH} (options here override it).")
835
996
  parser.add_argument("--exe", type=Path, default=default_exe, help=f"Questlog.exe (default {default_exe})")
836
- parser.add_argument("--interface", default=settings.interface or None,
837
- help="network interface carrying the game connection")
997
+ parser.add_argument("--interface", action="append", metavar="NAME",
998
+ help="capture only on this network interface (repeat for several; default: every "
999
+ "interface with an IPv4 address, and Questlog follows the game's connection)")
838
1000
  parser.add_argument("--no-auto-update", action="store_true",
839
1001
  help="do not download or install new Questlog versions (default: download them "
840
1002
  "in the background and install them at the next start)")
@@ -865,7 +1027,6 @@ def main():
865
1027
  state_dir = executable.parent / "proton-stream"
866
1028
  session_lock(state_dir)
867
1029
  dumpcap = system_dumpcap()
868
- interface, address = choose_interface(args.interface)
869
1030
  running = game_processes(APPID, ["questlog.exe"])["questlog.exe"]
870
1031
  if running:
871
1032
  fed = any("QUESTLOG_PROTON_BRIDGE=" in _read(f"/proc/{pid}/environ") for pid in running)
@@ -875,10 +1036,9 @@ def main():
875
1036
  raise RuntimeError("Questlog is already running in the game prefix without the capture bridge. "
876
1037
  "Quit it (tray icon > Quit) and run this again.")
877
1038
  server = BridgeServer(log)
878
- capture = start_dumpcap(dumpcap, interface, address)
879
- status = {"packets": 0, "error": None}
880
- threading.Thread(target=pump_records, args=(capture.stdout, server, status), daemon=True).start()
881
- log(f"Capturing on {interface} ({address}), TCP port {GAME_PORT}.")
1039
+ status = {"packets": 0}
1040
+ captures = Captures(dumpcap, server, args.interface or settings.interface, status, notify=notify)
1041
+ captures.scan()
882
1042
  tray = None
883
1043
  try:
884
1044
  game_seen = bool(game_processes(APPID, ["aion2.exe"])["aion2.exe"])
@@ -903,13 +1063,13 @@ def main():
903
1063
  if auto_update and questlog_update.install_staged(executable.parent, state_dir, log):
904
1064
  trial["until"] = time.monotonic() + UPDATE_TRIAL
905
1065
  log(f"Starting Questlog {questlog_update.installed_version(executable.parent) or '(version unknown)'}.")
906
- started = launch_questlog(executable, server, address, protontricks, log_path, hidden=hidden)
1066
+ started = launch_questlog(executable, server, protontricks, log_path, hidden=hidden)
907
1067
  tray.start()
908
1068
  hide_questlog_tray_icon(protontricks, log_path)
909
1069
  return started
910
1070
 
911
1071
  def start_again():
912
- return launch_questlog(executable, server, address, protontricks, log_path)
1072
+ return launch_questlog(executable, server, protontricks, log_path)
913
1073
 
914
1074
  questlog = start_questlog()
915
1075
  if auto_update:
@@ -994,8 +1154,7 @@ def main():
994
1154
  questlog = start_questlog()
995
1155
  told = False
996
1156
  continue
997
- if status["error"]:
998
- raise RuntimeError(status["error"])
1157
+ captures.scan()
999
1158
  if not told and status["packets"] and server.client_count():
1000
1159
  log("Game traffic is flowing to Questlog.")
1001
1160
  told = True
@@ -1068,8 +1227,8 @@ def main():
1068
1227
  # Ending while Questlog runs on (Ctrl+C, an error): give it its own tray icon back.
1069
1228
  if game_processes(APPID, ["questlog.exe"])["questlog.exe"]:
1070
1229
  run_ctl(protontricks, "show-tray", log_path)
1230
+ captures.stop()
1071
1231
  server.stop()
1072
- stop_process(capture)
1073
1232
  except (OSError, RuntimeError) as error:
1074
1233
  print(f"a2qlinux: {error}", file=sys.stderr)
1075
1234
  return 1