mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
dpcpd: handle errors
This commit is contained in:
1 parent
a956e5811f
commit
02220387e9
5 files changed
+59
-39
No files matched your search
@@ -14,7 +14,15 @@ type Pool struct {
|
||||
|
||||
// NewPool returns a new dhcp ip pool.
|
||||
func NewPool(lease time.Duration, start, end net.IP) (*Pool, error) {
|
||||
if start == nil || end == nil {
|
||||
return nil, errors.New("start ip or end ip is wrong/nil, please check your config")
|
||||
}
|
||||
|
||||
s, e := ip2num(start.To4()), ip2num(end.To4())
|
||||
if e < s {
|
||||
return nil, errors.New("start ip larger than end ip")
|
||||
}
|
||||
|
||||
items := make([]*item, 0, e-s+1)
|
||||
for n := s; n <= e; n++ {
|
||||
items = append(items, &item{lease: lease, ip: num2ip(n)})
|
||||
|
||||
Reference in new issue
Block a user