mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-22 03:20:41 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d06904d1f | ||
|
|
4dc7bae6ea | ||
|
|
6b139d375c | ||
|
|
80e3ffd57b | ||
|
|
893d3b429a | ||
|
|
cdaf929a4b | ||
|
|
d216a2edef | ||
|
|
eeae21cd29 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
language: go
|
||||
|
||||
go: 1.8.3
|
||||
go: 1.10.x
|
||||
|
||||
env:
|
||||
- "PATH=/home/travis/gopath/bin:$PATH"
|
||||
|
||||
+21
-2
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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