vmess_test.go 949 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package conf_test
  2. import (
  3. "encoding/json"
  4. "testing"
  5. "v2ray.com/core/common/protocol"
  6. "v2ray.com/core/proxy/vmess/outbound"
  7. "v2ray.com/core/testing/assert"
  8. . "v2ray.com/core/tools/conf"
  9. )
  10. func TestConfigTargetParsing(t *testing.T) {
  11. assert := assert.On(t)
  12. rawJson := `{
  13. "vnext": [{
  14. "address": "127.0.0.1",
  15. "port": 80,
  16. "users": [
  17. {
  18. "id": "e641f5ad-9397-41e3-bf1a-e8740dfed019",
  19. "email": "love@v2ray.com",
  20. "level": 255
  21. }
  22. ]
  23. }]
  24. }`
  25. rawConfig := new(VMessOutboundConfig)
  26. err := json.Unmarshal([]byte(rawJson), &rawConfig)
  27. assert.Error(err).IsNil()
  28. ts, err := rawConfig.Build()
  29. assert.Error(err).IsNil()
  30. iConfig, err := ts.GetInstance()
  31. assert.Error(err).IsNil()
  32. config := iConfig.(*outbound.Config)
  33. specPB := config.Receiver[0]
  34. spec := protocol.NewServerSpecFromPB(*specPB)
  35. assert.Destination(spec.Destination()).EqualsString("tcp:127.0.0.1:80")
  36. }