mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-26 13:11:54 +08:00
+18
-14
@@ -133,24 +133,27 @@ func getConfig() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type cfg struct {
|
type cfg struct {
|
||||||
webdav *webdav.Config
|
webdav *webdav.Config
|
||||||
port string
|
address string
|
||||||
auth map[string]string
|
port string
|
||||||
|
auth map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseConfig() *cfg {
|
func parseConfig() *cfg {
|
||||||
file := getConfig()
|
file := getConfig()
|
||||||
|
|
||||||
data := struct {
|
data := struct {
|
||||||
Port string `json:"port" yaml:"port"`
|
Address string `json:"address" yaml:"address"`
|
||||||
Scope string `json:"scope" yaml:"scope"`
|
Port string `json:"port" yaml:"port"`
|
||||||
Modify bool `json:"modify" yaml:"modify"`
|
Scope string `json:"scope" yaml:"scope"`
|
||||||
Rules []map[string]interface{} `json:"rules" yaml:"rules"`
|
Modify bool `json:"modify" yaml:"modify"`
|
||||||
Users []map[string]interface{} `json:"users" yaml:"users"`
|
Rules []map[string]interface{} `json:"rules" yaml:"rules"`
|
||||||
|
Users []map[string]interface{} `json:"users" yaml:"users"`
|
||||||
}{
|
}{
|
||||||
Port: "0",
|
Address: "0.0.0.0",
|
||||||
Scope: "./",
|
Port: "0",
|
||||||
Modify: true,
|
Scope: "./",
|
||||||
|
Modify: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -165,8 +168,9 @@ func parseConfig() *cfg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config := &cfg{
|
config := &cfg{
|
||||||
port: data.Port,
|
address: data.Address,
|
||||||
auth: map[string]string{},
|
port: data.Port,
|
||||||
|
auth: map[string]string{},
|
||||||
webdav: &webdav.Config{
|
webdav: &webdav.Config{
|
||||||
User: &webdav.User{
|
User: &webdav.User{
|
||||||
Scope: data.Scope,
|
Scope: data.Scope,
|
||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user