MCPcopy Index your code
hub / github.com/coder/coder / readXauthEntry

Function readXauthEntry

agent/agentssh/x11.go:583–648  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

581}
582
583func readXauthEntry(r io.Reader) (xauthEntry, error) {
584 var entry xauthEntry
585
586 // Read family
587 err := binary.Read(r, binary.BigEndian, &entry.family)
588 if err != nil {
589 return xauthEntry{}, xerrors.Errorf("failed to read family: %w", err)
590 }
591
592 // Read address
593 var addressLength uint16
594 err = binary.Read(r, binary.BigEndian, &addressLength)
595 if err != nil {
596 return xauthEntry{}, xerrors.Errorf("failed to read address length: %w", err)
597 }
598
599 addressBytes := make([]byte, addressLength)
600 _, err = r.Read(addressBytes)
601 if err != nil {
602 return xauthEntry{}, xerrors.Errorf("failed to read address: %w", err)
603 }
604 entry.address = string(addressBytes)
605
606 // Read display
607 var displayLength uint16
608 err = binary.Read(r, binary.BigEndian, &displayLength)
609 if err != nil {
610 return xauthEntry{}, xerrors.Errorf("failed to read display length: %w", err)
611 }
612
613 displayBytes := make([]byte, displayLength)
614 _, err = r.Read(displayBytes)
615 if err != nil {
616 return xauthEntry{}, xerrors.Errorf("failed to read display: %w", err)
617 }
618 entry.display = string(displayBytes)
619
620 // Read auth protocol
621 var authProtocolLength uint16
622 err = binary.Read(r, binary.BigEndian, &authProtocolLength)
623 if err != nil {
624 return xauthEntry{}, xerrors.Errorf("failed to read auth protocol length: %w", err)
625 }
626
627 authProtocolBytes := make([]byte, authProtocolLength)
628 _, err = r.Read(authProtocolBytes)
629 if err != nil {
630 return xauthEntry{}, xerrors.Errorf("failed to read auth protocol: %w", err)
631 }
632 entry.authProtocol = string(authProtocolBytes)
633
634 // Read auth cookie
635 var authCookieLength uint16
636 err = binary.Read(r, binary.BigEndian, &authCookieLength)
637 if err != nil {
638 return xauthEntry{}, xerrors.Errorf("failed to read auth cookie length: %w", err)
639 }
640

Callers 1

addXauthEntryFunction · 0.85

Calls 2

ReadMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected