mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-30 15:15:07 +03:00
Fix lint errors
This commit is contained in:
parent
166336a418
commit
8932ab0519
14 changed files with 44 additions and 54 deletions
|
@ -123,16 +123,12 @@ func (tun *TunAdapter) write() {
|
|||
continue // bad remote address/subnet
|
||||
}
|
||||
bs = buf[:TUN_OFFSET_BYTES+len(bs)]
|
||||
n, err = tun.iface.Write(bs, TUN_OFFSET_BYTES)
|
||||
if err != nil {
|
||||
if _, err = tun.iface.Write(bs, TUN_OFFSET_BYTES); err != nil {
|
||||
tun.Act(nil, func() {
|
||||
if !tun.isOpen {
|
||||
tun.log.Errorln("TUN iface write error:", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
if n != len(bs) {
|
||||
// TODO some kind of error reporting for a partial write
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func (k *keyStore) sendToAddress(addr address.Address, bs []byte) {
|
|||
if info := k.addrToInfo[addr]; info != nil {
|
||||
k.resetTimeout(info)
|
||||
k.mutex.Unlock()
|
||||
k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
_, _ = k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
} else {
|
||||
var buf *buffer
|
||||
if buf = k.addrBuffer[addr]; buf == nil {
|
||||
|
@ -79,7 +79,7 @@ func (k *keyStore) sendToSubnet(subnet address.Subnet, bs []byte) {
|
|||
if info := k.subnetToInfo[subnet]; info != nil {
|
||||
k.resetTimeout(info)
|
||||
k.mutex.Unlock()
|
||||
k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
_, _ = k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
} else {
|
||||
var buf *buffer
|
||||
if buf = k.subnetBuffer[subnet]; buf == nil {
|
||||
|
@ -132,13 +132,13 @@ func (k *keyStore) update(key ed25519.PublicKey) *keyInfo {
|
|||
k.mutex.Unlock()
|
||||
if buf := k.addrBuffer[info.address]; buf != nil {
|
||||
for _, bs := range buf.packets {
|
||||
k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
_, _ = k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
}
|
||||
delete(k.addrBuffer, info.address)
|
||||
}
|
||||
if buf := k.subnetBuffer[info.subnet]; buf != nil {
|
||||
for _, bs := range buf.packets {
|
||||
k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
_, _ = k.tun.core.WriteTo(bs, iwt.Addr(info.key[:]))
|
||||
}
|
||||
delete(k.subnetBuffer, info.subnet)
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ func (m *nodeinfo) _sendReq(key keyArray, callback func(nodeinfo NodeInfoPayload
|
|||
if callback != nil {
|
||||
m._addCallback(key, callback)
|
||||
}
|
||||
m.proto.tun.core.WriteTo([]byte{typeSessionProto, typeProtoNodeInfoRequest}, iwt.Addr(key[:]))
|
||||
_, _ = m.proto.tun.core.WriteTo([]byte{typeSessionProto, typeProtoNodeInfoRequest}, iwt.Addr(key[:]))
|
||||
}
|
||||
|
||||
func (m *nodeinfo) handleReq(from phony.Actor, key keyArray) {
|
||||
|
@ -146,7 +146,7 @@ func (m *nodeinfo) handleRes(from phony.Actor, key keyArray, info NodeInfoPayloa
|
|||
|
||||
func (m *nodeinfo) _sendRes(key keyArray) {
|
||||
bs := append([]byte{typeSessionProto, typeProtoNodeInfoResponse}, m._getNodeInfo()...)
|
||||
m.proto.tun.core.WriteTo(bs, iwt.Addr(key[:]))
|
||||
_, _ = m.proto.tun.core.WriteTo(bs, iwt.Addr(key[:]))
|
||||
}
|
||||
|
||||
// Admin socket stuff
|
||||
|
|
|
@ -209,7 +209,7 @@ func (p *protoHandler) _handleGetDHTResponse(key keyArray, bs []byte) {
|
|||
|
||||
func (p *protoHandler) _sendDebug(key keyArray, dType uint8, data []byte) {
|
||||
bs := append([]byte{typeSessionProto, typeProtoDebug, dType}, data...)
|
||||
p.tun.core.WriteTo(bs, iwt.Addr(key[:]))
|
||||
_, _ = p.tun.core.WriteTo(bs, iwt.Addr(key[:]))
|
||||
}
|
||||
|
||||
// Admin socket stuff
|
||||
|
|
|
@ -221,13 +221,13 @@ func (tun *TunAdapter) oobHandler(fromKey, toKey ed25519.PublicKey, data []byte)
|
|||
func (tun *TunAdapter) sendKeyLookup(partial ed25519.PublicKey) {
|
||||
sig := ed25519.Sign(tun.core.PrivateKey(), partial[:])
|
||||
bs := append([]byte{typeKeyLookup}, sig...)
|
||||
tun.core.SendOutOfBand(partial, bs)
|
||||
_ = tun.core.SendOutOfBand(partial, bs)
|
||||
}
|
||||
|
||||
func (tun *TunAdapter) sendKeyResponse(dest ed25519.PublicKey) {
|
||||
sig := ed25519.Sign(tun.core.PrivateKey(), dest[:])
|
||||
bs := append([]byte{typeKeyResponse}, sig...)
|
||||
tun.core.SendOutOfBand(dest, bs)
|
||||
_ = tun.core.SendOutOfBand(dest, bs)
|
||||
}
|
||||
|
||||
func (tun *TunAdapter) maxSessionMTU() uint64 {
|
||||
|
|
|
@ -40,26 +40,29 @@ const (
|
|||
darwin_ND6_INFINITE_LIFETIME = 0xFFFFFFFF // netinet6/nd6.h
|
||||
)
|
||||
|
||||
// nolint:structcheck
|
||||
type in6_addrlifetime struct {
|
||||
ia6t_expire float64
|
||||
ia6t_preferred float64
|
||||
ia6t_expire float64 // nolint:unused
|
||||
ia6t_preferred float64 // nolint:unused
|
||||
ia6t_vltime uint32
|
||||
ia6t_pltime uint32
|
||||
}
|
||||
|
||||
// nolint:structcheck
|
||||
type sockaddr_in6 struct {
|
||||
sin6_len uint8
|
||||
sin6_family uint8
|
||||
sin6_port uint8
|
||||
sin6_flowinfo uint32
|
||||
sin6_port uint8 // nolint:unused
|
||||
sin6_flowinfo uint32 // nolint:unused
|
||||
sin6_addr [8]uint16
|
||||
sin6_scope_id uint32
|
||||
sin6_scope_id uint32 // nolint:unused
|
||||
}
|
||||
|
||||
// nolint:structcheck
|
||||
type in6_aliasreq struct {
|
||||
ifra_name [16]byte
|
||||
ifra_addr sockaddr_in6
|
||||
ifra_dstaddr sockaddr_in6
|
||||
ifra_dstaddr sockaddr_in6 // nolint:unused
|
||||
ifra_prefixmask sockaddr_in6
|
||||
ifra_flags uint32
|
||||
ifra_lifetime in6_addrlifetime
|
||||
|
|
|
@ -2,14 +2,14 @@ package tuntap
|
|||
|
||||
// Out-of-band packet types
|
||||
const (
|
||||
typeKeyDummy = iota
|
||||
typeKeyDummy = iota // nolint:deadcode,varcheck
|
||||
typeKeyLookup
|
||||
typeKeyResponse
|
||||
)
|
||||
|
||||
// In-band packet types
|
||||
const (
|
||||
typeSessionDummy = iota
|
||||
typeSessionDummy = iota // nolint:deadcode,varcheck
|
||||
typeSessionTraffic
|
||||
typeSessionProto
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue