Merge pull request #2 from c35sys/master

Add *address* config option
This commit is contained in:
Henrique Dias
2017-12-21 17:01:18 +00:00
committed by GitHub
2 changed files with 20 additions and 15 deletions
+5 -1
View File
@@ -134,6 +134,7 @@ func getConfig() []byte {
type cfg struct { type cfg struct {
webdav *webdav.Config webdav *webdav.Config
address string
port string port string
auth map[string]string auth map[string]string
} }
@@ -142,12 +143,14 @@ func parseConfig() *cfg {
file := getConfig() file := getConfig()
data := struct { data := struct {
Address string `json:"address" yaml:"address"`
Port string `json:"port" yaml:"port"` Port string `json:"port" yaml:"port"`
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"`
Users []map[string]interface{} `json:"users" yaml:"users"` Users []map[string]interface{} `json:"users" yaml:"users"`
}{ }{
Address: "0.0.0.0",
Port: "0", Port: "0",
Scope: "./", Scope: "./",
Modify: true, Modify: true,
@@ -165,6 +168,7 @@ func parseConfig() *cfg {
} }
config := &cfg{ config := &cfg{
address: data.Address,
port: data.Port, port: data.Port,
auth: map[string]string{}, auth: map[string]string{},
webdav: &webdav.Config{ webdav: &webdav.Config{
@@ -224,7 +228,7 @@ func main() {
handler := basicAuth(cfg) handler := basicAuth(cfg)
// Builds the address and a listener. // Builds the address and a listener.
laddr := ":" + cfg.port laddr := cfg.address + ":" + cfg.port
listener, err := net.Listen("tcp", laddr) listener, err := net.Listen("tcp", laddr)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
+1
View File
@@ -7,6 +7,7 @@
```yaml ```yaml
scope: /path/to/files scope: /path/to/files
address: 0.0.0.0
port: 8080 port: 8080
users: users:
- username: admin - username: admin