misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
Simone Margaritelli 2024-09-21 17:52:50 +02:00
commit 7b4fc3d31d
2 changed files with 32 additions and 1 deletions

View file

@ -131,7 +131,9 @@ func (mod *ZeroGod) startAdvertiser(fileName string) error {
for _, svc := range advertiser.Services {
// if no external responder has been specified, check if port is available
if svc.Responder == "" {
// if the port was not set or is not available or is requesdted by another service
for svc.Port == 0 || !isPortAvailable(svc.Port) || isPortRequested(svc, services) {
// set a new one and try again
newPort := (rand.Intn(65535-1024) + 1024)
mod.Warning("port %d for service %s is not avaialble, trying %d ...",
svc.Port,