MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ParseGatewayServerAddress

Function ParseGatewayServerAddress

pkg/pfconfig/shared/shared.go:385–401  ·  view source on GitHub ↗

ParseGatewayServerAddress parses gateway server address s into hostname and port, port is equal to the port contained in s or DefaultGatewayServerUDPPort otherwise.

(s string)

Source from the content-addressed store, hash-verified

383// ParseGatewayServerAddress parses gateway server address s into hostname and port,
384// port is equal to the port contained in s or DefaultGatewayServerUDPPort otherwise.
385func ParseGatewayServerAddress(s string) (string, uint16, error) {
386 host, portStr, err := net.SplitHostPort(s)
387 if err != nil {
388 if host, _, err := net.SplitHostPort(fmt.Sprintf("%s:1700", s)); err == nil && host != "" {
389 return host, 1700, nil
390 }
391 return "", 0, errInvalidGatewayServerAddress.WithCause(err)
392 }
393 if host == "" {
394 return "", 0, errInvalidGatewayServerAddress.WithCause(errEmptyGatewayServerAddress)
395 }
396 port, err := strconv.ParseUint(portStr, 10, 16)
397 if err != nil {
398 return "", 0, errInvalidGatewayServerAddress.WithCause(err)
399 }
400 return host, uint16(port), nil
401}

Callers 3

BuildLorafwdFunction · 0.92
BuildFunction · 0.92

Calls 1

WithCauseMethod · 0.45

Tested by 1