chinaip_json_test.go 725 B

1234567891011121314151617181920212223242526
  1. // +build json
  2. package rules_test
  3. import (
  4. "testing"
  5. . "github.com/v2ray/v2ray-core/app/router/rules"
  6. "github.com/v2ray/v2ray-core/testing/assert"
  7. )
  8. func TestChinaIPJson(t *testing.T) {
  9. assert := assert.On(t)
  10. rule := ParseRule([]byte(`{
  11. "type": "chinaip",
  12. "outboundTag": "x"
  13. }`))
  14. assert.String(rule.Tag).Equals("x")
  15. assert.Bool(rule.Apply(makeDestination("121.14.1.189"))).IsTrue() // sina.com.cn
  16. assert.Bool(rule.Apply(makeDestination("101.226.103.106"))).IsTrue() // qq.com
  17. assert.Bool(rule.Apply(makeDestination("115.239.210.36"))).IsTrue() // image.baidu.com
  18. assert.Bool(rule.Apply(makeDestination("120.135.126.1"))).IsTrue()
  19. assert.Bool(rule.Apply(makeDestination("8.8.8.8"))).IsFalse()
  20. }