Skip to content

Commit

Permalink
Merge pull request #2 from c35sys/master
Browse files Browse the repository at this point in the history
Add *address* config option
  • Loading branch information
hacdias authored Dec 21, 2017
2 parents ac0e137 + 8271975 commit 6c10c35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
32 changes: 18 additions & 14 deletions cmd/webdav/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,27 @@ func getConfig() []byte {
}

type cfg struct {
webdav *webdav.Config
port string
auth map[string]string
webdav *webdav.Config
address string
port string
auth map[string]string
}

func parseConfig() *cfg {
file := getConfig()

data := struct {
Port string `json:"port" yaml:"port"`
Scope string `json:"scope" yaml:"scope"`
Modify bool `json:"modify" yaml:"modify"`
Rules []map[string]interface{} `json:"rules" yaml:"rules"`
Users []map[string]interface{} `json:"users" yaml:"users"`
Address string `json:"address" yaml:"address"`
Port string `json:"port" yaml:"port"`
Scope string `json:"scope" yaml:"scope"`
Modify bool `json:"modify" yaml:"modify"`
Rules []map[string]interface{} `json:"rules" yaml:"rules"`
Users []map[string]interface{} `json:"users" yaml:"users"`
}{
Port: "0",
Scope: "./",
Modify: true,
Address: "0.0.0.0",
Port: "0",
Scope: "./",
Modify: true,
}

var err error
Expand All @@ -165,8 +168,9 @@ func parseConfig() *cfg {
}

config := &cfg{
port: data.Port,
auth: map[string]string{},
address: data.Address,
port: data.Port,
auth: map[string]string{},
webdav: &webdav.Config{
User: &webdav.User{
Scope: data.Scope,
Expand Down Expand Up @@ -224,7 +228,7 @@ func main() {
handler := basicAuth(cfg)

// Builds the address and a listener.
laddr := ":" + cfg.port
laddr := cfg.address + ":" + cfg.port
listener, err := net.Listen("tcp", laddr)
if err != nil {
log.Fatal(err)
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

```yaml
scope: /path/to/files
address: 0.0.0.0
port: 8080
users:
- username: admin
Expand All @@ -22,4 +23,4 @@ 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.

Download it [here](https://github.com/hacdias/webdav/releases).
Download it [here](https://github.com/hacdias/webdav/releases).

0 comments on commit 6c10c35

Please sign in to comment.