fixing formatting

This commit is contained in:
Mark Puha 2023-09-14 07:21:51 +02:00
parent ba6bb0bb8f
commit 9329840b5a
6 changed files with 63 additions and 276 deletions

View file

@ -160,10 +160,7 @@ func (device *Device) changeState(want deviceState) (err error) {
old := device.deviceState()
if old == deviceStateClosed {
// once closed, always closed
device.log.Verbosef(
"Interface closed, ignored requested state %s",
want,
)
device.log.Verbosef("Interface closed, ignored requested state %s", want)
return nil
}
switch want {
@ -184,11 +181,7 @@ func (device *Device) changeState(want deviceState) (err error) {
}
}
device.log.Verbosef(
"Interface state was %s, requested %s, now %s",
old,
want,
device.deviceState(),
)
"Interface state was %s, requested %s, now %s", old, want, device.deviceState())
return
}
@ -293,9 +286,7 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
expiredPeers := make([]*Peer, 0, len(device.peers.keyMap))
for _, peer := range device.peers.keyMap {
handshake := &peer.handshake
handshake.precomputedStaticStatic, _ = device.staticIdentity.privateKey.sharedSecret(
handshake.remoteStatic,
)
handshake.precomputedStaticStatic, _ = device.staticIdentity.privateKey.sharedSecret(handshake.remoteStatic)
expiredPeers = append(expiredPeers, peer)
}
@ -439,9 +430,7 @@ func (device *Device) SendKeepalivesToPeersWithCurrentKeypair() {
device.peers.RLock()
for _, peer := range device.peers.keyMap {
peer.keypairs.RLock()
sendKeepalive := peer.keypairs.current != nil &&
!peer.keypairs.current.created.Add(RejectAfterTime).
Before(time.Now())
sendKeepalive := peer.keypairs.current != nil && !peer.keypairs.current.created.Add(RejectAfterTime).Before(time.Now())
peer.keypairs.RUnlock()
if sendKeepalive {
peer.SendKeepalive()
@ -555,12 +544,8 @@ func (device *Device) BindUpdate() error {
// start receiving routines
device.net.stopping.Add(len(recvFns))
device.queue.decryption.wg.Add(
len(recvFns),
) // each RoutineReceiveIncoming goroutine writes to device.queue.decryption
device.queue.handshake.wg.Add(
len(recvFns),
) // each RoutineReceiveIncoming goroutine writes to device.queue.handshake
device.queue.decryption.wg.Add(len(recvFns)) // each RoutineReceiveIncoming goroutine writes to device.queue.decryption
device.queue.handshake.wg.Add(len(recvFns)) // each RoutineReceiveIncoming goroutine writes to device.queue.handshake
batchSize := netc.bind.BatchSize()
for _, fn := range recvFns {
go device.RoutineReceiveIncoming(batchSize, fn)

View file

@ -237,11 +237,7 @@ func genTestPair(
if _, ok := tb.(*testing.B); ok && !testing.Verbose() {
level = LogLevelError
}
p.dev = NewDevice(
p.tun.TUN(),
binds[i],
NewLogger(level, fmt.Sprintf("dev%d: ", i)),
)
p.dev = NewDevice(p.tun.TUN(),binds[i],NewLogger(level, fmt.Sprintf("dev%d: ", i)))
if err := p.dev.IpcSet(cfg[i]); err != nil {
tb.Errorf("failed to configure device %d: %v", i, err)
p.dev.Close()
@ -298,12 +294,7 @@ func TestUpDown(t *testing.T) {
pair := genTestPair(t, false, false)
for i := range pair {
for k := range pair[i].dev.peers.keyMap {
pair[i].dev.IpcSet(
fmt.Sprintf(
"public_key=%s\npersistent_keepalive_interval=1\n",
hex.EncodeToString(k[:]),
),
)
pair[i].dev.IpcSet(fmt.Sprintf("public_key=%s\npersistent_keepalive_interval=1\n",hex.EncodeToString(k[:])))
}
}
var wg sync.WaitGroup
@ -315,19 +306,11 @@ func TestUpDown(t *testing.T) {
if err := d.Up(); err != nil {
t.Errorf("failed up bring up device: %v", err)
}
time.Sleep(
time.Duration(
rand.Intn(int(time.Nanosecond * (0x10000 - 1))),
),
)
time.Sleep(time.Duration(rand.Intn(int(time.Nanosecond * (0x10000 - 1)))))
if err := d.Down(); err != nil {
t.Errorf("failed to bring down device: %v", err)
}
time.Sleep(
time.Duration(
rand.Intn(int(time.Nanosecond * (0x10000 - 1))),
),
)
time.Sleep(time.Duration(rand.Intn(int(time.Nanosecond * (0x10000 - 1)))))
}
}(pair[i].dev)
}
@ -393,14 +376,8 @@ func TestConcurrencySafety(t *testing.T) {
// Change private keys concurrently with tunnel use.
t.Run("privateKey", func(t *testing.T) {
bad := uapiCfg(
"private_key",
"7777777777777777777777777777777777777777777777777777777777777777",
)
good := uapiCfg(
"private_key",
hex.EncodeToString(pair[0].dev.staticIdentity.privateKey[:]),
)
bad := uapiCfg("private_key", "7777777777777777777777777777777777777777777777777777777777777777")
good := uapiCfg("private_key", hex.EncodeToString(pair[0].dev.staticIdentity.privateKey[:]))
// Set iters to a large number like 1000 to flush out data races quickly.
// Don't leave it large. That can cause logical races
// in which the handshake is interleaved with key changes
@ -520,11 +497,7 @@ func goroutineLeakCheck(t *testing.T) {
endGoroutines, endStacks := goroutines()
t.Logf("starting stacks:\n%s\n", startStacks)
t.Logf("ending stacks:\n%s\n", endStacks)
t.Fatalf(
"expected %d goroutines, got %d, leak?",
startGoroutines,
endGoroutines,
)
t.Fatalf("expected %d goroutines, got %d, leak?", startGoroutines, endGoroutines)
})
}
@ -540,24 +513,11 @@ func (b *fakeBindSized) Open(
func (b *fakeBindSized) Close() error { return nil }
func (b *fakeBindSized) SetMark(
mark uint32,
) error {
return nil
}
func (b *fakeBindSized) SetMark(mark uint32) error {return nil }
func (b *fakeBindSized) Send(
bufs [][]byte,
ep conn.Endpoint,
) error {
return nil
}
func (b *fakeBindSized) Send(bufs [][]byte, ep conn.Endpoint) error { return nil }
func (b *fakeBindSized) ParseEndpoint(
s string,
) (conn.Endpoint, error) {
return nil, nil
}
func (b *fakeBindSized) ParseEndpoint(s string) (conn.Endpoint, error) { return nil, nil }
func (b *fakeBindSized) BatchSize() int { return b.size }
@ -567,20 +527,9 @@ type fakeTUNDeviceSized struct {
func (t *fakeTUNDeviceSized) File() *os.File { return nil }
func (t *fakeTUNDeviceSized) Read(
bufs [][]byte,
sizes []int,
offset int,
) (n int, err error) {
return 0, nil
}
func (t *fakeTUNDeviceSized) Read(bufs [][]byte, sizes []int, offset int) (n int, err error) { return 0, nil }
func (t *fakeTUNDeviceSized) Write(
bufs [][]byte,
offset int,
) (int, error) {
return 0, nil
}
func (t *fakeTUNDeviceSized) Write(bufs [][]byte, offset int) (int, error) { return 0, nil }
func (t *fakeTUNDeviceSized) MTU() (int, error) { return 0, nil }

View file

@ -178,9 +178,7 @@ func init() {
mixHash(&InitialHash, &InitialChainKey, []byte(WGIdentifier))
}
func (device *Device) CreateMessageInitiation(
peer *Peer,
) (*MessageInitiation, error) {
func (device *Device) CreateMessageInitiation(peer *Peer) (*MessageInitiation, error) {
device.staticIdentity.RLock()
defer device.staticIdentity.RUnlock()
@ -222,12 +220,7 @@ func (device *Device) CreateMessageInitiation(
ss[:],
)
aead, _ := chacha20poly1305.New(key[:])
aead.Seal(
msg.Static[:0],
ZeroNonce[:],
device.staticIdentity.publicKey[:],
handshake.hash[:],
)
aead.Seal(msg.Static[:0], ZeroNonce[:], device.staticIdentity.publicKey[:], handshake.hash[:])
handshake.mixHash(msg.Static[:])
// encrypt timestamp
@ -328,23 +321,14 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer {
// protect against replay & flood
replay := !timestamp.After(handshake.lastTimestamp)
flood := time.Since(
handshake.lastInitiationConsumption,
) <= HandshakeInitationRate
flood := time.Since(handshake.lastInitiationConsumption) <= HandshakeInitationRate
handshake.mutex.RUnlock()
if replay {
device.log.Verbosef(
"%v - ConsumeMessageInitiation: handshake replay @ %v",
peer,
timestamp,
)
device.log.Verbosef("%v - ConsumeMessageInitiation: handshake replay @ %v", peer, timestamp)
return nil
}
if flood {
device.log.Verbosef(
"%v - ConsumeMessageInitiation: handshake flood",
peer,
)
device.log.Verbosef("%v - ConsumeMessageInitiation: handshake flood", peer)
return nil
}
@ -373,9 +357,7 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer {
return peer
}
func (device *Device) CreateMessageResponse(
peer *Peer,
) (*MessageResponse, error) {
func (device *Device) CreateMessageResponse(peer *Peer) (*MessageResponse, error) {
handshake := &peer.handshake
handshake.mutex.Lock()
defer handshake.mutex.Unlock()
@ -388,10 +370,7 @@ func (device *Device) CreateMessageResponse(
var err error
device.indexTable.Delete(handshake.localIndex)
handshake.localIndex, err = device.indexTable.NewIndexForHandshake(
peer,
handshake,
)
handshake.localIndex, err = device.indexTable.NewIndexForHandshake(peer, handshake)
if err != nil {
return nil, err
}
@ -586,9 +565,7 @@ func (peer *Peer) BeginSymmetricSession() error {
// zero handshake
setZero(handshake.chainKey[:])
setZero(
handshake.hash[:],
) // Doesn't necessarily need to be zeroed. Could be used for something interesting down the line.
setZero(handshake.hash[:]) // Doesn't necessarily need to be zeroed. Could be used for something interesting down the line.
setZero(handshake.localEphemeral[:])
peer.handshake.state = handshakeZeroed

View file

@ -55,10 +55,7 @@ func (peer *Peer) keepKeyFreshReceiving() {
return
}
keypair := peer.keypairs.Current()
if keypair != nil && keypair.isInitiator &&
time.Since(
keypair.created,
) > (RejectAfterTime-KeepaliveTimeout-RekeyTimeout) {
if keypair != nil && keypair.isInitiator && time.Since(keypair.created) > (RejectAfterTime-KeepaliveTimeout-RekeyTimeout) {
peer.timers.sentLastMinuteHandshake.Store(true)
peer.SendHandshakeInitiation(false)
}
@ -115,11 +112,7 @@ func (device *Device) RoutineReceiveIncoming(
if errors.Is(err, net.ErrClosed) {
return
}
device.log.Verbosef(
"Failed to receive %s packet: %v",
recvName,
err,
)
device.log.Verbosef("Failed to receive %s packet: %v", recvName, err)
if neterr, ok := err.(net.Error); ok && !neterr.Temporary() {
return
}
@ -351,10 +344,7 @@ func (device *Device) RoutineHandshake(id int) {
// verify MAC2 field
if !device.cookieChecker.CheckMAC2(
elem.packet,
elem.endpoint.DstToBytes(),
) {
if !device.cookieChecker.CheckMAC2(elem.packet, elem.endpoint.DstToBytes()) {
device.SendHandshakeCookie(&elem)
goto skip
}
@ -387,10 +377,7 @@ func (device *Device) RoutineHandshake(id int) {
// consume initiation
peer := device.ConsumeMessageInitiation(&msg)
if peer == nil {
device.log.Verbosef(
"Received invalid initiation message from %s",
elem.endpoint.DstToString(),
)
device.log.Verbosef("Received invalid initiation message from %s", elem.endpoint.DstToString())
goto skip
}
@ -423,10 +410,7 @@ func (device *Device) RoutineHandshake(id int) {
peer := device.ConsumeMessageResponse(&msg)
if peer == nil {
device.log.Verbosef(
"Received invalid response message from %s",
elem.endpoint.DstToString(),
)
device.log.Verbosef("Received invalid response message from %s", elem.endpoint.DstToString())
goto skip
}
@ -446,11 +430,7 @@ func (device *Device) RoutineHandshake(id int) {
err = peer.BeginSymmetricSession()
if err != nil {
device.log.Errorf(
"%v - Failed to derive keypair: %v",
peer,
err,
)
device.log.Errorf("%v - Failed to derive keypair: %v", peer, err)
goto skip
}
@ -485,10 +465,7 @@ func (peer *Peer) RoutineSequentialReceiver(maxBatchSize int) {
continue
}
if !elem.keypair.replayFilter.ValidateCounter(
elem.counter,
RejectAfterMessages,
) {
if !elem.keypair.replayFilter.ValidateCounter(elem.counter, RejectAfterMessages) {
continue
}
@ -515,17 +492,13 @@ func (peer *Peer) RoutineSequentialReceiver(maxBatchSize int) {
}
field := elem.packet[IPv4offsetTotalLength : IPv4offsetTotalLength+2]
length := binary.BigEndian.Uint16(field)
if int(length) > len(elem.packet) ||
int(length) < ipv4.HeaderLen {
if int(length) > len(elem.packet) || int(length) < ipv4.HeaderLen {
continue
}
elem.packet = elem.packet[:length]
src := elem.packet[IPv4offsetSrc : IPv4offsetSrc+net.IPv4len]
if device.allowedips.Lookup(src) != peer {
device.log.Verbosef(
"IPv4 packet with disallowed source address from %v",
peer,
)
device.log.Verbosef("IPv4 packet with disallowed source address from %v", peer)
continue
}
@ -542,10 +515,7 @@ func (peer *Peer) RoutineSequentialReceiver(maxBatchSize int) {
elem.packet = elem.packet[:length]
src := elem.packet[IPv6offsetSrc : IPv6offsetSrc+net.IPv6len]
if device.allowedips.Lookup(src) != peer {
device.log.Verbosef(
"IPv6 packet with disallowed source address from %v",
peer,
)
device.log.Verbosef("IPv6 packet with disallowed source address from %v", peer)
continue
}
@ -563,15 +533,9 @@ func (peer *Peer) RoutineSequentialReceiver(maxBatchSize int) {
)
}
if len(bufs) > 0 {
_, err := device.tun.device.Write(
bufs,
MessageTransportOffsetContent,
)
_, err := device.tun.device.Write(bufs, MessageTransportOffsetContent)
if err != nil && !device.isClosed() {
device.log.Errorf(
"Failed to write packets to TUN device: %v",
err,
)
device.log.Errorf("Failed to write packets to TUN device: %v", err)
}
}
for _, elem := range *elems {

View file

@ -117,11 +117,7 @@ func (peer *Peer) SendHandshakeInitiation(isRetry bool) error {
msg, err := peer.device.CreateMessageInitiation(peer)
if err != nil {
peer.device.log.Errorf(
"%v - Failed to create initiation message: %v",
peer,
err,
)
peer.device.log.Errorf("%v - Failed to create initiation message: %v", peer, err)
return err
}
var sendBuffer [][]byte
@ -163,11 +159,7 @@ func (peer *Peer) SendHandshakeInitiation(isRetry bool) error {
err = peer.SendBuffers(sendBuffer)
if err != nil {
peer.device.log.Errorf(
"%v - Failed to send handshake initiation: %v",
peer,
err,
)
peer.device.log.Errorf("%v - Failed to send handshake initiation: %v", peer, err)
}
peer.timersHandshakeInitiated()
@ -183,11 +175,7 @@ func (peer *Peer) SendHandshakeResponse() error {
response, err := peer.device.CreateMessageResponse(peer)
if err != nil {
peer.device.log.Errorf(
"%v - Failed to create response message: %v",
peer,
err,
)
peer.device.log.Errorf("%v - Failed to create response message: %v", peer, err)
return err
}
var junkedHeader []byte
@ -227,11 +215,7 @@ func (peer *Peer) SendHandshakeResponse() error {
// TODO: allocation could be avoided
err = peer.SendBuffers([][]byte{junkedHeader})
if err != nil {
peer.device.log.Errorf(
"%v - Failed to send handshake response: %v",
peer,
err,
)
peer.device.log.Errorf("%v - Failed to send handshake response: %v", peer, err)
}
return err
}
@ -239,10 +223,7 @@ func (peer *Peer) SendHandshakeResponse() error {
func (device *Device) SendHandshakeCookie(
initiatingElem *QueueHandshakeElement,
) error {
device.log.Verbosef(
"Sending cookie response for denied handshake message for %v",
initiatingElem.endpoint.DstToString(),
)
device.log.Verbosef("Sending cookie response for denied handshake message for %v", initiatingElem.endpoint.DstToString())
sender := binary.LittleEndian.Uint32(initiatingElem.packet[4:8])
reply, err := device.cookieChecker.CreateReply(
@ -269,8 +250,7 @@ func (peer *Peer) keepKeyFreshSending() {
return
}
nonce := keypair.sendNonce.Load()
if nonce > RekeyAfterMessages ||
(keypair.isInitiator && time.Since(keypair.created) > RekeyAfterTime) {
if nonce > RekeyAfterMessages || (keypair.isInitiator && time.Since(keypair.created) > RekeyAfterTime) {
peer.SendHandshakeInitiation(false)
}
}
@ -373,18 +353,12 @@ func (device *Device) RoutineReadFromTUN() {
// TODO: record stat for this
// This will happen if MSS is surprisingly small (< 576)
// coincident with reasonably high throughput.
device.log.Verbosef(
"Dropped some packets from multi-segment read: %v",
readErr,
)
device.log.Verbosef("Dropped some packets from multi-segment read: %v", readErr)
continue
}
if !device.isClosed() {
if !errors.Is(readErr, os.ErrClosed) {
device.log.Errorf(
"Failed to read packet from TUN device: %v",
readErr,
)
device.log.Errorf("Failed to read packet from TUN device: %v", readErr)
}
go device.Close()
}
@ -419,8 +393,7 @@ top:
}
keypair := peer.keypairs.Current()
if keypair == nil || keypair.sendNonce.Load() >= RejectAfterMessages ||
time.Since(keypair.created) >= RejectAfterTime {
if keypair == nil || keypair.sendNonce.Load() >= RejectAfterMessages || time.Since(keypair.created) >= RejectAfterTime {
peer.SendHandshakeInitiation(false)
return
}
@ -451,9 +424,7 @@ top:
*elems = (*elems)[:i]
if elemsOOO != nil {
peer.StagePackets(
elemsOOO,
) // XXX: Out of order, but we can't front-load go chans
peer.StagePackets(elemsOOO) // XXX: Out of order, but we can't front-load go chans
}
if len(*elems) == 0 {
@ -573,12 +544,7 @@ func (device *Device) RoutineEncryption(id int) {
// encrypt content and release to consumer
binary.LittleEndian.PutUint64(nonce[4:], elem.nonce)
elem.packet = elem.keypair.send.Seal(
header,
nonce[:],
elem.packet,
nil,
)
elem.packet = elem.keypair.send.Seal(header, nonce[:], elem.packet, nil)
elem.Unlock()
}
}
@ -586,10 +552,7 @@ func (device *Device) RoutineEncryption(id int) {
func (peer *Peer) RoutineSequentialSender(maxBatchSize int) {
device := peer.device
defer func() {
defer device.log.Verbosef(
"%v - Routine: sequential sender - stopped",
peer,
)
defer device.log.Verbosef("%v - Routine: sequential sender - stopped", peer)
peer.stopping.Done()
}()
device.log.Verbosef("%v - Routine: sequential sender - started", peer)

View file

@ -149,10 +149,7 @@ func (device *Device) IpcGetOperation(w io.Writer) error {
sendf("last_handshake_time_nsec=%d", nano)
sendf("tx_bytes=%d", peer.txBytes.Load())
sendf("rx_bytes=%d", peer.rxBytes.Load())
sendf(
"persistent_keepalive_interval=%d",
peer.persistentKeepaliveInterval.Load(),
)
sendf("persistent_keepalive_interval=%d", peer.persistentKeepaliveInterval.Load())
device.allowedips.EntriesForPeer(
peer,
@ -387,11 +384,7 @@ func (device *Device) handlePublicKeyLine(
var publicKey NoisePublicKey
err := publicKey.FromHex(value)
if err != nil {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to get peer by public key: %w",
err,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to get peer by public key: %w", err)
}
// Ignore peer with the same public key as this device.
@ -409,11 +402,7 @@ func (device *Device) handlePublicKeyLine(
if peer.created {
peer.Peer, err = device.NewPeer(publicKey)
if err != nil {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to create new peer: %w",
err,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to create new peer: %w", err)
}
device.log.Verbosef("%v - UAPI: Created", peer.Peer)
}
@ -428,11 +417,7 @@ func (device *Device) handlePeerLine(
case "update_only":
// allow disabling of creation
if value != "true" {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to set update only, invalid value: %v",
value,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set update only, invalid value: %v", value)
}
if peer.created && !peer.dummy {
device.RemovePeer(peer.handshake.remoteStatic)
@ -443,11 +428,7 @@ func (device *Device) handlePeerLine(
case "remove":
// remove currently selected peer from device
if value != "true" {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to set remove, invalid value: %v",
value,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set remove, invalid value: %v", value)
}
if !peer.dummy {
device.log.Verbosef("%v - UAPI: Removing", peer.Peer)
@ -464,41 +445,25 @@ func (device *Device) handlePeerLine(
peer.handshake.mutex.Unlock()
if err != nil {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to set preshared key: %w",
err,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set preshared key: %w", err)
}
case "endpoint":
device.log.Verbosef("%v - UAPI: Updating endpoint", peer.Peer)
endpoint, err := device.net.bind.ParseEndpoint(value)
if err != nil {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to set endpoint %v: %w",
value,
err,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set endpoint %v: %w", value, err)
}
peer.Lock()
defer peer.Unlock()
peer.endpoint = endpoint
case "persistent_keepalive_interval":
device.log.Verbosef(
"%v - UAPI: Updating persistent keepalive interval",
peer.Peer,
)
device.log.Verbosef("%v - UAPI: Updating persistent keepalive interval", peer.Peer)
secs, err := strconv.ParseUint(value, 10, 16)
if err != nil {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to set persistent keepalive interval: %w",
err,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set persistent keepalive interval: %w", err)
}
old := peer.persistentKeepaliveInterval.Swap(uint32(secs))
@ -509,11 +474,7 @@ func (device *Device) handlePeerLine(
case "replace_allowed_ips":
device.log.Verbosef("%v - UAPI: Removing all allowedips", peer.Peer)
if value != "true" {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to replace allowedips, invalid value: %v",
value,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to replace allowedips, invalid value: %v", value)
}
if peer.dummy {
return nil
@ -524,11 +485,7 @@ func (device *Device) handlePeerLine(
device.log.Verbosef("%v - UAPI: Adding allowedip", peer.Peer)
prefix, err := netip.ParsePrefix(value)
if err != nil {
return ipcErrorf(
ipc.IpcErrorInvalid,
"failed to set allowed ip: %w",
err,
)
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set allowed ip: %w", err)
}
if peer.dummy {
return nil
@ -537,11 +494,7 @@ func (device *Device) handlePeerLine(
case "protocol_version":
if value != "1" {
return ipcErrorf(
ipc.IpcErrorInvalid,
"invalid protocol version: %v",
value,
)
return ipcErrorf(ipc.IpcErrorInvalid, "invalid protocol version: %v", value)
}
default:
@ -589,11 +542,7 @@ func (device *Device) IpcHandle(socket net.Conn) {
return
}
if nextByte != '\n' {
err = ipcErrorf(
ipc.IpcErrorInvalid,
"trailing character in UAPI get: %q",
nextByte,
)
err = ipcErrorf(ipc.IpcErrorInvalid, "trailing character in UAPI get: %q", nextByte)
break
}
err = device.IpcGetOperation(buffered.Writer)