Add read only public port on volume server

Add read only public port on volume server
This commit is contained in:
chrislusf
2015-03-09 01:10:01 -07:00
parent d48d76cb4f
commit f511b507a5
12 changed files with 71 additions and 74 deletions

View File

@@ -23,8 +23,8 @@ type VolumeServer struct {
FixJpgOrientation bool
}
func NewVolumeServer(publicMux, adminMux *http.ServeMux, ip string,
port, adminPort int, publicUrl string,
func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
port int, publicUrl string,
folders []string, maxCounts []int,
masterNode string, pulseSeconds int,
dataCenter string, rack string,
@@ -37,7 +37,7 @@ func NewVolumeServer(publicMux, adminMux *http.ServeMux, ip string,
FixJpgOrientation: fixJpgOrientation,
}
vs.SetMasterNode(masterNode)
vs.store = storage.NewStore(port, adminPort, ip, publicUrl, folders, maxCounts)
vs.store = storage.NewStore(port, ip, publicUrl, folders, maxCounts)
vs.guard = security.NewGuard(whiteList, "")
@@ -56,8 +56,7 @@ func NewVolumeServer(publicMux, adminMux *http.ServeMux, ip string,
adminMux.HandleFunc("/delete", vs.guard.WhiteList(vs.batchDeleteHandler))
adminMux.HandleFunc("/", vs.privateStoreHandler)
}
publicMux.HandleFunc("/delete", vs.guard.Secure(vs.batchDeleteHandler))
publicMux.HandleFunc("/", vs.publicStoreHandler)
publicMux.HandleFunc("/", vs.publicReadOnlyHandler)
go func() {
connected := true

View File

@@ -8,19 +8,17 @@ import (
/*
Public port supports reads. Writes on public port can have one of the 3
If volume server is started with a separated public port, the public port will
be more "secure".
Public port currently only supports reads.
Later writes on public port can have one of the 3
security settings:
1. not secured
2. secured by white list
3. secured by JWT(Json Web Token)
If volume server is started with a separated admin port, the admin port will
have less "security" for easier implementation.
Admin port always supports reads. Writes on admin port can have one of
the 2 security settings:
1. not secured
2. secured by white list
*/
func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Request) {
@@ -43,7 +41,7 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque
}
}
func (vs *VolumeServer) publicStoreHandler(w http.ResponseWriter, r *http.Request) {
func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
stats.ReadRequest()
@@ -51,14 +49,5 @@ func (vs *VolumeServer) publicStoreHandler(w http.ResponseWriter, r *http.Reques
case "HEAD":
stats.ReadRequest()
vs.GetOrHeadHandler(w, r)
case "DELETE":
stats.DeleteRequest()
vs.guard.Secure(vs.DeleteHandler)(w, r)
case "PUT":
stats.WriteRequest()
vs.guard.Secure(vs.PostHandler)(w, r)
case "POST":
stats.WriteRequest()
vs.guard.Secure(vs.PostHandler)(w, r)
}
}