refactor if/else in network and packets packages

This commit is contained in:
Edznux 2018-10-23 05:32:51 +02:00
commit ed6d40f163
6 changed files with 34 additions and 25 deletions

View file

@ -38,11 +38,11 @@ func DHCP6For(what dhcp6.MessageType, to dhcp6.Packet, duid []byte) (err error,
}
var rawCID []byte
if raw, found := to.Options[dhcp6.OptionClientID]; !found || len(raw) < 1 {
raw, found := to.Options[dhcp6.OptionClientID]
if !found || len(raw) < 1 {
return ErrNoCID, p
} else {
rawCID = raw[0]
}
rawCID = raw[0]
p.Options.AddRaw(dhcp6.OptionClientID, rawCID)
p.Options.AddRaw(dhcp6.OptionServerID, duid)

View file

@ -233,9 +233,8 @@ func (q *Queue) Send(raw []byte) error {
if err := q.handle.WritePacketData(raw); err != nil {
q.TrackError()
return err
} else {
q.TrackSent(uint64(len(raw)))
}
q.TrackSent(uint64(len(raw)))
return nil
}