MCPcopy Create free account
hub / github.com/coder/wush / AuthKey

Method AuthKey

overlay/auth.go:50–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48}
49
50func (ca *ClientAuth) AuthKey() string {
51 buf := bytes.NewBuffer(nil)
52
53 buf.WriteByte(1)
54
55 if ca.Web {
56 buf.WriteByte(1)
57 } else {
58 buf.WriteByte(0)
59 }
60
61 buf.WriteByte(byte(ca.ReceiverStunAddr.Addr().BitLen() / 8))
62 if ca.ReceiverStunAddr.Addr().BitLen() > 0 {
63 stunBytes, err := ca.ReceiverStunAddr.MarshalBinary()
64 if err != nil {
65 panic(fmt.Sprint("failed to marshal stun addr:", err))
66 }
67 buf.Write(stunBytes)
68 }
69
70 derpBuf := [2]byte{}
71 binary.BigEndian.PutUint16(derpBuf[:], ca.ReceiverDERPRegionID)
72 buf.Write(derpBuf[:])
73
74 pub := ca.ReceiverPublicKey.Raw32()
75 buf.Write(pub[:])
76
77 priv := ca.OverlayPrivateKey.Raw32()
78 buf.Write(priv[:])
79
80 return base58.Encode(buf.Bytes())
81}
82
83func (ca *ClientAuth) Parse(authKey string) error {
84 if len(authKey) == 0 {

Callers 3

newWushFunction · 0.80
serveCmdFunction · 0.80
rsyncCmdFunction · 0.80

Calls 2

AddrMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected