MCPcopy Create free account
hub / github.com/tailscale/tailcat / parseWire

Function parseWire

tailcat.go:719–733  ·  view source on GitHub ↗

parseWire decodes cb into its wire form, without restoring the fields that [ConnInfo.ConnBlob] elides.

(cb ConnBlob)

Source from the content-addressed store, hash-verified

717// parseWire decodes cb into its wire form, without restoring the
718// fields that [ConnInfo.ConnBlob] elides.
719func parseWire(cb ConnBlob) (*wireConnInfo, error) {
720 rest, ok := strings.CutPrefix(string(cb), "tc")
721 if !ok {
722 return nil, errors.New("server address doesn't start with \"tc\"")
723 }
724 x, err := base64.RawURLEncoding.DecodeString(rest)
725 if err != nil {
726 return nil, fmt.Errorf("base64 decode: %w", err)
727 }
728 w := new(wireConnInfo)
729 if err := cbor.Unmarshal(x, w); err != nil {
730 return nil, fmt.Errorf("CBOR unmarshal: %v", err)
731 }
732 return w, nil
733}
734
735// ParseConnBlobRaw decodes cb into its wire form, without restoring
736// the implicit fields that [ParseConnBlob] synthesizes (region and

Callers 2

ParseConnBlobRawFunction · 0.85
ParseConnBlobFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected