config_json.go 529 B

1234567891011121314151617181920212223242526
  1. // +build json
  2. package inbound
  3. import (
  4. "encoding/json"
  5. "github.com/v2ray/v2ray-core/proxy/internal/config"
  6. "github.com/v2ray/v2ray-core/proxy/vmess"
  7. )
  8. func init() {
  9. config.RegisterInboundConnectionConfig("vmess",
  10. func(data []byte) (interface{}, error) {
  11. type JsonConfig struct {
  12. Users []*vmess.User `json:"clients"`
  13. }
  14. jsonConfig := new(JsonConfig)
  15. if err := json.Unmarshal(data, jsonConfig); err != nil {
  16. return nil, err
  17. }
  18. return &Config{
  19. AllowedUsers: jsonConfig.Users,
  20. }, nil
  21. })
  22. }