changed
pacaget
      agent -> probe
			
			
This commit is contained in:
		
							parent
							
								
									1d37f87065
								
							
						
					
					
						commit
						74beb66775
					
				@ -42,10 +42,10 @@ func InitServices()  {
 | 
			
		||||
	g_services = make(map[string]interface{},0)
 | 
			
		||||
 | 
			
		||||
	// proxy services save
 | 
			
		||||
	//AddServices("Probe", probe.NewAgentService())
 | 
			
		||||
	//AddServices("Probe", probe.NewProbeService())
 | 
			
		||||
	AddServices("Member", member.NewMemberService())
 | 
			
		||||
	AddServices("NoAuthProbe", noauthprobe.NewNoAuthAgentService())
 | 
			
		||||
	AddServices("Probe", probe.NewAgentService())
 | 
			
		||||
	AddServices("NoAuthProbe", noauthprobe.NewNoAuthProbeService())
 | 
			
		||||
	AddServices("Probe", probe.NewProbeService())
 | 
			
		||||
	AddServices("Target", target.NewTargetService())
 | 
			
		||||
	AddServices("Crawler", crawler.NewCrawlerService())
 | 
			
		||||
	AddServices("CrawlerInputItem", crawlerInputItem.NewCrawlerInputItemService())
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ import (
 | 
			
		||||
type NoAuthProbeService struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewNoAuthAgentService() *NoAuthProbeService {
 | 
			
		||||
func NewNoAuthProbeService() *NoAuthProbeService {
 | 
			
		||||
	return &NoAuthProbeService{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,7 @@ type NoAuthProbe struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthProbe {
 | 
			
		||||
func NewNoAuthProbe(apikey string, localIp int64, hostName string) *NoAuthProbe {
 | 
			
		||||
 | 
			
		||||
	na := &NoAuthProbe{
 | 
			
		||||
		Date:timestamp.Now(),
 | 
			
		||||
@ -41,7 +41,7 @@ func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthProbe
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func(as *NoAuthProbeService)SaveNoAuthAgent(na *NoAuthProbe) (string, error) {
 | 
			
		||||
func(as *NoAuthProbeService)Save(na *NoAuthProbe) (string, error) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	bytes, err := json.Marshal(na)
 | 
			
		||||
@ -52,7 +52,7 @@ func(as *NoAuthProbeService)SaveNoAuthAgent(na *NoAuthProbe) (string, error) {
 | 
			
		||||
	memMap := make(map[string]string)
 | 
			
		||||
	memMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes);
 | 
			
		||||
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthAgent", "create", memMap);
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthProbe", "create", memMap);
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
@ -65,7 +65,7 @@ func(as *NoAuthProbeService)CheckAuth(tempKey string) (string,error) {
 | 
			
		||||
 | 
			
		||||
	memMap := make(map[string]string)
 | 
			
		||||
 | 
			
		||||
	na := NewNoAuthAgent("", 0, "")
 | 
			
		||||
	na := NewNoAuthProbe("", 0, "")
 | 
			
		||||
	na.TempKey = tempKey
 | 
			
		||||
 | 
			
		||||
	bytes, err := json.Marshal(na)
 | 
			
		||||
@ -75,7 +75,7 @@ func(as *NoAuthProbeService)CheckAuth(tempKey string) (string,error) {
 | 
			
		||||
 | 
			
		||||
	memMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes);
 | 
			
		||||
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthAgent", "findByTempKey", memMap);
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthProbe", "findByTempKey", memMap);
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
@ -92,11 +92,11 @@ func(as *NoAuthProbeService)CheckAuth(tempKey string) (string,error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func(as *NoAuthProbeService)GetNoAuthList(excludeStatus string) (string,error) {
 | 
			
		||||
func(as *NoAuthProbeService)GetList(excludeStatus string) (string,error) {
 | 
			
		||||
 | 
			
		||||
	memMap := make(map[string]string)
 | 
			
		||||
 | 
			
		||||
	na := NewNoAuthAgent("", 0, "")
 | 
			
		||||
	na := NewNoAuthProbe("", 0, "")
 | 
			
		||||
	na.AuthStatus = excludeStatus
 | 
			
		||||
 | 
			
		||||
	bytes, err := json.Marshal(na)
 | 
			
		||||
@ -106,7 +106,7 @@ func(as *NoAuthProbeService)GetNoAuthList(excludeStatus string) (string,error) {
 | 
			
		||||
 | 
			
		||||
	memMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes);
 | 
			
		||||
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthAgent", "findAllByNoAuth", memMap);
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthProbe", "findAllByNoAuth", memMap);
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
@ -127,7 +127,7 @@ func (as *NoAuthProbeService)RequestAuth(noauthAgt NoAuthProbe, memberId, desc s
 | 
			
		||||
		return "", err;
 | 
			
		||||
	}
 | 
			
		||||
	paramMap["com.loafle.overflow.noauthprobe.model.NoAuthProbe"] = string(bytes)
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthAgent", "update", paramMap)
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthProbe", "update", paramMap)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
@ -139,7 +139,7 @@ func (as *NoAuthProbeService)RequestAuth(noauthAgt NoAuthProbe, memberId, desc s
 | 
			
		||||
	m := member.Member{}
 | 
			
		||||
	m.Id = json.Number(memberId)
 | 
			
		||||
	newAgent := probe.NewAgent(desc, m)
 | 
			
		||||
	newone, err := probe.NewAgentService().SaveAgent(newAgent)
 | 
			
		||||
	newone, err := probe.NewProbeService().SaveAgent(newAgent)
 | 
			
		||||
	if err!= nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
@ -147,10 +147,10 @@ func (as *NoAuthProbeService)RequestAuth(noauthAgt NoAuthProbe, memberId, desc s
 | 
			
		||||
	return newone, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (as *NoAuthProbeService)ReadNoAuthAgent(id string) (string, error){
 | 
			
		||||
func (as *NoAuthProbeService)Read(id string) (string, error){
 | 
			
		||||
	mm := make(map[string]string)
 | 
			
		||||
	mm["id"] = id
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthAgent", "find", mm)
 | 
			
		||||
	out, err := proxy.InvokeDB("noauthProbe", "find", mm)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
 | 
			
		||||
@ -23,14 +23,14 @@ func TestCreateUUid(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
func TestCreateNoAuthAgent(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	na := NewNoAuthAgent("233421390283", 111, "Snoop")
 | 
			
		||||
	na := NewNoAuthProbe("233421390283", 111, "Snoop")
 | 
			
		||||
 | 
			
		||||
	na.TempKey = "1111111"
 | 
			
		||||
	na.AuthStatus = "WAIT"
 | 
			
		||||
 | 
			
		||||
	nas := NewNoAuthAgentService()
 | 
			
		||||
	nas := NewNoAuthProbeService()
 | 
			
		||||
 | 
			
		||||
	out, err := nas.SaveNoAuthAgent(na)
 | 
			
		||||
	out, err := nas.Save(na)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
@ -42,12 +42,12 @@ func TestCreateNoAuthAgent(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
func TestCheckAuthNoAuthAgent(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	na := NewNoAuthAgent("2334278390283", 111, "Snoop")
 | 
			
		||||
	na := NewNoAuthProbe("2334278390283", 111, "Snoop")
 | 
			
		||||
 | 
			
		||||
	na.TempKey = "alsdkjf;alkdjsf;la"
 | 
			
		||||
	na.AuthStatus = "WAIT"
 | 
			
		||||
 | 
			
		||||
	nas := NewNoAuthAgentService()
 | 
			
		||||
	nas := NewNoAuthProbeService()
 | 
			
		||||
 | 
			
		||||
	out, err := nas.CheckAuth(na.TempKey)
 | 
			
		||||
 | 
			
		||||
@ -63,9 +63,9 @@ func TestCheckAuthNoAuthAgent(t *testing.T) {
 | 
			
		||||
func TestNoAuthList(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	nas := NewNoAuthAgentService()
 | 
			
		||||
	nas := NewNoAuthProbeService()
 | 
			
		||||
 | 
			
		||||
	out, err := nas.GetNoAuthList("ACCEPT")
 | 
			
		||||
	out, err := nas.GetList("ACCEPT")
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
@ -76,8 +76,8 @@ func TestNoAuthList(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRequestAuth(t *testing.T) {
 | 
			
		||||
	nas := NewNoAuthAgentService()
 | 
			
		||||
	res, err := nas.ReadNoAuthAgent("1")
 | 
			
		||||
	nas := NewNoAuthProbeService()
 | 
			
		||||
	res, err := nas.Read("1")
 | 
			
		||||
 | 
			
		||||
	na := NoAuthProbe{}
 | 
			
		||||
	json.Unmarshal([]byte(res), na)
 | 
			
		||||
@ -93,7 +93,7 @@ func TestRequestAuth(t *testing.T) {
 | 
			
		||||
func TestCheckAuth(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	ns := NewNoAuthAgentService()
 | 
			
		||||
	ns := NewNoAuthProbeService()
 | 
			
		||||
 | 
			
		||||
	str, err := ns.CheckAuth("3398473-90847903874")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ type Probe struct {
 | 
			
		||||
	Status          string        `json:"status,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAgentService() *ProbeService {
 | 
			
		||||
func NewProbeService() *ProbeService {
 | 
			
		||||
	return &ProbeService{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,7 @@ func TestSaveAgent(t *testing.T) {
 | 
			
		||||
	m.Id = json.Number("1")
 | 
			
		||||
 | 
			
		||||
	agt := NewAgent("test agent424", m)
 | 
			
		||||
	as := NewAgentService()
 | 
			
		||||
	as := NewProbeService()
 | 
			
		||||
 | 
			
		||||
	res, err := as.SaveAgent(agt)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -21,7 +21,7 @@ func TestSaveAgent(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func TestListAgent(t *testing.T) {
 | 
			
		||||
	as := NewAgentService()
 | 
			
		||||
	as := NewProbeService()
 | 
			
		||||
	m := member.Member{}
 | 
			
		||||
	m.Id = "1"
 | 
			
		||||
	if res, err := as.getAgentList(&m); err != nil {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user