Metadata-Version: 2.4
Name: py-ftpchat
Version: 0.2.0
Summary: A messenger where messages are literally files on an FTP server. Terminal client + browser gateway on one LAN host.
Author: ftpchat contributors
License-Expression: MIT
Keywords: ftp,messenger,chat,networking,browser,lan
Classifier: Environment :: Console
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Communications :: Chat
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: server
Requires-Dist: pyftpdlib>=1.5; extra == "server"
Dynamic: license-file

# FTP Chat

A messenger where messages are literally **files on an FTP server**. One
device on the LAN hosts the chat; every other device joins from a **browser**
(or the terminal client) — everything on the wire is FTP into that store.

## How it works

```
        browser on phone/PC                 terminal client
             │  HTTP/JSON                         │ ftplib
             ▼                                   ▼
      ftpchat-web (HTTP gateway)          ftpchat (terminal)
             │  FTP (ftplib -> localhost)         │
             ▼                                   ▼
        ┌────────────────────────┐
        │  pyftpdlib FTP server  │   storage = files:
        │  rooms/general/*.txt   │   rooms/general/<ms>-<nick>.txt
        │  users/<name>/*.txt    │
        └────────────────────────┘
```

The host runs **one process** (`ftpchat-web`) that starts the FTP server and
the browser gateway. The gateway itself speaks FTP to the local FTP server, so
even the browser traffic becomes FTP file reads/writes.

## Run (host PC)

```
pip install -e ".[server]"
ftpchat-web
```

It prints the addresses to use, e.g.:

```
ftp (store):   127.0.0.1:2121
browser:       http://192.168.0.5:8080
terminal:      ftpchat --host <local-ip> --port 2121 --user name
```

* **Browser**: open `http://<host-ip>:8080` on any device in the network —
  type a nickname and chat. No apps, no installs.
* **Terminal client**: `ftpchat --host <host-ip> --user alice` (auto-registers
  on first login). Commands: `/r <room>` `/to <user>` `/inbox` `/outbox`
  `/users` `/rooms` `/refresh` `/quit`.

Windows: double-click `ftpchat-web.bat` (from the launcher) to run the host.

## Storage

Messages are plain files named `<milliseconds>-<nick>.txt`:

```
from: phone
at: 1789234637227
room: general

привет с браузера
```

Inspect the host folder (default `.ftpchat/rooms/general/`) to see every
message as a file; edit/delete files there if you like.

## Notes / security

* Toy for a trusted LAN. New FTP users auto-register with any password, and the
  authorizer hands everyone full access to the shared tree.
* No TLS on FTP or HTTP. Do not expose to the internet.
* Message text goes through FTP storage; the web page renders it with
  `textContent` (no HTML injection).
* Polling: browsers poll the gateway every 2 s, terminal polls the FTP store
  every 2 s.

## Tests

```
pip install -e ".[server]" pytest
pytest            # 20 tests: protocol, FTP core, web gateway
```
