chinasites_test.go 810 B

1234567891011121314151617181920212223242526
  1. package rules_test
  2. import (
  3. "testing"
  4. . "github.com/v2ray/v2ray-core/app/router/rules"
  5. v2net "github.com/v2ray/v2ray-core/common/net"
  6. v2testing "github.com/v2ray/v2ray-core/testing"
  7. "github.com/v2ray/v2ray-core/testing/assert"
  8. )
  9. func makeDomainDestination(domain string) v2net.Destination {
  10. return v2net.TCPDestination(v2net.DomainAddress(domain), 80)
  11. }
  12. func TestChinaSites(t *testing.T) {
  13. v2testing.Current(t)
  14. rule := NewChinaSitesRule("tag")
  15. assert.Bool(rule.Apply(makeDomainDestination("v.qq.com"))).IsTrue()
  16. assert.Bool(rule.Apply(makeDomainDestination("www.163.com"))).IsTrue()
  17. assert.Bool(rule.Apply(makeDomainDestination("ngacn.cc"))).IsTrue()
  18. assert.Bool(rule.Apply(makeDomainDestination("12306.cn"))).IsTrue()
  19. assert.Bool(rule.Apply(makeDomainDestination("v2ray.com"))).IsFalse()
  20. }