func (db *DB) GetLease(mac net.HardwareAddr) (*Lease, error) {
	l := &Lease{}
	return l, db.db.Transaction(func(tx *gorm.DB) error {
		return tx.First(l, "mac_address = ?", mac.String()).Error
	})
}
GetLease retrieves the lease if possible, otherwise returns error.
package db
import (
	"net"
	"time"
	"github.com/jinzhu/gorm"
)
type Lease struct {
	MACAddress    string `gorm:"primary_key"`
	IPAddress     string `gorm:"unique"`
	Dynamic       bool
	LeaseEnd      time.Time
	LeaseGraceEnd time.Time
	Persistent    bool
}
func (l *Lease) IP() net.IP {
	return net.ParseIP(l.IPAddress).To4()
}
func (l *Lease) HardwareAddr() (net.HardwareAddr, error) {
	return net.ParseMAC(l.MACAddress)
}