mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-23 19:51:53 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d06904d1f | ||
|
|
4dc7bae6ea | ||
|
|
6b139d375c | ||
|
|
80e3ffd57b | ||
|
|
893d3b429a | ||
|
|
cdaf929a4b | ||
|
|
d216a2edef | ||
|
|
eeae21cd29 |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
go: 1.8.3
|
go: 1.10.x
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- "PATH=/home/travis/gopath/bin:$PATH"
|
- "PATH=/home/travis/gopath/bin:$PATH"
|
||||||
|
|||||||
+21
-2
@@ -138,6 +138,9 @@ type cfg struct {
|
|||||||
webdav *webdav.Config
|
webdav *webdav.Config
|
||||||
address string
|
address string
|
||||||
port string
|
port string
|
||||||
|
tls bool
|
||||||
|
cert string
|
||||||
|
key string
|
||||||
auth map[string]string
|
auth map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +150,9 @@ func parseConfig() *cfg {
|
|||||||
data := struct {
|
data := struct {
|
||||||
Address string `json:"address" yaml:"address"`
|
Address string `json:"address" yaml:"address"`
|
||||||
Port string `json:"port" yaml:"port"`
|
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"`
|
Scope string `json:"scope" yaml:"scope"`
|
||||||
Modify bool `json:"modify" yaml:"modify"`
|
Modify bool `json:"modify" yaml:"modify"`
|
||||||
Rules []map[string]interface{} `json:"rules" yaml:"rules"`
|
Rules []map[string]interface{} `json:"rules" yaml:"rules"`
|
||||||
@@ -154,6 +160,9 @@ func parseConfig() *cfg {
|
|||||||
}{
|
}{
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
Port: "0",
|
Port: "0",
|
||||||
|
TLS: false,
|
||||||
|
Cert: "cert.pem",
|
||||||
|
Key: "key.pem",
|
||||||
Scope: "./",
|
Scope: "./",
|
||||||
Modify: true,
|
Modify: true,
|
||||||
}
|
}
|
||||||
@@ -172,6 +181,9 @@ func parseConfig() *cfg {
|
|||||||
config := &cfg{
|
config := &cfg{
|
||||||
address: data.Address,
|
address: data.Address,
|
||||||
port: data.Port,
|
port: data.Port,
|
||||||
|
tls: data.TLS,
|
||||||
|
cert: data.Cert,
|
||||||
|
key: data.Key,
|
||||||
auth: map[string]string{},
|
auth: map[string]string{},
|
||||||
webdav: &webdav.Config{
|
webdav: &webdav.Config{
|
||||||
User: &webdav.User{
|
User: &webdav.User{
|
||||||
@@ -251,7 +263,14 @@ func main() {
|
|||||||
fmt.Println("Listening on", listener.Addr().String())
|
fmt.Println("Listening on", listener.Addr().String())
|
||||||
|
|
||||||
// Starts the server.
|
// Starts the server.
|
||||||
if err := http.Serve(listener, handler); err != nil {
|
if cfg.tls {
|
||||||
log.Fatal(err)
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
scope: /path/to/files
|
scope: /path/to/files
|
||||||
address: 0.0.0.0
|
address: 0.0.0.0
|
||||||
port: 8080
|
port: 8080
|
||||||
|
tls: false
|
||||||
|
cert: cert.pem
|
||||||
|
key: key.pem
|
||||||
users:
|
users:
|
||||||
- username: admin
|
- username: admin
|
||||||
password: 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.
|
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).
|
Download it [here](https://github.com/hacdias/webdav/releases).
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user