package chat
import (
"context"
"testing"
)
// CheckPublicHost applies the bridge dialer's own rule to a host the
// caller will hand to another program.
func TestCheckPublicHostRefusesWhatTheBridgeRefuses(t *testing.T) {
ctx := context.Background()
for _, bad := range []string{"127.0.0.1", "10.0.0.5", "192.168.1.1", "169.254.169.254", "::1", "0.0.0.0"} {
if err := CheckPublicHost(ctx, bad); err == nil {
t.Errorf("FAIL: %s passed", bad)
}
}
if err := CheckPublicHost(ctx, "93.184.216.34"); err != nil {
t.Errorf("FAIL: a public address refused: %v", err)
}
t.Log("ok")
}