refactor: create common package for holding STUN input (#631)
We want stunreachability to use the same STUN servers used by snowflake, so let's start by making a common package holding the servers. Let's also use this new package in Snowflake. We're currently not using this package in stunreachability, but I am going to apply this as a subsequent diff. Reference issue: https://github.com/ooni/probe/issues/1814. This issue is a bit complex to address in a single PR, so we are going to proceed incremntally. This diff was extracted from https://github.com/ooni/probe-cli/pull/539.
This commit is contained in:
parent
cba72d1ca3
commit
13414e0abc
3 changed files with 77 additions and 14 deletions
31
internal/stuninput/stuninput_test.go
Normal file
31
internal/stuninput/stuninput_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package stuninput
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAsSnowflakeInput(t *testing.T) {
|
||||
outputs := AsSnowflakeInput()
|
||||
if len(outputs) != len(inputs) {
|
||||
t.Fatal("unexpected number of entries")
|
||||
}
|
||||
for idx := 0; idx < len(inputs); idx++ {
|
||||
output := outputs[idx]
|
||||
input := "stun:" + inputs[idx]
|
||||
if input != output {
|
||||
t.Fatal("mismatch")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAsStunReachabilityInput(t *testing.T) {
|
||||
outputs := AsnStunReachabilityInput()
|
||||
if len(outputs) != len(inputs) {
|
||||
t.Fatal("unexpected number of entries")
|
||||
}
|
||||
for idx := 0; idx < len(inputs); idx++ {
|
||||
output := outputs[idx]
|
||||
input := "stun://" + inputs[idx]
|
||||
if input != output {
|
||||
t.Fatal("mismatch")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue