Compare commits

...
8 Commits
Author SHA1 Message Date
Henrique Dias 3d06904d1f style: replace Tls by TLS 2018-04-21 08:42:23 +01:00
Henrique Dias 4dc7bae6ea Update .travis.yml 2018-04-21 08:39:55 +01:00
Henrique Dias 6b139d375c feat: TLS support 2018-04-21 08:39:32 +01:00
Florian Walther 80e3ffd57b added tls options to readme example config 2018-04-20 17:07:52 +02:00
Florian Walther 893d3b429a added TLS support 2018-04-20 17:05:21 +02:00
Henrique Dias cdaf929a4b Update readme.md 2018-04-08 19:04:07 +01:00
Henrique Dias d216a2edef Merge pull request #4 from alex3305/master
Adds a Systemd service unit
2018-04-08 19:03:19 +01:00
Alex van den Hoogen eeae21cd29 Adds a Systemd service unit
I wanted to run this application as a service on my Debian based machine,
which uses systemd as a service manager. Since there was no default or
example service available in this repository, I've added a very simple
service unit.
2018-04-08 12:48:53 +02:00
4 changed files with 39 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
language: go
go: 1.8.3
go: 1.10.x
env:
- "PATH=/home/travis/gopath/bin:$PATH"
+21 -2
View File
@@ -138,6 +138,9 @@ type cfg struct {
webdav *webdav.Config
address string
port string
tls bool
cert string
key string
auth map[string]string
}
@@ -147,6 +150,9 @@ func parseConfig() *cfg {
data := struct {
Address string `json:"address" yaml:"address"`
Port string `json:"port" yaml:"port"`
TLS bool `json:"tls" yaml:"tls"`
Cert string `json:"cert" yaml:"cert"`
Key string `json:"key" yaml:"key"`
Scope string `json:"scope" yaml:"scope"`
Modify bool `json:"modify" yaml:"modify"`
Rules []map[string]interface{} `json:"rules" yaml:"rules"`
@@ -154,6 +160,9 @@ func parseConfig() *cfg {
}{
Address: "0.0.0.0",
Port: "0",
TLS: false,
Cert: "cert.pem",
Key: "key.pem",
Scope: "./",
Modify: true,
}
@@ -172,6 +181,9 @@ func parseConfig() *cfg {
config := &cfg{
address: data.Address,
port: data.Port,
tls: data.TLS,
cert: data.Cert,
key: data.Key,
auth: map[string]string{},
webdav: &webdav.Config{
User: &webdav.User{
@@ -251,7 +263,14 @@ func main() {
fmt.Println("Listening on", listener.Addr().String())
// Starts the server.
if err := http.Serve(listener, handler); err != nil {
log.Fatal(err)
if cfg.tls {
if err := http.ServeTLS(listener, handler, cfg.cert, cfg.key); err != nil {
log.Fatal(err)
}
} else {
if err := http.Serve(listener, handler); err != nil {
log.Fatal(err)
}
}
}
+5
View File
@@ -9,6 +9,9 @@
scope: /path/to/files
address: 0.0.0.0
port: 8080
tls: false
cert: cert.pem
key: key.pem
users:
- username: admin
password: admin
@@ -25,4 +28,6 @@ users:
You can specify the path to the configuration file using the `--config` flag. By default, it will search for a `config.{yaml,json}` file on your current working directory.
An example of how to use this with `systemd` is on [webdav.service.example](/webdav.service.example).
Download it [here](https://github.com/hacdias/webdav/releases).
+12
View File
@@ -0,0 +1,12 @@
[Unit]
Description=WebDAV server
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/webdav --config /opt/webdav.config
Restart=on-failure
[Install]
WantedBy=multi-user.target