func (this *Account) AsAccount() (protocol.Account, error) { id, err := uuid.ParseString(this.Id) if err != nil { log.Error("VMess: Failed to parse ID: ", err) return nil, err } protoId := protocol.NewID(id) return &InternalAccount{ ID: protoId, AlterIDs: protocol.NewAlterIDs(protoId, uint16(this.AlterId)), }, nil }
func (v *Account) AsAccount() (protocol.Account, error) { id, err := uuid.ParseString(v.Id) if err != nil { log.Error("VMess: Failed to parse ID: ", err) return nil, err } protoID := protocol.NewID(id) return &InternalAccount{ ID: protoID, AlterIDs: protocol.NewAlterIDs(protoID, uint16(v.AlterId)), Security: v.SecuritySettings.AsSecurity(), }, nil }
func (u *Account) UnmarshalJSON(data []byte) error { type JsonConfig struct { ID string `json:"id"` AlterIds uint16 `json:"alterId"` } var rawConfig JsonConfig if err := json.Unmarshal(data, &rawConfig); err != nil { return err } id, err := uuid.ParseString(rawConfig.ID) if err != nil { log.Error("VMess: Failed to parse ID: ", err) return err } u.ID = protocol.NewID(id) u.AlterIDs = protocol.NewAlterIDs(u.ID, rawConfig.AlterIds) return nil }