Add dvs_enc.py and document the two-module requirement

The client imports its backend from a module named `dvs_enc`, but the
repository only shipped that backend as `qtmain.py`. Starting the application
from a fresh clone therefore failed immediately:

    ModuleNotFoundError: No module named 'dvs_enc'

`dvs_enc.py` is now included. It carries the same content as `qtmain.py`, so
the import resolves to the identical implementation.

Verified end to end:

  - without dvs_enc.py: import qtmain raises ModuleNotFoundError
  - with dvs_enc.py:    import qtmain succeeds, all 14 backend classes present

Functional tests against a clean copy of the repository pass: text
round-trip, 4096-byte binary round-trip, HMAC authentication, AccountDB and
HistoryDB construction.

Also exercised the full client/server protocol against a live relay: register,
login, create group, join group, and ciphertext relay between two clients.
The relay forwards the payload verbatim without inspecting it.

Documentation
- README: new "Module layout" section explaining why both files are required,
  and what the failure looks like when dvs_enc.py is absent; repository layout
  and troubleshooting table updated to match
- CHANGELOG: structure table updated
This commit is contained in:
dvs
2026-09-27 17:16:56 +08:00
parent faf60fd2e5
commit a2d492e9f8
3 changed files with 4189 additions and 2 deletions
+6
View File
@@ -35,8 +35,14 @@ licence.
| File | Role | | File | Role |
|---|---| |---|---|
| `qtmain.py` | PyQt5 client together with the complete backend | | `qtmain.py` | PyQt5 client together with the complete backend |
| `dvs_enc.py` | The backend module that `qtmain.py` imports at runtime |
| `server.py` | Optional central relay server, standard library only | | `server.py` | Optional central relay server, standard library only |
`dvs_enc.py` carries the same content as `qtmain.py`. The client imports its
backend classes from `dvs_enc`, so both files must be present in the same
directory or startup fails. Shipping it explicitly makes the package complete
on its own.
### Notes ### Notes
The application code is byte-for-byte identical to the version shipped with The application code is byte-for-byte identical to the version shipped with
+36 -2
View File
@@ -60,6 +60,7 @@ the scope is deliberately narrow.
``` ```
ChaosCryptChat/ ChaosCryptChat/
├── qtmain.py PyQt5 client + the entire backend ├── qtmain.py PyQt5 client + the entire backend
├── dvs_enc.py the backend, under the name the client imports it by
└── server.py optional central relay server (standard library only) └── server.py optional central relay server (standard library only)
``` ```
@@ -68,6 +69,10 @@ the account and history databases, the peer-to-peer networking layer, the
relay client, and the graphical interface. Running it directly starts the relay client, and the graphical interface. Running it directly starts the
client. client.
`dvs_enc.py` holds the same backend content under the module name the client
imports at runtime. **Both files must be present.** See
[Module layout](#module-layout) below.
`server.py` is deliberately independent and uses **only the Python standard `server.py` is deliberately independent and uses **only the Python standard
library**, so it can be deployed on a bare server without installing anything. library**, so it can be deployed on a bare server without installing anything.
@@ -109,6 +114,33 @@ handshake and command set are visible in the `_dispatch` methods of
--- ---
## Module layout
The client expects its backend under the module name `dvs_enc`, and the
distribution ships that backend as `qtmain.py`. Both files must sit in the
same directory:
```
qtmain.py the application; run this
dvs_enc.py the backend module that qtmain.py imports
server.py the relay server; run this separately if you need it
```
`qtmain.py` defines the backend classes itself and then imports the same names
from `dvs_enc`. Because `dvs_enc.py` carries the identical content, the import
resolves to the same implementation and the application behaves consistently
whether it is launched as `python qtmain.py` or imported.
If `dvs_enc.py` is missing, starting the client fails immediately with:
```
ModuleNotFoundError: No module named 'dvs_enc'
```
So when copying the project, copy all three files — not just `qtmain.py`.
---
## Requirements ## Requirements
### Client (`qtmain.py`) ### Client (`qtmain.py`)
@@ -241,6 +273,7 @@ repository.
| Symptom | Likely cause | | Symptom | Likely cause |
|---|---| |---|---|
| `ModuleNotFoundError: dvs_enc` | `dvs_enc.py` not copied alongside `qtmain.py` |
| `ModuleNotFoundError: PyQt5` | Client dependencies not installed | | `ModuleNotFoundError: PyQt5` | Client dependencies not installed |
| No audio devices listed | `sounddevice` or PortAudio missing | | No audio devices listed | `sounddevice` or PortAudio missing |
| Peers cannot connect in P2P mode | Firewall blocking the port, or NAT; use the relay | | Peers cannot connect in P2P mode | Firewall blocking the port, or NAT; use the relay |
@@ -259,8 +292,9 @@ repository.
├── LICENSE MIT ├── LICENSE MIT
├── CHANGELOG.md release history ├── CHANGELOG.md release history
├── .gitignore ├── .gitignore
├── qtmain.py client and backend ├── qtmain.py client and backend; run this for the client
└── server.py relay server ├── dvs_enc.py backend module imported by the client
└── server.py relay server; run this separately
``` ```
--- ---
+4147
View File
File diff suppressed because it is too large Load Diff