openidec/README.md

204 lines
4.9 KiB
Markdown
Raw Permalink Normal View History

2020-09-09 10:18:47 +03:00
# Intro
2023-03-28 13:33:58 +03:00
OpenIDEC is [idec](https://github.com/idec-net/new-docs/blob/master/main.md) node realization written in golang.
Forked from https://github.com/hugeping/ii-go for OpenBSD adaptation
2020-09-09 10:18:47 +03:00
It has no dependencies and very compact. You can easy setup it and make your own ii/idec node.
How to build?
```
2023-03-28 13:33:58 +03:00
git clone https://git.openbsd.org.ru/vasyahacker/openidec.git
cd openidec
make build
2020-09-09 10:18:47 +03:00
```
2023-03-28 13:33:58 +03:00
# idecctl
2020-09-09 10:18:47 +03:00
2023-03-28 13:33:58 +03:00
idecctl can be used to fetch messages from another node and maintaince database.
2020-09-09 10:18:47 +03:00
## Fetch messages
2023-03-28 13:33:58 +03:00
idecctl [options] fetch [uri] [echolist]
2020-09-09 10:18:47 +03:00
echolist is the file with echonames (can has : splitted columns, like list.txt) or - -- to load it from stdin. For example:
```
2023-03-28 13:33:58 +03:00
echo "std.club:this comment will be omitted" | ./idecctl fecth http://127.0.0.1:8080 -
2020-09-09 10:18:47 +03:00
```
Options are:
```
2020-09-09 10:21:36 +03:00
-db <database> -- db by default (db.idx - genetated index)
2020-09-09 10:18:47 +03:00
-lim=<n> -- fetch mode, if omitted full sync will be performed if needed
if n > 0 - last n messages synced
2020-09-09 10:19:56 +03:00
if n < 0 - adaptive fetching with step n will be performed
2020-09-09 10:18:47 +03:00
-f -- do not check last message, perform sync even it is not needed
```
If echolist is omitted, fetcher will try to get all echos. It uses list.txt extension of IDEC if target node supports it.
## Create index
2020-09-09 10:37:33 +03:00
Index file (db.idx by default) is created when needed. If you want force to recreate it, use:
2020-09-09 10:18:47 +03:00
```
2023-03-28 13:33:58 +03:00
./idecctl index
2020-09-09 10:18:47 +03:00
```
## Store bundle into db
DB is just msgid:message bundles in base64 stored in text file. You can merge records from db to db with store command:
```
2023-03-28 13:33:58 +03:00
idecctl [options] store [db]
2020-09-09 10:18:47 +03:00
```
db - is file with bundles or '-' for stdin.
Options are:
```
2020-09-09 10:21:36 +03:00
-db <database> -- db to store/merge in;
2020-09-09 10:18:47 +03:00
```
## Show messages
Messages are identificated by unique message ids (MsgId). It is the first column in bundle:
```
<msgid>:<message>
```
You may select messages with select cmd:
```
2023-03-28 13:33:58 +03:00
./idecctl [options] select <echo.name> [slice]
2020-09-09 10:18:47 +03:00
```
slice is the start:limit. For example:
```
2023-03-28 13:33:58 +03:00
./idecctl select std.club -1:1 # get last message
./idecctl select std.club 0:10 # get first 10 messages
2020-09-09 10:18:47 +03:00
```
Options are:
```
2021-02-05 12:36:17 +03:00
-from <user> -- from user
-to <user> -- to user
-t -- only topics (w/o repto)
2020-09-09 10:21:36 +03:00
-db <database> -- db by default (db.idx - genetated index)
-v -- show message text, not only MsgId
2020-09-09 10:18:47 +03:00
```
You may show selected message:
```
2023-03-28 13:33:58 +03:00
./idecctl [options] get <MsgId>
2020-09-09 10:18:47 +03:00
```
Or search message:
```
2023-03-28 13:33:58 +03:00
./idecctl [options] search <string> [echo]
2020-09-09 10:18:47 +03:00
```
Where options are:
```
2020-09-09 10:21:36 +03:00
-db <database> -- db by default (db.idx - genetated index)
-v -- show message text, not only MsgId
2020-09-09 10:18:47 +03:00
```
2021-02-05 12:36:17 +03:00
You can sort ids by date with sort command.
To show last 5 messages adressed to selected user, try:
2020-09-09 10:18:47 +03:00
```
2023-03-28 13:33:58 +03:00
./idecctl [options] -to <user> select "" | ./idecctl sort | tail -n5 | ./idecctl -v sort
2020-09-09 10:18:47 +03:00
```
For example:
```
2023-03-28 13:33:58 +03:00
./idecctl -v -to Peter "" -1:1 # show and print last message to Peter
2020-09-09 10:18:47 +03:00
```
## Add user (point)
```
2023-03-28 13:33:58 +03:00
./idecctl [-u pointfile] useradd <name> <e-mail> <password>
2020-09-09 10:18:47 +03:00
```
2023-05-18 08:45:33 +03:00
**Attention**: by default, a new user is added blocked, **set 'locked/no' in points.txt to unlock**
2020-09-09 10:18:47 +03:00
By default, pointfile is points.txt
## Blacklist msg
```
2023-03-28 13:33:58 +03:00
./idecctl [-db db] blacklist <MsgId>
2020-09-09 10:18:47 +03:00
```
Blacklist is just new record with same id but spectial status.
2023-03-28 13:33:58 +03:00
# idecd
2020-09-09 10:18:47 +03:00
To run node:
```
2023-03-28 13:33:58 +03:00
./idecd [options]
2020-09-09 10:18:47 +03:00
```
Where options are:
```
-L Listen address, default is :8080
-db <path> Database, "db" by default
-e list Echos list file. This file needs only for descriptions
and must be in list.txt format, where 2nd colum is ignored.
2020-09-09 10:19:56 +03:00
When this file is exists, points can not create they own echos.
list.txt by default.
2020-09-09 10:18:47 +03:00
-host <string> Host string for node. For ex. http://hugeping.tk.
http://127.0.0.1:8080 by default
2023-05-18 08:45:33 +03:00
-noreg Disable new users registration
-style path Path to /style web-directory (css/images) (default "./style")
2023-03-28 13:33:58 +03:00
-sys "name" Node name. "openidec" by default
2023-05-18 08:45:33 +03:00
-tpl path Path to html templates (default "./tpl")
2020-09-09 10:18:47 +03:00
-u <points> Points file. "points.txt" by default.
-v Be verbose (for tracing)
```
## Example setup
```
2023-03-28 13:33:58 +03:00
./idecctl fetch http://club.syscall.ru
2020-09-09 10:18:47 +03:00
wget http://club.syscall.ru/list.txt # for echo descriptions
2023-05-18 08:45:33 +03:00
./idecd -sys "newnode" -tpl www/tpl -style www/style
2020-09-09 10:18:47 +03:00
```
And open http://127.0.0.1:8080 in your browser.
2023-05-18 08:45:33 +03:00
**Attention**: by default, a new user is added blocked, **set 'locked/no' in points.txt to unlock**
2020-09-09 10:18:47 +03:00
## Standarts supported
- u/e
- list.txt
- x/c
- blacklist.txt
- m/
- e/
## Limitations
Size of message can not be greater then 65536 bytes (before encoded into base64).
# web interface
User with id 1 (first created user) is admin.
Admin can create new echoes with: http://127.0.0.1:8080/new
Another hiden feature, is blacklisting: http://127.0.0.1:8080/msgid/blacklist
Web interface supports some non-standart features in message body text:
- @spolier: spoiler
- @base64: name (base64 data from next line till end of message)
2020-09-09 10:38:25 +03:00
- xpm2 and xpm3 images embedding
2020-09-09 10:18:47 +03:00
That's all, for now! :)