div 쿼리 주소 변경
This commit is contained in:
@ -610,8 +610,7 @@ func (sh *serviceDescription) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
sh.authorize(w, r)
|
||||
} else if strings.HasSuffix(r.URL.Path, "/link") {
|
||||
sh.link(w, r)
|
||||
} else {
|
||||
// TODO : 세션키와 authtoken을 헤더로 받아서 accid 조회
|
||||
} else if strings.HasSuffix(r.URL.Path, "/divs") {
|
||||
queryvals := r.URL.Query()
|
||||
sk := queryvals.Get("sk")
|
||||
|
||||
@ -630,10 +629,44 @@ func (sh *serviceDescription) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
if divname := queryvals.Get("div"); len(divname) > 0 {
|
||||
servicecode := queryvals.Get("servicecode")
|
||||
if sh.ServiceCode != servicecode {
|
||||
logger.Println("service code is not valid :", servicecode, sh.ServiceCode)
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
divstrptr := atomic.LoadPointer(&sh.divisionsForUsersSerialized)
|
||||
divstr := *(*string)(divstrptr)
|
||||
w.Write([]byte(divstr))
|
||||
} else if strings.HasSuffix(r.URL.Path, "/addr") {
|
||||
queryvals := r.URL.Query()
|
||||
sk := queryvals.Get("sk")
|
||||
|
||||
//if len(token) == 0 || len(sk) == 0 {
|
||||
if len(sk) == 0 {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// TODO : 각 서버에 있는 자산? 캐릭터 정보를 보여줘야 하나. 뭘 보여줄지는 프로젝트에 문의
|
||||
// 일단 서버 종류만 내려보내자
|
||||
// 세션키가 있는지 확인
|
||||
if _, ok := sh.auths.IsValid(sk, ""); !ok {
|
||||
logger.Println("sessionkey is not valid :", sk)
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
servicecode := queryvals.Get("servicecode")
|
||||
if sh.ServiceCode != servicecode {
|
||||
logger.Println("service code is not valid :", servicecode, sh.ServiceCode)
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
divname := queryvals.Get("div")
|
||||
divname = strings.Trim(divname, `"`)
|
||||
// 점검중인지 아닌지 확인
|
||||
// 점검중이어도 입장이 가능한 인원이 있다.
|
||||
div := sh.Divisions[divname]
|
||||
if div != nil {
|
||||
switch div.State {
|
||||
@ -666,11 +699,12 @@ func (sh *serviceDescription) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
logger.Println("div.Maintenance is nil :", divname)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.Println("div is not found :", divname)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}
|
||||
} else {
|
||||
divstrptr := atomic.LoadPointer(&sh.divisionsForUsersSerialized)
|
||||
divstr := *(*string)(divstrptr)
|
||||
w.Write([]byte(divstr))
|
||||
}
|
||||
logger.Println("??? :", r.URL.Path)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user