mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:44:02 +03:00
Rewrite to WaitGroup.Go
This commit is contained in:
+4
-12
@@ -81,32 +81,24 @@ func (n *network) dnsResolve(protocol, address string) ([]string, error) {
|
||||
|
||||
switch protocol {
|
||||
case "tcp", "tcp4":
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
wg.Go(func() {
|
||||
resolved := n.dns.LookupA(address)
|
||||
|
||||
mutex.Lock()
|
||||
ips = append(ips, resolved...)
|
||||
mutex.Unlock()
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
switch protocol {
|
||||
case "tcp", "tcp6":
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
wg.Go(func() {
|
||||
resolved := n.dns.LookupAAAA(address)
|
||||
|
||||
mutex.Lock()
|
||||
ips = append(ips, resolved...)
|
||||
mutex.Unlock()
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user