changed
pacaget agent -> probe
This commit is contained in:
parent
1f54c37e3c
commit
1d37f87065
@ -42,10 +42,10 @@ func InitServices() {
|
||||
g_services = make(map[string]interface{},0)
|
||||
|
||||
// proxy services save
|
||||
//AddServices("Agent", probe.NewAgentService())
|
||||
//AddServices("Probe", probe.NewAgentService())
|
||||
AddServices("Member", member.NewMemberService())
|
||||
AddServices("NoAuthAgent", noauthprobe.NewNoAuthAgentService())
|
||||
AddServices("Agent", probe.NewAgentService())
|
||||
AddServices("NoAuthProbe", noauthprobe.NewNoAuthAgentService())
|
||||
AddServices("Probe", probe.NewAgentService())
|
||||
AddServices("Target", target.NewTargetService())
|
||||
AddServices("Crawler", crawler.NewCrawlerService())
|
||||
AddServices("CrawlerInputItem", crawlerInputItem.NewCrawlerInputItemService())
|
||||
|
@ -10,15 +10,15 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type NoAuthAgentService struct {
|
||||
type NoAuthProbeService struct {
|
||||
}
|
||||
|
||||
func NewNoAuthAgentService() *NoAuthAgentService {
|
||||
return &NoAuthAgentService{}
|
||||
func NewNoAuthAgentService() *NoAuthProbeService {
|
||||
return &NoAuthProbeService{}
|
||||
}
|
||||
|
||||
|
||||
type NoAuthAgent struct {
|
||||
type NoAuthProbe struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
TempKey string `json:"tempKey,omitempty"`
|
||||
Date timestamp.Timestamp`json:"date,omitempty"`
|
||||
@ -29,9 +29,9 @@ type NoAuthAgent struct {
|
||||
}
|
||||
|
||||
|
||||
func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthAgent {
|
||||
func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthProbe {
|
||||
|
||||
na := &NoAuthAgent{
|
||||
na := &NoAuthProbe{
|
||||
Date:timestamp.Now(),
|
||||
ApiKey:apikey,
|
||||
LocalIP:localIp,
|
||||
@ -41,7 +41,7 @@ func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthAgent
|
||||
}
|
||||
|
||||
|
||||
func(as *NoAuthAgentService)SaveNoAuthAgent(na *NoAuthAgent) (string, error) {
|
||||
func(as *NoAuthProbeService)SaveNoAuthAgent(na *NoAuthProbe) (string, error) {
|
||||
|
||||
|
||||
bytes, err := json.Marshal(na)
|
||||
@ -50,7 +50,7 @@ func(as *NoAuthAgentService)SaveNoAuthAgent(na *NoAuthAgent) (string, error) {
|
||||
}
|
||||
|
||||
memMap := make(map[string]string)
|
||||
memMap["com.loafle.overflow.noauthprobe.model.NoAuthAgent"] = string(bytes);
|
||||
memMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes);
|
||||
|
||||
out, err := proxy.InvokeDB("noauthAgent", "create", memMap);
|
||||
|
||||
@ -61,7 +61,7 @@ func(as *NoAuthAgentService)SaveNoAuthAgent(na *NoAuthAgent) (string, error) {
|
||||
return out, nil;
|
||||
}
|
||||
|
||||
func(as *NoAuthAgentService)CheckAuth(tempKey string) (string,error) {
|
||||
func(as *NoAuthProbeService)CheckAuth(tempKey string) (string,error) {
|
||||
|
||||
memMap := make(map[string]string)
|
||||
|
||||
@ -73,7 +73,7 @@ func(as *NoAuthAgentService)CheckAuth(tempKey string) (string,error) {
|
||||
return "", err;
|
||||
}
|
||||
|
||||
memMap["com.loafle.overflow.noauthprobe.model.NoAuthAgent"] = string(bytes);
|
||||
memMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes);
|
||||
|
||||
out, err := proxy.InvokeDB("noauthAgent", "findByTempKey", memMap);
|
||||
|
||||
@ -81,7 +81,7 @@ func(as *NoAuthAgentService)CheckAuth(tempKey string) (string,error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
nn := NoAuthAgent{}
|
||||
nn := NoAuthProbe{}
|
||||
err = json.Unmarshal([]byte(out), &nn)
|
||||
|
||||
if err != nil {
|
||||
@ -92,7 +92,7 @@ func(as *NoAuthAgentService)CheckAuth(tempKey string) (string,error) {
|
||||
}
|
||||
|
||||
|
||||
func(as *NoAuthAgentService)GetNoAuthList(excludeStatus string) (string,error) {
|
||||
func(as *NoAuthProbeService)GetNoAuthList(excludeStatus string) (string,error) {
|
||||
|
||||
memMap := make(map[string]string)
|
||||
|
||||
@ -104,7 +104,7 @@ func(as *NoAuthAgentService)GetNoAuthList(excludeStatus string) (string,error) {
|
||||
return "", err;
|
||||
}
|
||||
|
||||
memMap["com.loafle.overflow.noauthprobe.model.NoAuthAgent"] = string(bytes);
|
||||
memMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes);
|
||||
|
||||
out, err := proxy.InvokeDB("noauthAgent", "findAllByNoAuth", memMap);
|
||||
|
||||
@ -118,7 +118,7 @@ func(as *NoAuthAgentService)GetNoAuthList(excludeStatus string) (string,error) {
|
||||
|
||||
|
||||
|
||||
func (as *NoAuthAgentService)RequestAuth(noauthAgt NoAuthAgent, memberId, desc string) (string, error) {
|
||||
func (as *NoAuthProbeService)RequestAuth(noauthAgt NoAuthProbe, memberId, desc string) (string, error) {
|
||||
paramMap := make(map[string]string)
|
||||
noauthAgt.AuthStatus = "ACCEPT"
|
||||
|
||||
@ -126,7 +126,7 @@ func (as *NoAuthAgentService)RequestAuth(noauthAgt NoAuthAgent, memberId, desc s
|
||||
if err != nil {
|
||||
return "", err;
|
||||
}
|
||||
paramMap["com.loafle.overflow.noauthprobe.model.NoAuthAgent"] = string(bytes)
|
||||
paramMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes)
|
||||
out, err := proxy.InvokeDB("noauthAgent", "update", paramMap)
|
||||
|
||||
if err != nil {
|
||||
@ -134,7 +134,7 @@ func (as *NoAuthAgentService)RequestAuth(noauthAgt NoAuthAgent, memberId, desc s
|
||||
}
|
||||
|
||||
if len(out) == 0 {
|
||||
return "", errors.New("Cannot update Agent. ")
|
||||
return "", errors.New("Cannot update Probe. ")
|
||||
}
|
||||
m := member.Member{}
|
||||
m.Id = json.Number(memberId)
|
||||
@ -147,7 +147,7 @@ func (as *NoAuthAgentService)RequestAuth(noauthAgt NoAuthAgent, memberId, desc s
|
||||
return newone, nil
|
||||
}
|
||||
|
||||
func (as *NoAuthAgentService)ReadNoAuthAgent(id string) (string, error){
|
||||
func (as *NoAuthProbeService)ReadNoAuthAgent(id string) (string, error){
|
||||
mm := make(map[string]string)
|
||||
mm["id"] = id
|
||||
out, err := proxy.InvokeDB("noauthAgent", "find", mm)
|
||||
|
@ -79,7 +79,7 @@ func TestRequestAuth(t *testing.T) {
|
||||
nas := NewNoAuthAgentService()
|
||||
res, err := nas.ReadNoAuthAgent("1")
|
||||
|
||||
na := NoAuthAgent{}
|
||||
na := NoAuthProbe{}
|
||||
json.Unmarshal([]byte(res), na)
|
||||
|
||||
newone, err := nas.RequestAuth(na, "1", "test")
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type AgentService struct {
|
||||
type ProbeService struct {
|
||||
}
|
||||
|
||||
type Agent struct {
|
||||
type Probe struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
AuthorizedDate int64 `json:"authorizedDate,Number,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
@ -21,13 +21,13 @@ type Agent struct {
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
func NewAgentService() *AgentService {
|
||||
return &AgentService{}
|
||||
func NewAgentService() *ProbeService {
|
||||
return &ProbeService{}
|
||||
}
|
||||
|
||||
func NewAgent(desc string, member member.Member) *Agent {
|
||||
func NewAgent(desc string, member member.Member) *Probe {
|
||||
|
||||
na := &Agent{
|
||||
na := &Probe{
|
||||
AuthorizedDate: time.Now().Unix(),
|
||||
Description: desc,
|
||||
Member: member,
|
||||
@ -35,7 +35,7 @@ func NewAgent(desc string, member member.Member) *Agent {
|
||||
return na
|
||||
}
|
||||
|
||||
func (as *AgentService) SaveAgent(agent *Agent) (string, error) {
|
||||
func (as *ProbeService) SaveAgent(agent *Probe) (string, error) {
|
||||
//bytes, err := json.Marshal(probe)
|
||||
//if err != nil {
|
||||
// return "", err
|
||||
@ -43,7 +43,7 @@ func (as *AgentService) SaveAgent(agent *Agent) (string, error) {
|
||||
//fmt.Println(probe.Member.Id)
|
||||
//fmt.Println(string(bytes))
|
||||
//paramMap := make(map[string]string)
|
||||
//paramMap["com.loafle.overflow.probe.model.Agent"] = string(bytes)
|
||||
//paramMap["com.loafle.overflow.probe.model.Probe"] = string(bytes)
|
||||
//
|
||||
//out, err := proxy.InvokeDB("probe", "create", paramMap)
|
||||
|
||||
@ -56,7 +56,7 @@ func (as *AgentService) SaveAgent(agent *Agent) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (as *AgentService) GetAgentList(mem *member.Member) (string, error) {
|
||||
func (as *ProbeService) GetAgentList(mem *member.Member) (string, error) {
|
||||
//paramMap := make(map[string]string)
|
||||
//
|
||||
//mem := member.NewMember()
|
||||
@ -80,6 +80,6 @@ func (as *AgentService) GetAgentList(mem *member.Member) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (as *AgentService) GetModel() interface{} {
|
||||
return &Agent{}
|
||||
func (as *ProbeService) GetModel() interface{} {
|
||||
return &Probe{}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user