netbirdio/netbird · error

parse handshake sec

Error message

parse handshake sec: %w

What it means

The last_handshake_time_sec field from the wireguard UAPI output could not be parsed as an int64 in toLastHandshake. The timestamp string is empty or non-numeric, so the peer's handshake time is unknown.

Solutions

  1. Treat unparseable handshake times as no handshake
  2. Check UAPI output format compatibility
  3. Log the offending value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at client/iface/configurer/usp.go:487 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/a58deb557739b94b. Report an issue: GitHub.

Appendix: source

Thrown at client/iface/configurer/usp.go:487

		if p.PersistentKeepaliveInterval != nil {
			sb.WriteString(fmt.Sprintf("persistent_keepalive_interval=%d\n", int(p.PersistentKeepaliveInterval.Seconds())))
		}

		if p.ReplaceAllowedIPs {
			sb.WriteString("replace_allowed_ips=true\n")
		}

		for _, aip := range p.AllowedIPs {
			sb.WriteString(fmt.Sprintf("allowed_ip=%s\n", aip.String()))
		}
	}
	return sb.String()
}

func toLastHandshake(stringVar string) (time.Time, error) {
	sec, err := strconv.ParseInt(stringVar, 10, 64)
	if err != nil {
		return time.Time{}, fmt.Errorf("parse handshake sec: %w", err)
	}

	// If sec is 0 (Unix epoch), return zero time instead
	// This indicates no handshake has occurred
	if sec == 0 {
		return time.Time{}, nil
	}

	return time.Unix(sec, 0), nil
}

func toBytes(s string) (int64, error) {
	return strconv.ParseInt(s, 10, 64)
}

func getFwmark() int {
	if nbnet.AdvancedRouting() && runtime.GOOS == "linux" {
		return nbnet.ControlPlaneMark

View on GitHub (pinned to 93e97f4bf1)