reflector.go/readme.md

125 lines
5.7 KiB
Markdown
Raw Normal View History

2018-05-29 23:36:28 +02:00
# Reflector
2021-07-22 20:13:05 +02:00
Reflector is a central piece of software that providers LBRY with the following features:
- Blobs reflection: when something is published, we capture the data and store it on our servers for quicker retrieval
- Blobs distribution: when a piece of content is requested and the LBRY network doesn't have it, reflector will retrieve it from its storage and distribute it
- Blobs caching: reflectors can be chained together in multiple regions or servers to form a chain of cached content. We call those "blobcaches". They are layered so that content distribution is favorable in all the regions we deploy it to
There are a few other features embedded in reflector.go including publishing streams from Go, downloading or upload blobs, resolving content and more unfinished tools.
This code includes a Go implementations of the LBRY peer protocol, reflector protocol, and DHT.
2018-05-29 23:36:28 +02:00
## Installation
2021-07-22 20:13:05 +02:00
- Install mysql 8 (5.7 might work too)
- add a reflector user and database with password `reflector` with localhost access only
2023-03-09 18:59:21 +01:00
- Create the tables as described [here](https://github.com/lbryio/reflector.go/blob/master/db/db.go#L735) (the link might not update as the code does so just look for the schema in that file)
2021-07-22 20:13:05 +02:00
#### We do not support running reflector.go as a blob receiver, however if you want to run it as a private blobcache you may compile it yourself and run it as following:
```bash
./prism-bin reflector \
--conf="none" \
--disable-uploads=true \
--use-db=false \
--upstream-reflector="reflector.lbry.com" \
--upstream-protocol="http" \
--request-queue-size=200 \
--disk-cache="2GB:/path/to/your/storage/:localdb" \
```
Create a systemd script if you want to run it automatically on startup or as a service.
2018-05-29 23:36:28 +02:00
## Usage
2021-07-22 20:13:05 +02:00
Usage as reflector/blobcache:
```bash
Run reflector server
Usage:
prism reflector [flags]
Flags:
--disable-blocklist Disable blocklist watching/updating
--disable-uploads Disable uploads to this reflector server
--disk-cache string Where to cache blobs on the file system. format is 'sizeGB:CACHE_PATH:cachemanager' (cachemanagers: localdb/lfuda/lru) (default "100GB:/tmp/downloaded_blobs:localdb")
-h, --help help for reflector
--http-peer-port int The port reflector will distribute content from over HTTP protocol (default 5569)
--http3-peer-port int The port reflector will distribute content from over HTTP3 protocol (default 5568)
--mem-cache int enable in-memory cache with a max size of this many blobs
--metrics-port int The port reflector will use for prometheus metrics (default 2112)
--optional-disk-cache string Optional secondary file system cache for blobs. format is 'sizeGB:CACHE_PATH:cachemanager' (cachemanagers: localdb/lfuda/lru) (this would get hit before the one specified in disk-cache)
--origin-endpoint string HTTP edge endpoint for standard HTTP retrieval
--origin-endpoint-fallback string HTTP edge endpoint for standard HTTP retrieval if first origin fails
--receiver-port int The port reflector will receive content from (default 5566)
--request-queue-size int How many concurrent requests from downstream should be handled at once (the rest will wait) (default 200)
--tcp-peer-port int The port reflector will distribute content from for the TCP (LBRY) protocol (default 5567)
--upstream-protocol string protocol used to fetch blobs from another upstream reflector server (tcp/http3/http) (default "http")
--upstream-reflector string host:port of a reflector server where blobs are fetched from
--use-db Whether to connect to the reflector db or not (default true)
Global Flags:
--conf string Path to config. Use 'none' to disable (default "config.json")
-v, --verbose strings Verbose logging for specific components
```
2018-05-29 23:36:28 +02:00
2021-07-22 20:13:05 +02:00
Other uses:
```bash
Prism is a single entry point application with multiple sub modules which can be leveraged individually or together
Usage:
prism [command]
Available Commands:
check-integrity check blobs integrity for a given path
cluster Start(join) to or Start a new cluster
decode Decode a claim value
dht Run dht node
getstream Get a stream from a reflector server
help Help about any command
peer Run peer server
populate-db populate local database with blobs from a disk storage
publish Publish a file
reflector Run reflector server
resolve Resolve a URL
send Send a file to a reflector
sendblob Send a random blob to a reflector server
start Runs full prism application with cluster, dht, peer server, and reflector server.
test Test things
upload Upload blobs to S3
version Print the version
Flags:
--conf string Path to config. Use 'none' to disable (default "config.json")
-h, --help help for prism
-v, --verbose strings Verbose logging for specific components
```
2018-05-29 23:36:28 +02:00
## Running from Source
2023-03-09 18:59:21 +01:00
This project requires [Go v1.19](https://golang.org/doc/install).
2021-07-22 20:13:05 +02:00
On Ubuntu you can install it with `sudo snap install go --classic`
2018-05-29 23:36:28 +02:00
```
2019-10-03 20:09:26 +02:00
git clone git@github.com:lbryio/reflector.go.git
cd reflector.go
2018-05-29 23:36:28 +02:00
make
2023-03-09 18:59:21 +01:00
./dist/linux_amd64/prism-bin
2018-05-29 23:36:28 +02:00
```
## Contributing
coming soon
## License
This project is MIT licensed.
## Security
2019-03-18 17:28:29 +01:00
We take security seriously. Please contact security@lbry.com regarding any security issues.
2021-09-28 16:15:24 +02:00
Our PGP key is [here](https://lbry.com/faq/pgp-key) if you need it.
2018-05-29 23:36:28 +02:00
## Contact
2021-07-22 20:13:05 +02:00
The primary contact for this project is [@Nikooo777](https://github.com/Nikooo777) (niko-at-lbry.com)