Skip to content

Commit

Permalink
Skip assigning/claiming the first .0 of a CIDR/24
Browse files Browse the repository at this point in the history
  • Loading branch information
skx committed Nov 26, 2018
1 parent e96ee74 commit 0be01c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd_server.go
Expand Up @@ -152,6 +152,7 @@ func (p *serverCmd) pickIP(name string, remote string) (string, error) {
// If that worked, and the IP is free then use it.
//
if fixed != "" && p.assigned[fixed] == nil {

p.assigned[fixed] = &connection{name: name, localIP: fixed, remoteIP: remote}

p.assignedMutex.Unlock()
Expand All @@ -165,6 +166,11 @@ func (p *serverCmd) pickIP(name string, remote string) (string, error) {

s := ip.String()

// Skip the first IP.
if strings.HasSuffix(s, ".0") {
continue
}

if p.assigned[s] == nil {
p.assigned[s] = &connection{name: name, localIP: s, remoteIP: remote}
p.assignedMutex.Unlock()
Expand Down Expand Up @@ -243,6 +249,10 @@ func (p *serverCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}

s := ip.String()

if strings.HasSuffix(s, ".0") {
continue
}

p.assigned[s] = nil

//
Expand Down

0 comments on commit 0be01c1

Please sign in to comment.