# luan:host/Hosting.luan

The client side of Luan hosting. The command-line scripts in `luan:host/` wrap these functions: `push.luan domain password dir`, `push_file.luan`, `delete.luan`, `change_domain.luan`, `change_password.luan`, `backup.luan`, `restore.luan`.

- `Hosting.push(domain, password, dir)`: connects to the hosting server for `domain` by RPC (`Rpc.remote`, port 9101), creating the site if it doesn't exist (which sets its password). Then it syncs `dir` to the site: copies files that are new or whose checksum differs, creates missing directories, and deletes remote entries that don't exist locally. It skips `.DS_Store` and any directory named `local`, which is also never deleted on the server, so runtime data kept there survives pushes. Finally it reloads the site (`update_handler`), so new Luan code takes effect without restarting the server.
- `Hosting.push_file(domain, password, dir, file)`: copies one file (which must be inside `dir`) to the same place in the site, then reloads.
- `Hosting.delete(domain, password)`, `Hosting.exists(domain)`, `Hosting.change_domain(old, new, password)`, `Hosting.change_password(domain, old, new)`.
- `Hosting.caller(domain)`: returns a table whose functions call the site's own `Rpc.functions` (e.g. `Hosting.caller(domain).lucene_backup(password,name)`); `close()` closes the connection. The site function must check the password itself.
- Server side (`src/luan/host/main.luan`): the RPC functions check the password stored in `<sites>/<domain>/info.luan`; a site's files are in `<sites>/<domain>/site`. RPC uses anonymous TLS: encrypted, but the server isn't authenticated.
