README.md 3.35 KB
Newer Older
Giovane Liberato's avatar
Giovane Liberato committed
1
# Prosody server with a OTRv4 prekey server included
2

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
3
A docker composed infrastructure containing a [prosody](https://prosody.im/) xmpp server and a [OTRv4](https://github.com/otrv4/libotr-ng) prekey server added to it. 
Giovane Liberato's avatar
Giovane Liberato committed
4

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
5 6 7 8 9 10 11 12 13 14
It also has some [dummy accounts](#available-accounts).

__IMPORTANT__: This server is intended to be used only for **local testing**.

## Content

- [Running the xmpp server on Docker](#running-the-xmpp-server-on-docker)
- [Restarting the prosody server](#restarting-the-prosody-server) 
- [Available accounts](#available-accounts)
- [Troubleshoots](#troubleshoots)
Giovane Liberato's avatar
Giovane Liberato committed
15 16

## Running the xmpp server on Docker
17

Sofia Celi's avatar
Sofia Celi committed
18
1. Create an `.env` file that looks exactly like this:
Sofia Celi's avatar
Sofia Celi committed
19 20 21 22 23 24 25 26 27 28

```
  PREKEY_SERVER_IDENTITY=prekeys.localhost
  PREKEY_SERVER_FINGERPRINT=
  XMPP_COMPONENTS_SECRET=this is secret
```

2. Run:

```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
29
  $ docker-compose up
Sofia Celi's avatar
Sofia Celi committed
30 31
```

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
32
3. Copy the shown fingerprint (without spaces/brackets) into the `.env` file. Something like this will be shown:
Sofia Celi's avatar
Sofia Celi committed
33 34 35 36 37 38 39

```
prekeys-raw_1   | Starting server on 0.0.0.0:30123...
prekeys-raw_1   | [F91453A3D80BB48F FD683C98FBB2ED30 33F52861F6549F64 A45216627D43BA80 CCD9B08156CBAB97 E9B00314B313AF87 6FD6FBAFE97C00CC]
prekeys-xmpp_1  | fingerprint provided is not valid
```

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
40 41 42
This is line shows you the appropriate fingerprint 

`prekeys-raw_1   | [F91453A3D80BB48F FD683C98FBB2ED30 33F52861F6549F64 A45216627D43BA80 CCD9B08156CBAB97 E9B00314B313AF87 6FD6FBAFE97C00CC]`.
Sofia Celi's avatar
Sofia Celi committed
43 44 45 46 47 48 49 50

Copy it on the `.env` file, so it looks like this:

```
PREKEY_SERVER_IDENTITY=prekeys.localhost
PREKEY_SERVER_FINGERPRINT=F91453A3D80BB48FFD683C98FBB2ED3033F52861F6549F64A45216627D43BA80CCD9B08156CBAB97E9B00314B313AF876FD6FBAFE97C00CC
XMPP_COMPONENTS_SECRET=this is secret
```
Sofia Celi's avatar
Sofia Celi committed
51 52 53

4. Run:

54
```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
55
$ docker-compose up
56 57
```

Sofia Celi's avatar
Sofia Celi committed
58
Everything should run. This line should show up:
59 60

```
Sofia Celi's avatar
Sofia Celi committed
61
xmpp-server_1   | prekeys.localhost:component  info	External component successfully authenticated
62 63
```

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
64
In order to make this server be recognizable by the [pidgin plugin](https://github.com/otrv4/pidgin-otrng), you need to run the following command:
65 66

```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
67
  ./configure CFLAGS="-ggdb3 -O0 -DDEFAULT_PREKEYS_SERVER='\"prekeys.localhost\"'"
68 69
```

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
70 71 72
## Restarting the prosody server

Run:
73

Mauro Velasco's avatar
Mauro Velasco committed
74
```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
75 76 77
$ docker-compose down
$ docker-compose stop
$ docker system prune -a
Mauro Velasco's avatar
Mauro Velasco committed
78
```
79

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
80
## Available accounts
Sofia Celi's avatar
Sofia Celi committed
81 82

```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
83 84 85 86 87 88 89
+-------------------------------------+
|   ACCOUNT            |   PASSWORD   |
+-------------------------------------+
|   alice@localhost    |   alice      |
+-------------------------------------+
|   bob@localhost      |   bob        |
+-------------------------------------+
Mauro Velasco's avatar
Mauro Velasco committed
90
```
Sofia Celi's avatar
Sofia Celi committed
91

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
92 93 94 95 96
## Troubleshoots

If you need to fix [ownership]([https://prosody.im/doc/certificates](https://prosody.im/doc/certificates)) issues using `prosody`, you can do the following:

1. In another terminal window run:
Sofia Celi's avatar
Sofia Celi committed
97

Mauro Velasco's avatar
Mauro Velasco committed
98
```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
99 100
$ docker-compose exec xmpp-server bash
$ ls -al ~/localhost/
Sofia Celi's avatar
Sofia Celi committed
101
```
Sofia Celi's avatar
Sofia Celi committed
102

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
103
2. Take the `id/gid` (the 4th column) of the offline folder. `chown` it outside of the docker container so the offline storage is writable. 
Sofia Celi's avatar
Sofia Celi committed
104

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
105
Note that the user must belong to the docker group.
Sofia Celi's avatar
Sofia Celi committed
106

107
```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
108
$ sudo chown -R uid:gid prekey-server-docker-compose/prosody/data/localhost/
109 110
```

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
111
3. In some distributions could be necessary to execute the following steps:
112

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
113
- Modify `prekey-server-docker-compose/prosody/Dockerfile` adding:
114 115

```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
116 117
$ chown root:prosody /etc/prosody/certs/localhost.key
$ chmod 660 /etc/prosody/certs/localhost.key
118 119
```

Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
120
- Rebuild the image with:
Sofia Celi's avatar
Sofia Celi committed
121

Giovane Liberato's avatar
Giovane Liberato committed
122
```
Pedro Enrique Palau's avatar
Pedro Enrique Palau committed
123
$ sudo docker-compose build
Giovane Liberato's avatar
Giovane Liberato committed
124
```