Skip to content

Commit

Permalink
Add remaining options to Lease struct
Browse files Browse the repository at this point in the history
closes #7
  • Loading branch information
corny committed Apr 15, 2019
1 parent 12e5c52 commit 1be2917
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type Lease struct {
DomainName string
MTU uint16

// Other options
OtherOptions []Option

Bound time.Time
Renew time.Time
Rebind time.Time
Expand Down
2 changes: 2 additions & 0 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func newLease(packet *layers.DHCPv4) (msgType layers.DHCPMsgType, lease Lease) {
if option.Length == 4 {
lease.Rebind = lease.Bound.Add(time.Second * time.Duration(binary.BigEndian.Uint32(option.Data)))
}
default:
lease.OtherOptions = append(lease.OtherOptions, Option{option.Type, option.Data})
}
}
return
Expand Down
1 change: 1 addition & 0 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestParseResponse(t *testing.T) {
assert.Equal(net.IP{192, 168, 8, 1}, lease.DNS[0])
assert.Equal(net.IPMask{255, 255, 252, 0}, lease.Netmask)
assert.EqualValues(1406, lease.MTU)
assert.Len(lease.OtherOptions, 0)

// check timestamps
assert.False(lease.Bound.IsZero())
Expand Down

0 comments on commit 1be2917

Please sign in to comment.