EnsureAvailablePorts checks if the proxy and DNS ports are available. If they are available, it returns them unchanged. If not, it allocates new available ports for them.
(port uint32)
| 1147 | // If they are available, it returns them unchanged. |
| 1148 | // If not, it allocates new available ports for them. |
| 1149 | func EnsureAvailablePorts(port uint32) (uint32, error) { |
| 1150 | var newPort uint32 |
| 1151 | var err error |
| 1152 | if isPortAvailable(port) { |
| 1153 | return port, nil |
| 1154 | } |
| 1155 | newPort, err = GetAvailablePort() |
| 1156 | if err != nil { |
| 1157 | return 0, fmt.Errorf("failed to allocate new proxy port: %w", err) |
| 1158 | } |
| 1159 | return newPort, nil |
| 1160 | } |
| 1161 | |
| 1162 | func EnsureRmBeforeName(cmd string) string { |
| 1163 | parts := strings.Split(cmd, " ") |
no test coverage detected