add option to configure # of times to check id collision
This commit is contained in:
parent
db8e6389cb
commit
c296e7fff3
34
README.md
34
README.md
|
@ -1,50 +1,52 @@
|
|||
# LoliHost
|
||||
![](https://i.imgur.com/jkB0XlM.png)
|
||||
|
||||
Created for use on https://l-o.li (now runs on a private fork from this repo). A file host server with security in mind, which stores everything locally. Intended for private/small group use, and for things like screenshots (though you could use it for something else as well).
|
||||
# Tytanium
|
||||
|
||||
A file host server which puts security first. Intended for private/small group use, and for things like screenshots (though you could use it for something else as well).
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
- Excellent compatibility with image capture suites like ShareX/MagicCap/etc.
|
||||
- Customizable rate limits
|
||||
- Runs with [fasthttp](https://github.com/vayala/fasthttp) for maximum performance and built-in anti-DoS features
|
||||
- Lots of configuration options
|
||||
- Built with [fasthttp](https://github.com/vayala/fasthttp) for performance and built-in anti-DoS features
|
||||
- Whitelist/blacklist file types, and check them based on their headers, not the extension
|
||||
- Sanitize files to prevent against phishing attacks
|
||||
- Public/private mode (private by default)
|
||||
- Zero-width file IDs in URLs
|
||||
- File ID collision checking
|
||||
- Not written in Javascript!
|
||||
|
||||
## Setup
|
||||
|
||||
Make sure you have a Redis instance set up somewhere; preferably in the same environment as the file hoster.
|
||||
|
||||
- Put your config in `conf/` as `config.yml` using `conf/example.yml` as a reference.
|
||||
- Put your config in `conf/` as `config.yml` using `conf/example.yml` as a reference.
|
||||
- Optionally, you can replace `favicon.ico` with your own icon! (It must have the same name)
|
||||
- If you're using this with ShareX, check `example/lolihost.sxcu` for a template sxcu file.
|
||||
- If you're using this with ShareX, check `example/tytanium.sxcu` for a template sxcu file.
|
||||
|
||||
Now you can choose to either run LoliHost with Docker or as a service on your system.
|
||||
Now you can choose to either run Tytanium with Docker or as a service on your system.
|
||||
|
||||
### Option 1: systemd/other service manager (Recommended)
|
||||
|
||||
- Download the binary to the same directory where `conf/` is located.
|
||||
- Alternatively you can build it.
|
||||
- Mark it as executable with `chmod 0744 <binary file>`.
|
||||
- Copy `example/lolihost.service` to `/lib/systemd/system` (if it's not there already).
|
||||
- Copy `example/tytanium.service` to `/lib/systemd/system` (if it's not there already).
|
||||
- Edit the WorkingDirectory and ExecFile to match the locations of the binary file.
|
||||
- Run `systemctl daemon-reload`.
|
||||
|
||||
At this point, you can run the program using `systemctl start lolihost`. You can check on its status by running `systemctl status lolihost`.
|
||||
|
||||
If anything goes wrong, you can check `journalctl -u lolihost` and find out what happened.
|
||||
At this point, you can run the program using `systemctl start tytanium`. You can check on its status by running `systemctl status tytanium`.
|
||||
|
||||
If anything goes wrong, you can check `journalctl -u tytanium` and find out what happened.
|
||||
|
||||
### Option 2: Docker
|
||||
|
||||
**Note that you will have to attach external volumes yourself should you use this method.**
|
||||
|
||||
- Build the image with `docker build -t lolihost .`
|
||||
- Make sure to bind the port you choose (default is `3030`) to other ports on your system. Here's an example of how you would run it, after building the image.
|
||||
|
||||
`docker container run -d -p 127.0.0.1:3030:3030 lolihost`
|
||||
- Build the image with `docker build -t tytanium .`
|
||||
- Make sure to bind the port you choose (default is `3030`) to other ports on your system. Here's an example of how you would run it, after building the image.
|
||||
|
||||
`docker container run -d -p 127.0.0.1:3030:3030 tytanium`
|
||||
|
||||
### How to Upload
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# EXAMPLE CONFIGURATION
|
||||
# Rename this file to "config.yml" before you start LoliHost.
|
||||
# Rename this file to "config.yml" before you start Tytanium.
|
||||
|
||||
storage:
|
||||
# If there is another directory you want to save files to (instead of "files" in the executable's
|
||||
|
@ -50,7 +50,7 @@ security:
|
|||
- application/x-sqlite3
|
||||
- application/x-object
|
||||
- application/x-elf
|
||||
# If this list is populated, then LoliHost will ONLY allow these mime types to be displayed.
|
||||
# If this list is populated, then Tytanium will ONLY allow these mime types to be displayed.
|
||||
# If a mime type from this list is also in the sanitize list, it will be sanitized.
|
||||
# If a mime type from this list is also in the blacklist, it will be blacklisted anyway.
|
||||
# If no values are given, a whitelist will not be set.
|
||||
|
@ -75,6 +75,9 @@ server:
|
|||
# How many TOTAL requests the server can handle at once.
|
||||
# Requests will not be served to ANYONE if the # of connections everywhere is above this number.
|
||||
concurrency: 512
|
||||
# How many times an ID should be checked to see if a duplicate exists.
|
||||
# If 0, and a duplicate ID is generated, the file will not upload.
|
||||
collisioncheckattempts: 3
|
||||
|
||||
net:
|
||||
redis:
|
||||
|
|
BIN
conf/favicon.ico
BIN
conf/favicon.ico
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 4.6 KiB |
|
@ -1,5 +1,5 @@
|
|||
[Unit]
|
||||
Description=LoliHost File Host
|
||||
Description=Tytanium File Host
|
||||
|
||||
[Service]
|
||||
Type=simple
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"Version": "13.0.1",
|
||||
"Name": "LoliHost Example Configuration",
|
||||
"Name": "Tytanium Example Configuration",
|
||||
"DestinationType": "ImageUploader, TextUploader, FileUploader",
|
||||
"RequestMethod": "POST",
|
||||
"RequestURL": "https://domain.com/upload",
|
4
go.mod
4
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/vysiondev/lolihost
|
||||
module github.com/vysiondev/tytanium
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/gabriel-vasile/mimetype v1.1.2
|
||||
|
|
5
main.go
5
main.go
|
@ -11,11 +11,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Version = "1.13.3"
|
||||
Version = "1.13.4"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Print(">> LoliHost " + Version + "\n\n")
|
||||
log.Print(">> Tytanium " + Version + "\n\n")
|
||||
|
||||
viper.SetConfigName("config")
|
||||
viper.AddConfigPath("./conf/")
|
||||
|
@ -33,6 +33,7 @@ func main() {
|
|||
viper.SetDefault("net.redis.db", 0)
|
||||
viper.SetDefault("server.idlen", 5)
|
||||
viper.SetDefault("server.concurrency", 128*4)
|
||||
viper.SetDefault("server.collisioncheckattempts", 3)
|
||||
viper.SetDefault("security.maxsizebytes", 52428800)
|
||||
viper.SetDefault("security.publicmode", false)
|
||||
viper.SetDefault("security.ratelimit.resetafter", 60000)
|
||||
|
|
|
@ -104,13 +104,12 @@ func (b *BaseHandler) ServeUpload(ctx *fasthttp.RequestCtx) {
|
|||
break
|
||||
}
|
||||
attempts++
|
||||
if attempts >= 10 {
|
||||
if attempts >= b.Config.Server.CollisionCheckAttempts {
|
||||
SendTextResponse(ctx, "Tried too many times to find a valid file ID to use. Consider increasing the ID length.", fasthttp.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fsFile, err := os.Create(path.Join(b.Config.Storage.Directory, fileName))
|
||||
defer func() {
|
||||
_ = fsFile.Close()
|
||||
|
|
|
@ -39,9 +39,10 @@ type FilterConfig struct {
|
|||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
Port string
|
||||
Concurrency int
|
||||
IDLen int
|
||||
Port string
|
||||
Concurrency int
|
||||
IDLen int
|
||||
CollisionCheckAttempts int
|
||||
}
|
||||
|
||||
type NetConfig struct {
|
||||
|
|
Loading…
Reference in New Issue