19 lines
479 B
Go
19 lines
479 B
Go
|
package nebula
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"sync/atomic"
|
||
|
)
|
||
|
|
||
|
var deviceCounter = new(atomic.Uint64)
|
||
|
|
||
|
// GetDeviceName returns the network device name to use for a particular
|
||
|
// network. Each returns name is gauranteed to be unique for the lifetime of the
|
||
|
// process.
|
||
|
func GetDeviceName(networkID string) string {
|
||
|
i := deviceCounter.Add(1) - 1
|
||
|
// the returned string will be too long for linux, but it will get
|
||
|
// automatically truncated.
|
||
|
return fmt.Sprintf("isle%d-%s", i, networkID)
|
||
|
}
|