mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-20 13:58:22 +00:00
95 lines
3.8 KiB
Markdown
95 lines
3.8 KiB
Markdown
# Development
|
|
|
|
This development guide assumes you have [Go](https://golang.org) installed on your development machine, and you have a flexible infrastructure environment where you can control a domain called `home.arpa` (*an example `Corefile` and `db.home.arpa` is provided for running with [CoreDNS](https://coredns.io/)*).
|
|
|
|
## Requirements
|
|
|
|
- An appropriate UNIX-like development workstation like Linux or macOS (*Windows is not recommended, unless you use WSL/WSL2*).
|
|
- [Go](https://golang.org) and [CoreDNS](https://coredns.io) installed.
|
|
- A cup of coffee ☕️
|
|
|
|
## Setup
|
|
|
|
1. Run `make deps` to install the required dependencies for this project. This will install [CoreDNS](https://coredns.io) and [MiniCA](https://github.com/jsha/minica)
|
|
2. Run `coredns` in a directory that contains the sample [Corefile](../Corefile) and [db.home.arpa](../db.home.arpa) to run a local authorities DNS server for the domain `home.arpa` used for development purposes.
|
|
3. Run `make certs` to create a CA and Certificates for `*.home.arpa`. You will have to add `certs/minica.pem` to your system's certificate trust store. This depends on your system, on macOS you can run `open certs/minica.pem` to open the Keychain utility and change the trust for the CA to "Always Trust".
|
|
|
|
## Building
|
|
|
|
To build the Salty broker `saltyd` and the command-line Client tools and TUI `salty-chat` run:
|
|
|
|
```shell
|
|
$ make dev
|
|
```
|
|
|
|
This will build all binaries and run the `saltyd` broker. You should see something like this on startup:
|
|
|
|
![](./screenshots/screenshot-make-dev.png)
|
|
|
|
## Configuration
|
|
|
|
The `salty-chat` command-line client which also includes a terminal ui (TUI) has a configuration file (in addition to command-line options and environment variables) to make it a bit easier to work with.
|
|
|
|
Setup a configuration file (`$HOME/.config/salty/config.json`) with JSON content similar to:
|
|
|
|
![](./screenshots/screenshot-salty-config.png)
|
|
|
|
**NB:** Note that this is taken from my own configuration file where I have setup a default identity and user for my public Salty Address `prologic@mills.io`.
|
|
|
|
## Identies and Registration
|
|
|
|
Creating an identity is as simple as running the `make-user` command:
|
|
|
|
```shell
|
|
$ ./salty-chat make-user user@domaiun
|
|
```
|
|
|
|
However this requires you to setup the Well-Known Configuration manually on a Web server on the Domain. See the [Spec](https://salty.im/spec.html) and the section on [Well-Known URI](https://salty.im/spec.html#well-known-uri).
|
|
|
|
Instead you can create an identity (key pair) and register it against a Salty Broker such as the one running locally from the `make dev` step above in [Building](#building).
|
|
|
|
```shell
|
|
$ ./salty-chat register user@domain [optional broker]
|
|
```
|
|
|
|
![](./screenshots/screenshot-register.png)
|
|
|
|
**NB:** Note that the Salty Broker to register against is looked up automatically from the DNS SRV record on the Domain. This is why the [DNS Setup](#dns-setup) step above is important and an important part of the [Discovery](https://salty.im/spec.html#discovery) process and [Delegation](https://salty.im/spec.html#delegation).
|
|
|
|
## Send and Read
|
|
|
|
Sending a message to a Salty User and reading from your Salty Inbox is straight forward.
|
|
|
|
To send a message:
|
|
|
|
```shell
|
|
$ ./salty-chat send <address> <message|->
|
|
```
|
|
|
|
And to read from your inbox:
|
|
|
|
```shell
|
|
$ ./salty-chat read
|
|
```
|
|
|
|
For example (sending a message to `bar@home.arpa` from `foo@home.arpa` and reading our `bar@home.arpa` inbox)"
|
|
|
|
![](./screenshots/screenshot-send-read.png)
|
|
|
|
## Chat Client (TUI)
|
|
|
|
In addition to various commands for managing identities, registration, sending and receiving messages, there is also a builtin Terminal UI (TUI) client. Simple run with:
|
|
|
|
```shell
|
|
$ ./salty-chat chat <address>
|
|
|
|
```
|
|
|
|
For example chatting with `bar@home.arpa` from `foo@home.arpa`:
|
|
|
|
![](./screenshots/screenshot-chat-foo.png)
|
|
|
|
And the other way around:
|
|
|
|
![](./screenshots/screenshot-chat-bar.png)
|