MCPcopy Create free account
hub / github.com/encodeous/nylon / handlePublicKeyLine

Method handlePublicKeyLine

polyamide/device/uapi.go:277–305  ·  view source on GitHub ↗
(peer *ipcSetPeer, value string)

Source from the content-addressed store, hash-verified

275}
276
277func (device *Device) handlePublicKeyLine(peer *ipcSetPeer, value string) error {
278 // Load/create the peer we are configuring.
279 var publicKey NoisePublicKey
280 err := publicKey.FromHex(value)
281 if err != nil {
282 return ipcErrorf(ipc.IpcErrorInvalid, "failed to get peer by public key: %w", err)
283 }
284
285 // Ignore peer with the same public key as this device.
286 device.staticIdentity.RLock()
287 peer.dummy = device.staticIdentity.publicKey.Equals(publicKey)
288 device.staticIdentity.RUnlock()
289
290 if peer.dummy {
291 peer.Peer = &Peer{}
292 } else {
293 peer.Peer = device.LookupPeer(publicKey)
294 }
295
296 peer.created = peer.Peer == nil
297 if peer.created {
298 peer.Peer, err = device.NewPeer(publicKey)
299 if err != nil {
300 return ipcErrorf(ipc.IpcErrorInvalid, "failed to create new peer: %w", err)
301 }
302 device.Log.Verbosef("%v - UAPI: Created", peer.Peer)
303 }
304 return nil
305}
306
307func (device *Device) handlePeerLine(peer *ipcSetPeer, key, value string) error {
308 switch key {

Callers 1

IpcSetOperationMethod · 0.95

Implementers 4

NativeTunpolyamide/tun/tun_linux.go
netTunpolyamide/tun/netstack/tun.go
chTunpolyamide/tun/tuntest/tuntest.go
fakeTUNDeviceSizedpolyamide/device/device_test.go

Calls 5

FromHexMethod · 0.95
LookupPeerMethod · 0.95
NewPeerMethod · 0.95
ipcErrorfFunction · 0.85
EqualsMethod · 0.45

Tested by

no test coverage detected