MCPcopy
hub / github.com/keploy/keploy / EnsureAvailablePorts

Function EnsureAvailablePorts

utils/utils.go:1149–1160  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1147// If they are available, it returns them unchanged.
1148// If not, it allocates new available ports for them.
1149func 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
1162func EnsureRmBeforeName(cmd string) string {
1163 parts := strings.Split(cmd, " ")

Callers 1

SetupMethod · 0.92

Calls 2

isPortAvailableFunction · 0.85
GetAvailablePortFunction · 0.85

Tested by

no test coverage detected