mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-16 14:53:12 +00:00
Version 1.0 alpha
This commit is contained in:
1 parent
f3a12e9f57
commit
cc3fdb6ef4
21 files changed
+279
-103
No files matched your search
+25
-6
@@ -4,11 +4,22 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/v2ray/v2ray-core"
|
||||
"github.com/v2ray/v2ray-core/log"
|
||||
v2net "github.com/v2ray/v2ray-core/net"
|
||||
)
|
||||
|
||||
type VMessUser struct {
|
||||
Id string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
func (u *VMessUser) ToVUser() (core.VUser, error) {
|
||||
id, err := core.UUIDToVID(u.Id)
|
||||
return core.VUser{id}, err
|
||||
}
|
||||
|
||||
type VMessInboundConfig struct {
|
||||
AllowedClients []core.VUser `json:"clients"`
|
||||
AllowedClients []VMessUser `json:"clients"`
|
||||
}
|
||||
|
||||
func loadInboundConfig(rawConfig []byte) (VMessInboundConfig, error) {
|
||||
@@ -18,19 +29,27 @@ func loadInboundConfig(rawConfig []byte) (VMessInboundConfig, error) {
|
||||
}
|
||||
|
||||
type VNextConfig struct {
|
||||
Address string `json:"address"`
|
||||
Port uint16 `json:"port"`
|
||||
Users []core.VUser `json:"users"`
|
||||
Address string `json:"address"`
|
||||
Port uint16 `json:"port"`
|
||||
Users []VMessUser `json:"users"`
|
||||
}
|
||||
|
||||
func (config VNextConfig) ToVNextServer() VNextServer {
|
||||
users := make([]core.VUser, 0, len(config.Users))
|
||||
for _, user := range config.Users {
|
||||
vuser, err := user.ToVUser()
|
||||
if err != nil {
|
||||
panic(log.Error("Failed to convert %v to VUser.", user))
|
||||
}
|
||||
users = append(users, vuser)
|
||||
}
|
||||
return VNextServer{
|
||||
v2net.DomainAddress(config.Address, config.Port),
|
||||
config.Users}
|
||||
users}
|
||||
}
|
||||
|
||||
type VMessOutboundConfig struct {
|
||||
VNextList []VNextConfig
|
||||
VNextList []VNextConfig `json:"vnext"`
|
||||
}
|
||||
|
||||
func loadOutboundConfig(rawConfig []byte) (VMessOutboundConfig, error) {
|
||||
|
||||
Reference in new issue
Block a user