diff --git a/initialize/rpc_impl.go b/initialize/rpc_impl.go index ee9cd30..91bcb2b 100644 --- a/initialize/rpc_impl.go +++ b/initialize/rpc_impl.go @@ -6,7 +6,7 @@ import ( "git.loafle.net/overflow/overflow_proxy_service/proxy/apikey" "git.loafle.net/overflow/overflow_proxy_service/proxy/keystore" "git.loafle.net/overflow/overflow_proxy_service/proxy/noauthagent" - "encoding/json" + ) @@ -14,6 +14,18 @@ type InitializeServerImpl struct { } +func testPollInterval(types string) float64 { + + var defaultTime float64 = 10 + + if types == "CheckAuth" { + return defaultTime + } + + return defaultTime; +} + + func (s *InitializeServerImpl) StartAgent(c context.Context, info *pb.AgentInfo) (*pb.InitResponse, error) { output := &pb.InitResponse{} @@ -51,7 +63,8 @@ func (s *InitializeServerImpl) RequestTempKey(c context.Context, info *pb.ReqTem ti.TempKey = key //FIXME:: check Poll intervar - //ti.PollInterval + time := testPollInterval("CheckAuth") + ti.PollInterval = time return ti, nil } @@ -65,7 +78,7 @@ func (s *InitializeServerImpl) CheckAuth(c context.Context, info *pb.TempKey) (* as := &pb.AuthStatus{} - as.Type = pb.AuthStatus_AUTH_WAIT + as.Type = pb.AuthStatus_WAIT str, err := ns.CheckAuth(info.Value) @@ -73,18 +86,10 @@ func (s *InitializeServerImpl) CheckAuth(c context.Context, info *pb.TempKey) (* return as, err } - //FIXME auth type - res := "" - - err = json.Unmarshal([]byte(str), &res) - if err != nil { - return as , nil - } - - if res == "ACCEPT" { - as.Type = pb.AuthStatus_AUTH_ACCEPT - } else if res == "REFUSE" { - as.Type = pb.AuthStatus_AUTH_REFUSE + if str == pb.AuthStatus_REFUSE.String() { + as.Type = pb.AuthStatus_ACCEPT + } else if str == pb.AuthStatus_REFUSE.String() { + as.Type = pb.AuthStatus_REFUSE } return as, nil