Skip to content

Commit

Permalink
Unnest if clause
Browse files Browse the repository at this point in the history
  • Loading branch information
corny committed Jan 12, 2018
1 parent ee1e86d commit 71ce280
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,13 @@ func (client *Client) request(lease *Lease) error {
err = errors.New("expire value is zero")
break
}
if lease.Renew.IsZero() || lease.Rebind.IsZero() {
// support DHCP servers that do not send option 58 and 59
// this is using the Microsoft suggested defaults

remaining := lease.Expire.Sub(lease.Bound)

if lease.Renew.IsZero() {
lease.Renew = lease.Bound.Add(remaining / 2)
}
if lease.Rebind.IsZero() {
lease.Rebind = lease.Bound.Add(remaining / 1000 * 875)
}
// support DHCP servers that do not send option 58 and 59
// this is using the Microsoft suggested defaults
if lease.Renew.IsZero() {
lease.Renew = lease.Bound.Add(lease.Expire.Sub(lease.Bound) / 2)
}
if lease.Rebind.IsZero() {
lease.Rebind = lease.Bound.Add(lease.Expire.Sub(lease.Bound) / 1000 * 875)
}

client.Lease = lease
Expand Down

0 comments on commit 71ce280

Please sign in to comment.