Skip to content

A filesystem interface over http, with extras and docker support

License

Notifications You must be signed in to change notification settings

5HT2/fs-over-http

Repository files navigation

time tracker Docker Pulls Docker Build CodeFactor

A filesystem interface over http.

NOTE: I wrote this when I was still learning Go, and as such many improvements can be made. I have detailed what I would like to improve in the TODO section, with Partial Content, better error handling and response syntax being the main focus.

Contributing

Contributions to fix my code are welcome, as well as any improvements.

To build:

git clone git@github.com:5HT2/fs-over-http.git
cd fs-over-http
make

To run:

# I recommend using genpasswd https://gist.github.com/5HT2/30f98284e9f92e1b47b4df6e05a063fc
AUTH='some secure token'
echo "$AUTH" > token

# Change the port to whatever you'd like. 
# Change localhost to your public IP if you'd like.
./fs-over-http -addr=localhost:6060

Usage

Please see USAGE.md for examples of interacting with a fs-over-http server.

IPv6

IPv6 is supported, do note that you need to format the addr flag differently.

# Example IPv4
./fs-over-http -addr "10.0.1.1:6060"
# Example IPv6
./fs-over-http -addr "[2fb1:e540:13a7:3fa1:37bc:80b4:0b96:dbb8]:6060"

Production

I recommend using Caddy for automatic renewal + as a reverse proxy.

# Caddyfile example
i.l1v.in {
  header Server Caddy "Nintendo Wii"
  reverse_proxy localhost:6060
}

There is also a docker image available with the following command, or checkout the update.sh script for automatically updating a live docker image.

docker pull l1ving/fs-over-http:latest

TODO

  • Binary file support
  • Allow marking a folder as public
  • Custom shell for interacting
  • Partial Content support (docs)
  • Switch X-File-Content to using forms
    • eg: curl -X POST -H "Auth: $TOKEN" -d 'content=File content' localhost:6060/file.txt
    • Switch folder creation to same syntax with empty content
    • Read 512 bytes at a time like so.
  • Move error handling to ListenAndServe instead of individually sending the error
    • Switch to using X-Error-Message instead of printing it out, add a newline end of normal responses
  • Refactor use of JoinStr to fmt.Sprintf/Sprintln and +
  • Set ReadTimeout and WriteTimeout to prevent abuse
  • Add Docker image
    • Add CI service
  • Add Caddyfile example
    • Maybe with rate limit options and the such
    • Refactor docs about TLS
  • Encoding of uploading text-based files (eg the ● character)
  • Cleanup README
  • Fix scripts to use new format