Skip to content
quarry Artifact [fb5e5dc004]
Login

Artifact [fb5e5dc004]

Artifact fb5e5dc004a02f15d25a3522077d12e650c6bb8f93cb0fb06236740ad086c368:


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")
}