projectdiscovery/interactsh

Maint: use async/await for services readiness

Mzack9999 opened this issue · 2 comments

Please describe your feature request:

Replace the following hardly readable asyncronous pattern:

dnsTcpAlive := make(chan bool, 1)
go dnsTcpServer.ListenAndServe(dnsTcpAlive)
okTcpAlive <-dnsTcpAlive

with async/await functional programming which adds proper error propagation (depends on Use projectdiscovery/utils#195):

checkTcp  := async.Exec(func() (bool, error) {
    return dnsTcpServer.ListenAndServe()
})
ok, err := checkTcp.Await()

@Mzack9999 When using the ListenAndServe() function along with Exec/Await, there is a potential for a blocking issue. This function is typically used by servers to wait for connections, meaning that the Await() function will wait indefinitely for a response. In most cases, servers will only provide an error message if they fail to start or are stopped. @Mzack9999 Am I missing something?

Makes sense, the await should be wrapped itself into another go routine. The current implementation of async/await doesn't fit the runtime logic.