Commit d4f55f37 authored by dmknght's avatar dmknght

Fix devicde busy in test and fix progressbar

parent 3f7da044
......@@ -21,7 +21,7 @@
{
"label": "[Test]Test start program from scratch",
"type": "shell",
"command": "nim c --threads:on --define:ssl -r src/test/testmain.nim"
"command": "nim c --threads:on --define:ssl -r src/test/testmain.nim http://testphp.vulnweb.com/"
}
]
}
\ No newline at end of file
......@@ -24,9 +24,9 @@ proc showHelpCmd*(app = "dirbnim", keyword = "help", value = "", descr = "") =
proc progressBar*(subPath: string) =
stdout.eraseLine()
stdout.write(subPath)
stdout.flushFile()
stdout.eraseLine()
proc prntErr*(reason: string, descr = "") =
......
......@@ -3,9 +3,10 @@ import httpclient
import .. / cli / utils
proc checkBranch*(client: HttpClient, subPath, fullURL: string) =
proc checkBranch*(subPath, fullURL: string) =
progressBar(fullURL)
# TODO use a callback function instead of cli
var client = newHttpClient()
try:
let resp = client.get(fullURL)
if resp.status != "404 Not Found":
......@@ -16,4 +17,7 @@ proc checkBranch*(client: HttpClient, subPath, fullURL: string) =
prntErr(fullURL, "ProtocolError")
except:
echo getCurrentExceptionMsg()
echo repr(getCurrentException())
prntErr(fullURL, "Unknown")
finally:
client.close()
import httpclient
# import httpclient
import terminal
# import strutils
import bench
......@@ -11,12 +11,12 @@ const
proc createTest() =
var client = newHttpClient()
# var client = newHttpClient()
benchmark "ThreadPool loop":
for subPath in lines(dict):
let fullURL = url & subPath
spawn checkBranch(client, subPath, fullURL)
client.close()
spawn checkBranch(subPath, fullURL)
# client.close()
stdout.eraseLine()
createtest()
......@@ -4,7 +4,7 @@ import threadpool
import httpclient
import strutils
setMaxPoolSize(32)
setMaxPoolSize(64)
let allOptions = getOptions()
if not allOptions.paramError:
var client = newHttpClient()
......@@ -13,10 +13,10 @@ if not allOptions.paramError:
if not isEmptyOrWhitespace(line):
let fullURL = allOptions.url & line
# TODO handle / at end of line here
spawn checkBranch(client, line, fullURL)
spawn checkBranch(line, fullURL)
if not line.endsWith("/") and not line.contains("."): # and option
# Some web servers support forward to `/` for branches.
spawn checkBranch(client, line & "/", fullURL & "/")
spawn checkBranch(line & "/", fullURL & "/")
except:
discard
finally:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment