Skip to content

Commit

Permalink
Rewrite of sharry
Browse files Browse the repository at this point in the history
This is a complete overhaul to start with version 1.0.
  • Loading branch information
eikek committed Dec 23, 2019
1 parent d3dde8a commit 100a672
Show file tree
Hide file tree
Showing 456 changed files with 22,467 additions and 16,690 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
dev.conf
_site/
target/

# ensime
.ensime_cache/
.ensime
local/
elm-stuff/
result
3 changes: 3 additions & 0 deletions .projectile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!/local
!/local/dev.conf
!/local/testing.org
15 changes: 15 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version = "2.2.0"

align = most
#align.arrowEnumeratorGenerator = true

maxColumn = 100

rewrite.rules = [
AvoidInfix
RedundantBraces
RedundantParens
AsciiSortImports
PreferCurlyFors
SortModifiers
]
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

674 changes: 0 additions & 674 deletions LICENSE.txt

This file was deleted.

216 changes: 9 additions & 207 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
sharry
======
# Sharry

Sharry allows to share files with others in a simple way. It is a
self-hosted web application. The basic concept is: upload files and get
a url back that can then be shared.

<a href="https://travis-ci.org/eikek/sharry"><img src="https://travis-ci.org/eikek/sharry.svg"></a>
<a href="https://xkcd.com/949/"><img height="400" align="right" style="float:right" src="https://imgs.xkcd.com/comics/file_transfer.png"></a>

How it works
------------
## How it works

### Authenticated users -&gt; others
### Authenticated users others

Authenticated users can upload their files on a web site together with
an optional password and a time period. The time period defines how long
Expand All @@ -20,7 +17,7 @@ can be shared, e.g. via email.

The download page is hard to guess, but open to everyone.

### Others -&gt; Authenticated users
### Others Authenticated users

Anonymous can send files to registered ones. Each registered user can
maintain alias pages. An alias page is behind a “hard-to-guess” URL
Expand All @@ -29,207 +26,12 @@ corresponding user. The form does not allow to specify a password or
validation period, but a description can be given. The user belonging to
the alias can be notified via email.

### Others -&gt; Others
## Documentation

If authentication is enabled, it is not possible to share files between
non-registered users. One party must be registered. But authentication
can be completely disabled. Then any user can upload files. This may be
useful within a closed network.
Please see the [documentation site](https://eikek.github.io/sharry).

Upload and Download
-------------------

Sharry aims to provide a good support for large files. That means
downloads and uploads are resumable. Large files can be downloaded via
[byte serving](https://en.wikipedia.org/wiki/Byte_serving), which allows
for example to watch video files directly in the browser. Uploads are
resumable, too, by using
[resumable.js](https://github.com/23/resumable.js) on the client.
Uploads can be retried where only chunks not already at the server are
transferred.
## License

Each published upload has a validity period, after which the public
download page doesn't work anymore. A cleanup job running periodically
can delete those files to save space.

Features
--------

- resumable and recoverable upload of multiple files; thanks to
[resumable.js](https://github.com/23/resumable.js)
- validation period for uploads
- resumable downloads using [byte
serving](https://en.wikipedia.org/wiki/Byte_serving)
- download single files or all in a zip
- protect downloads with a password
- automatic removal of invalid uploads
- external authentication (via system command or http requests)
- managing accounts, uploads and alias pages
- a command line client for uploading files

Try it
------

~~There is a demo installation at <https://sharrydemo.eknet.org>. You can
use the account `sharry` and no password to log in. The mail feature is
not enabled and uploads are restricted to 1.5M.~~ Sorry, I had to shut down this service.

Or, clone this project and use sbt (see below for prerequisites) to
compile and run:

``` shell
sbt run-sharry
```

This will build the project and start the server. Point your browser to
<http://localhost:9090> and login with user `admin` and password
`admin`.

Or, download a binary from the [release
page](https://github.com/eikek/sharry/releases).

Documentation
-------------

These pages are shown in each sharry instance, for example
[here](https://sharrydemo.eknet.org/#manual/index.md). The documentation
to the command line client is included.

Building
--------

For the server, you need Java8, [sbt](http://scala-sbt.org) and
[Elm](http://elm-lang.org/) installed first. Then clone the project and
run:

``` shell
sbt make
```

This creates a file in `modules/server/target/scala-2.12` named
`sharry-server-*.jar.sh`. This is an executable jar file and can be used
to run sharry:

The `--console` argument allows to terminate the server from the
terminal (otherwise it's `Ctrl-C`). By default a
[H2](http://h2database.com) database is configured in the current
working directory.

``` shell
$ ./modules/server/target/scala-2.12/sharry-server-0.0.1-SNAPSHOT.jar.sh --console
2017-05-08T14:53:07.345+0200 INFO [main] sharry.server.main$ [main.scala:36]
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Sharry 0.0.1-SNAPSHOT (build 2017-05-08 12:49:58UTC) is starting up …
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
2017-05-08T14:53:08.563+0200 INFO [main] sharry.server.main$ [main.scala:42]
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• Running initialize tasks …
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
2017-05-08T14:53:08.622+0200 INFO [main] com.zaxxer.hikari.HikariDataSource [HikariDataSource.java:93] HikariPool-1 - Started.
2017-05-08T14:53:09.272+0200 INFO [main] sharry.server.main$ [main.scala:62]
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• Starting http server at 0.0.0.0:9090
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Hit RETURN to stop the server
```

The command also builds the command line client. It can be found at
`modules/cli/target/scala-2.12` named `sharry-cli-*-.jar.sh`.

Building only the command line client doesn't require Elm and can be
built separately with `sbt make-cli`.

Dependencies
------------

The server and cli part is written in [Scala](http://scala-lang.or) and
uses the following great libraries:

- [fs2](https://github.com/functional-streams-for-scala/fs2) all the
way
- [fs2-http](https://github.com/Spinoco/fs2-http) for the http stack
- [doobie](https://github.com/tpolecat/doobie) for db access (which
uses fs2, too)
- [circe](https://github.com/circe/circe) great library for json
- [pureconfig](https://github.com/pureconfig/pureconfig) is reading
the configuration file using
[config](https://github.com/typesafehub/config) library
-

See all of them in the [libs](./project/libs.scala) file.

The frontend is written in [Elm](http://elm-lang.org/). Two libraries
aside from `elm-lang/*` are used:

- [evancz/elm-markdown](https://github.com/evancz/elm-markdown)
rendering markdown
- [NoRedInk/elm-decode-pipeline](https://github.com/NoRedInk/elm-decode-pipeline)
decoding json

Non-elm components:

- [semantic-ui](https://semantic-ui.com) for a well looking web
interface
- [resumable.js](https://github.com/23/resumable.js) for handling
uploads at the client

Configuring (server)
--------------------

Sharry reads a configuration file that can be given as an argument to
the executable. Please see the
[default](./modules/server/src/main/resources/reference.conf)
configuration for all available options and their default values. It
also contains hopefully helpful comments.

For more detailed information on its syntax, please refer to the
[specification](https://github.com/typesafehub/config/blob/master/HOCON.md)
and documentation of [config
library](https://github.com/typesafehub/config).

The important settings are

- `sharry.web.bindHost` and `sharry.web.bindPort` the host and port
for binding the http server
- `sharry.web.baseurl` this must be set to the external base url. So
if the app is at <http://example.com/>, then it should be set to
this value. It is used to restrict the authentication cookie and to
create links in the web application.
- `sharry.db.driver|user|url|password` the JDBC settings; currently it
should work with postgres and h2
- `sharry.upload.max-file-size` maximum file size to upload
- `sharry.authc.enable=true|false` whether to enable authentication
(default is `true`)
- `sharry.authc.extern.admin.enable=true|false` enables an admin
account for initial login (password is `admin`), default is `false`

Every setting can also be given as a Java system property by adding it
to the environment variable `SHARRY_JAVA_OPTS` (`-D` prefix is required
here):

``` shell
SHARRY_JAVA_OPTS="-Dsharry.authc.enable=false" ./sharry-server-0.0.1-SNAPSHOT.jar.sh
```

This overrides same settings in the configuration file.

### Reverse Proxy

When running behind a reverse proxy, it is importand to use HTTP 1.1.
For example, a minimal nginx config would look like this:

``` conf
server {
listen 0.0.0.0:80;
proxy_request_buffering off;
proxy_buffering off;
location / {
proxy_pass http://127.0.0.1:9090;
# this is important, because fs2-http can only do 1.1
# and it effectively disables request_buffering
proxy_http_version 1.1;
}
}
```
This project is distributed under the
[GPLv3+](https://spdx.org/licenses/GPL-3.0-or-later.html)
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

File renamed without changes
Loading

0 comments on commit 100a672

Please sign in to comment.