lib/nat: Add a nat package and service to track mappings on multiple IGDs

This commit is contained in:
Audrius Butkevicius
2016-04-10 19:36:38 +00:00
committed by Jakob Borg
parent f3ac421266
commit 19b4f3bfb4
20 changed files with 661 additions and 236 deletions

View File

@@ -6,26 +6,7 @@
package util
import (
"runtime"
"sync"
"testing"
)
var predictableRandomTest sync.Once
func TestPredictableRandom(t *testing.T) {
if runtime.GOARCH != "amd64" {
t.Skip("Test only for 64 bit platforms; but if it works there, it should work on 32 bit")
}
predictableRandomTest.Do(func() {
// predictable random sequence is predictable
e := int64(3440579354231278675)
if v := int64(PredictableRandom.Int()); v != e {
t.Errorf("Unexpected random value %d != %d", v, e)
}
})
}
import "testing"
func TestSeedFromBytes(t *testing.T) {
// should always return the same seed for the same bytes