config.go 890 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package vmess
  2. import (
  3. "encoding/json"
  4. "github.com/v2ray/v2ray-core"
  5. v2net "github.com/v2ray/v2ray-core/net"
  6. )
  7. type VMessInboundConfig struct {
  8. AllowedClients []core.VUser `json:"clients"`
  9. }
  10. func loadInboundConfig(rawConfig []byte) (VMessInboundConfig, error) {
  11. config := VMessInboundConfig{}
  12. err := json.Unmarshal(rawConfig, &config)
  13. return config, err
  14. }
  15. type VNextConfig struct {
  16. Address string `json:"address"`
  17. Port uint16 `json:"port"`
  18. Users []core.VUser `json:"users"`
  19. }
  20. func (config VNextConfig) ToVNextServer() VNextServer {
  21. return VNextServer{
  22. v2net.DomainAddress(config.Address, config.Port),
  23. config.Users}
  24. }
  25. type VMessOutboundConfig struct {
  26. VNextList []VNextConfig
  27. }
  28. func loadOutboundConfig(rawConfig []byte) (VMessOutboundConfig, error) {
  29. config := VMessOutboundConfig{}
  30. err := json.Unmarshal(rawConfig, &config)
  31. return config, err
  32. }