chinasites_test.go 763 B

12345678910111213141516171819202122232425
  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. "github.com/v2ray/v2ray-core/testing/assert"
  7. )
  8. func makeDomainDestination(domain string) v2net.Destination {
  9. return v2net.TCPDestination(v2net.DomainAddress(domain), 80)
  10. }
  11. func TestChinaSites(t *testing.T) {
  12. assert := assert.On(t)
  13. rule := NewChinaSitesRule("tag")
  14. assert.Bool(rule.Apply(makeDomainDestination("v.qq.com"))).IsTrue()
  15. assert.Bool(rule.Apply(makeDomainDestination("www.163.com"))).IsTrue()
  16. assert.Bool(rule.Apply(makeDomainDestination("ngacn.cc"))).IsTrue()
  17. assert.Bool(rule.Apply(makeDomainDestination("12306.cn"))).IsTrue()
  18. assert.Bool(rule.Apply(makeDomainDestination("v2ray.com"))).IsFalse()
  19. }