chinasites_test.go 853 B

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