|
@ -23,6 +23,7 @@ var ( |
|
|
|
|
|
|
|
|
type WebDavOption struct { |
|
|
type WebDavOption struct { |
|
|
filer *string |
|
|
filer *string |
|
|
|
|
|
bindIp *string |
|
|
filerRootPath *string |
|
|
filerRootPath *string |
|
|
port *int |
|
|
port *int |
|
|
collection *string |
|
|
collection *string |
|
@ -38,6 +39,7 @@ type WebDavOption struct { |
|
|
func init() { |
|
|
func init() { |
|
|
cmdWebDav.Run = runWebDav // break init cycle
|
|
|
cmdWebDav.Run = runWebDav // break init cycle
|
|
|
webDavStandaloneOptions.filer = cmdWebDav.Flag.String("filer", "localhost:8888", "filer server address") |
|
|
webDavStandaloneOptions.filer = cmdWebDav.Flag.String("filer", "localhost:8888", "filer server address") |
|
|
|
|
|
webDavStandaloneOptions.bindIp = cmdWebDav.Flag.String("ip.bind", "", "ip address to bind to. Default listen to all.") |
|
|
webDavStandaloneOptions.port = cmdWebDav.Flag.Int("port", 7333, "webdav server http listen port") |
|
|
webDavStandaloneOptions.port = cmdWebDav.Flag.Int("port", 7333, "webdav server http listen port") |
|
|
webDavStandaloneOptions.collection = cmdWebDav.Flag.String("collection", "", "collection to create the files") |
|
|
webDavStandaloneOptions.collection = cmdWebDav.Flag.String("collection", "", "collection to create the files") |
|
|
webDavStandaloneOptions.replication = cmdWebDav.Flag.String("replication", "", "replication to create the files") |
|
|
webDavStandaloneOptions.replication = cmdWebDav.Flag.String("replication", "", "replication to create the files") |
|
@ -62,7 +64,8 @@ func runWebDav(cmd *Command, args []string) bool { |
|
|
|
|
|
|
|
|
util.LoadSecurityConfiguration() |
|
|
util.LoadSecurityConfiguration() |
|
|
|
|
|
|
|
|
glog.V(0).Infof("Starting Seaweed WebDav Server %s at https port %d", util.Version(), *webDavStandaloneOptions.port) |
|
|
|
|
|
|
|
|
listenAddress := fmt.Sprintf("%s:%d", *webDavStandaloneOptions.bindIp, *webDavStandaloneOptions.port) |
|
|
|
|
|
glog.V(0).Infof("Starting Seaweed WebDav Server %s at %s", util.Version(), listenAddress) |
|
|
|
|
|
|
|
|
return webDavStandaloneOptions.startWebDav() |
|
|
return webDavStandaloneOptions.startWebDav() |
|
|
|
|
|
|
|
@ -126,19 +129,23 @@ func (wo *WebDavOption) startWebDav() bool { |
|
|
|
|
|
|
|
|
httpS := &http.Server{Handler: ws.Handler} |
|
|
httpS := &http.Server{Handler: ws.Handler} |
|
|
|
|
|
|
|
|
listenAddress := fmt.Sprintf(":%d", *wo.port) |
|
|
|
|
|
|
|
|
if wo.bindIp == nil { |
|
|
|
|
|
wo.bindIp = new(string) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listenAddress := fmt.Sprintf("%s:%d", *wo.bindIp, *wo.port) |
|
|
webDavListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second) |
|
|
webDavListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
glog.Fatalf("WebDav Server listener on %s error: %v", listenAddress, err) |
|
|
glog.Fatalf("WebDav Server listener on %s error: %v", listenAddress, err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if *wo.tlsPrivateKey != "" { |
|
|
if *wo.tlsPrivateKey != "" { |
|
|
glog.V(0).Infof("Start Seaweed WebDav Server %s at https port %d", util.Version(), *wo.port) |
|
|
|
|
|
|
|
|
glog.V(0).Infof("Start Seaweed WebDav Server %s at https %s", util.Version(), listenAddress) |
|
|
if err = httpS.ServeTLS(webDavListener, *wo.tlsCertificate, *wo.tlsPrivateKey); err != nil { |
|
|
if err = httpS.ServeTLS(webDavListener, *wo.tlsCertificate, *wo.tlsPrivateKey); err != nil { |
|
|
glog.Fatalf("WebDav Server Fail to serve: %v", err) |
|
|
glog.Fatalf("WebDav Server Fail to serve: %v", err) |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
glog.V(0).Infof("Start Seaweed WebDav Server %s at http port %d", util.Version(), *wo.port) |
|
|
|
|
|
|
|
|
glog.V(0).Infof("Start Seaweed WebDav Server %s at http %s", util.Version(), listenAddress) |
|
|
if err = httpS.Serve(webDavListener); err != nil { |
|
|
if err = httpS.Serve(webDavListener); err != nil { |
|
|
glog.Fatalf("WebDav Server Fail to serve: %v", err) |
|
|
glog.Fatalf("WebDav Server Fail to serve: %v", err) |
|
|
} |
|
|
} |
|
|