abyss/README.md

189 lines
5.7 KiB
Markdown
Raw Normal View History

2024-08-19 13:01:23 -03:00
# abyss
2024-08-25 23:16:56 -03:00
2024-10-17 13:02:20 -03:00
abyss is a basic and mostly single user http server written in go made for uploading files (logs, images) and then sharing them to the internet
2024-08-19 13:01:23 -03:00
2024-10-17 13:02:20 -03:00
<figure>
<img src="https://github.com/user-attachments/assets/eae42368-d8b5-4c42-ac8a-0e1486fcd0d4" alt="homepage"/>
<figcaption>this is abyss' default home page<figcaption/>
</figure>
2024-08-19 13:01:23 -03:00
2024-08-19 15:50:17 -03:00
## table of contents
2024-08-25 23:16:56 -03:00
2024-10-17 13:02:20 -03:00
- [features](#features)
2024-08-19 15:50:17 -03:00
- [running abyss](#running)
2024-08-25 23:16:56 -03:00
- [installing with docker](#docker)
2024-10-17 18:56:09 -03:00
- [installing manually](#directly)
2024-08-20 09:03:25 -03:00
- [uploading files](#uploading)
2024-09-19 10:30:28 -03:00
- [theming](#theming)
- [docs](#docs)
2024-08-19 15:50:17 -03:00
- [todo list](#todo)
2024-10-17 13:02:20 -03:00
- [more pictures](#pictures)
## features
- **file uploads**: supports uploading various file types, including images, videos, and documents.
- **flexible media display**: automatically renders uploaded files on a webpage based on their type (images, pdfs, videos, or plain text).
- **easily customizable interface**: allows for easy modification of color schemes and layout to suit specific design needs.
- **syntax highlighting for code**: syntax highlighting available by default for code files, with support for multiple programming languages. (can be tweaked/changed and even removed)
- **security considerations**: as it is single user, it's mostly secure but there are still some edges to sharpen
2024-08-19 15:50:17 -03:00
2024-10-17 18:56:09 -03:00
## running
2024-08-25 23:16:56 -03:00
2024-10-17 18:56:09 -03:00
#### setting it up
- clone the repository and cd into it:
```bash
git clone https://github.com/jabuxas/abyss.git --depth 1 && cd abyss
```
- then run `./generate_config.sh` to setup the necessary environment variables
- after that, you can use either docker or run it directly
2024-08-20 09:03:25 -03:00
2024-08-19 15:50:17 -03:00
### docker
2024-08-25 23:16:56 -03:00
2024-09-06 16:51:14 -03:00
- to run with docker, you can use the `docker-compose.yml` file available in this repo. to do so, run:
2024-08-25 23:16:56 -03:00
2024-08-19 15:50:17 -03:00
```bash
docker compose up -d # might be docker-compose depending on distro
```
2024-08-25 23:16:56 -03:00
2024-09-06 12:07:20 -03:00
- you can optionally use the [docker image](https://git.jabuxas.xyz/jabuxas/-/packages/container/abyss/latest) directly and set it up how you want
2024-08-25 23:16:56 -03:00
2024-10-17 18:56:09 -03:00
### directly
2024-08-19 13:01:23 -03:00
- to run it manually, build it with `go build -o abyss` and run:
2024-08-25 23:16:56 -03:00
2024-08-19 13:03:24 -03:00
```bash
./abyss
2024-08-19 13:01:23 -03:00
```
2024-08-19 13:03:24 -03:00
2024-08-20 09:03:25 -03:00
## uploading
2024-10-15 22:59:01 -03:00
#### with curl
2024-10-17 13:02:20 -03:00
- you can upload both with the main key and with jwt tokens
##### main key
- to upload your files with main key:
2024-08-25 23:16:56 -03:00
2024-08-19 13:03:24 -03:00
```bash
2024-09-18 10:34:42 -03:00
curl -F "file=@/path/to/file" -H "X-Auth: "$(cat /path/to/.key) http://localhost:3235/
2024-08-19 13:03:24 -03:00
```
2024-08-25 23:16:56 -03:00
2024-10-15 22:59:01 -03:00
- you should probably create an `alias` or a `function` to do this automatically for you.
<details>
<summary>click for an example for bash/zsh:</summary>
```bash
pst() {
local file
if [[ -p /dev/stdin ]]; then
file=$(mktemp)
cat > "$file"
elif [[ -n $1 ]]; then
file="$1"
else
echo "Usage: pst [file]"
return 1
fi
2024-10-17 13:02:20 -03:00
curl -F "file=@$file" -H "X-Auth: $(cat ~/.key)" http://localhost:3235/
2024-10-15 22:59:01 -03:00
if [[ -p /dev/stdin ]]; then
rm "$file"
fi
}
```
</details>
<details>
<summary>click for an example for fish shell:</summary>
```bash
function pst
set -l file
if command test -p /dev/stdin
set file "/tmp/tmp.txt"
cat > $file
else if test -n "$argv[1]"
set file "$argv[1]"
end
2024-10-17 13:02:20 -03:00
curl -F "file=@$file" -H "X-Auth: $(cat ~/.key)" http://localhost:3235/
2024-10-15 22:59:01 -03:00
if command test -p /dev/stdin
rm "$file"
end
end
```
</details>
2024-10-17 13:02:20 -03:00
##### with jwt tokens
- you first need to generate them:
```bash
curl -u admin http://localhost:3235/token # you can also access the url in the browser directly
```
- the user will be the value of `$AUTH_USERNAME` and password the value of `$AUTH_PASSWORD`
- then you use the token in place of the main key:
```bash
curl -F"file=@/path/to/file.jpg" -H "X-Auth: your-token" http://localhost:3235/
```
2024-10-15 22:59:01 -03:00
#### through the browser
- you can only upload text through the browser, to do so, simply write text in the form in the default webpage and click upload.
- this upload can be restricted to need authentication or not, controlled by an environment variable.
2024-09-19 10:30:28 -03:00
## theming
2024-09-18 10:34:42 -03:00
- there is an example homepage in `static/` you can edit directly, which the server will serve automatically
- if running with docker, it's also possible to override `/static` inside the container with your own page.
2024-10-15 22:59:01 -03:00
- otherwise you will need to clone this repository and edit `static/` and `templates/` manually, or recreate the structure.
2024-09-19 10:30:28 -03:00
- same thing with templates in `templates/`
2024-09-18 10:34:42 -03:00
- it is preferred to use `dev/` for that reason, since it is git-ignored and that way makes it easier if wanting to update regularly without making changes to the tree
## docs
- `ABYSS_URL`: this is used for the correct formatting of the response of `curl`.
2024-10-15 22:59:01 -03:00
- `AUTH_USERNAME | AUTH_PASSWORD`: this is used to access `/tree`, which shows all uploaded files
- `UPLOAD_KEY`: this is key checked when uploading files. if the key doesn't match with server's one, then it refuses uploading.
2024-09-06 16:35:01 -03:00
- `ABYSS_FILEDIR`: this points to the directory where abyss will save the uploads to. defaults to `./files`
- `ABYSS_PORT`: this is the port the server will run on. safe to leave empty. defaults to 3235
2024-10-15 22:59:01 -03:00
- `SHOULD_AUTH`: if it is `yes`, then to upload text through the browser you will need authentication (same auth as `/tree`), any value other than that and upload is auth-less
2024-08-19 13:01:23 -03:00
## todo:
2024-08-25 23:16:56 -03:00
2024-08-19 13:54:33 -03:00
- [x] add upload of logs funcionality (like 0x0.st)
2024-08-19 15:50:17 -03:00
- [x] add docker easy setup
2024-08-20 09:03:25 -03:00
- ~~add db for tracking of file names~~ (dont need that)
- [x] add file browser (like file://)
- [x] add file extension in its name
- [x] login prompt when accessing /tree
2024-09-18 10:34:42 -03:00
- [x] home page
2024-10-16 22:42:46 -03:00
- [x] custom file displaying!!
- [x] syntax highlighting
2024-08-20 09:03:25 -03:00
- [ ] add rate limits
2024-10-17 13:02:20 -03:00
## pictures
<figure>
<img src="https://github.com/user-attachments/assets/32ce9b3a-8c0f-4bb5-bdcf-3a602e0c81e6"/>
<figcaption>this is abyss' default directory list<figcaption/>
</figure>
<figure>
<img src="https://github.com/user-attachments/assets/7072b227-9972-4c2a-a9f3-384d2efb4fe1"/>
<figcaption>this is abyss' default file presentation<figcaption/>
</figure>