mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-22 03:20:41 +08:00
+5
-1
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user