diff --git a/.idea/GobyApi.iml b/.idea/GobyApi.iml
new file mode 100644
index 0000000..17e140a
--- /dev/null
+++ b/.idea/GobyApi.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..565c347
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
new file mode 100644
index 0000000..a88a942
--- /dev/null
+++ b/.idea/dbnavigator.xml
@@ -0,0 +1,414 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..582e3f4
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/preferred-vcs.xml b/.idea/preferred-vcs.xml
new file mode 100644
index 0000000..a45e7e0
--- /dev/null
+++ b/.idea/preferred-vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+ Git
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..620dd64
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ current
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/goApi.go b/goApi.go
index 22d56c5..7b9fffc 100644
--- a/goApi.go
+++ b/goApi.go
@@ -20,6 +20,7 @@ import (
const (
maxScanContent int = 5
+ maxTryScanCount int = 3
)
type (
@@ -37,6 +38,8 @@ type (
PortScope string
ctx context.Context
+ TaskFaildTimes map[string]int
+
//url
startScanAddr string
getProgessAddr string
@@ -96,6 +99,8 @@ func NewGobyApi(ips []string, hostInfo, portScope string, ctx context.Context) *
g.PortScope = portScope
+ g.TaskFaildTimes = make(map[string]int,0)
+
g.init(ips)
return g
}
@@ -210,7 +215,7 @@ func (g *GobyApi) isIpv4(ip string) bool {
// set time wait
func (g *GobyApi) StartScan() {
fmt.Println("start scan task")
- if err := g.unitScan();err !=nil{
+ if err := g.unitScan(false);err !=nil{
panic(err)
}
go g.tickListen()
@@ -224,6 +229,7 @@ func (g *GobyApi) StartScan() {
if vv, ok := AllAsserts.LoadOrStore(g.TaskId, goTasks); ok {
fmt.Println(vv)
}
+ g.stopAllScanTasks()
fmt.Println("Scan Task Is Over!")
return
case <-g.ctx.Done():
@@ -285,17 +291,35 @@ func (g *GobyApi) checkGobyTaskProgess() bool {
pi := int(p)
if pi == 100 {
- g.unitScan()
+ g.unitScan(false)
fmt.Println("progress 100%")
return true
}
+
+ //如果一个任务连续3次0%,那么就将该任务剔除
+ if pi == 0{
+ if t,ok:=g.TaskFaildTimes[g.CurrentGobyTaskId];ok {
+ if t == maxTryScanCount{
+ g.unitScan(true)
+ fmt.Println("连续0%超过3次,扫描任务退出")
+ return true
+ }
+ t++
+ fmt.Printf("0% 第%d次\n",t)
+ }else{
+ g.TaskFaildTimes[g.CurrentGobyTaskId] = 1
+ }
+ }
+
fmt.Printf("Current progress is %d\n", pi)
return false
}
-func (g *GobyApi) unitScan() error {
+
+//传入是否要求停止该扫描结束信号
+func (g *GobyApi) unitScan(isStop bool) error {
// all finish
- if g.WaitingIps == nil || len(g.WaitingIps) == 0 {
+ if g.WaitingIps == nil || len(g.WaitingIps) == 0 || isStop {
fmt.Println("scan task all finished, now out!")
g.ScanStatus = true
g.notice <- 1
@@ -334,7 +358,7 @@ func (g *GobyApi) unitScan() error {
func (g *GobyApi) post(url string, data interface{}) ([]byte, error) {
// 超时时间:5秒
- client := &http.Client{Timeout: 5 * time.Second}
+ client := &http.Client{Timeout: 5 * time.Minute}
jsonStr, _ := json.Marshal(data)
resp, err := client.Post(url, "application/json", bytes.NewBuffer(jsonStr))
if err != nil {
diff --git a/lib/built-in-stubs.jar b/lib/built-in-stubs.jar
new file mode 100644
index 0000000..54f5d10
Binary files /dev/null and b/lib/built-in-stubs.jar differ