mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-12-16 20:27:04 +03:00
Some checks are pending
Build docker image / build-image (push) Waiting to run
Build and Release / prepare (push) Waiting to run
Build and Release / build (386, freebsd, , ) (push) Blocked by required conditions
Build and Release / build (386, linux, , ) (push) Blocked by required conditions
Build and Release / build (386, openbsd, , ) (push) Blocked by required conditions
Build and Release / build (386, windows, , ) (push) Blocked by required conditions
Build and Release / build (386, windows, 1.21.4, win7-32) (push) Blocked by required conditions
Build and Release / build (amd64, darwin, , ) (push) Blocked by required conditions
Build and Release / build (amd64, freebsd, , ) (push) Blocked by required conditions
Build and Release / build (amd64, linux, , ) (push) Blocked by required conditions
Build and Release / build (amd64, openbsd, , ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, , ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, 1.21.4, win7-64) (push) Blocked by required conditions
Build and Release / build (arm, 5, linux) (push) Blocked by required conditions
Build and Release / build (arm, 6, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, freebsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, openbsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, windows) (push) Blocked by required conditions
Build and Release / build (arm64, android) (push) Blocked by required conditions
Build and Release / build (arm64, darwin) (push) Blocked by required conditions
Build and Release / build (arm64, freebsd) (push) Blocked by required conditions
Build and Release / build (arm64, linux) (push) Blocked by required conditions
Build and Release / build (arm64, openbsd) (push) Blocked by required conditions
Build and Release / build (arm64, windows) (push) Blocked by required conditions
Build and Release / build (loong64, linux) (push) Blocked by required conditions
Build and Release / build (mips, linux) (push) Blocked by required conditions
Build and Release / build (mips64, linux) (push) Blocked by required conditions
Build and Release / build (mips64le, linux) (push) Blocked by required conditions
Build and Release / build (mipsle, linux) (push) Blocked by required conditions
Build and Release / build (ppc64, linux) (push) Blocked by required conditions
Build and Release / build (ppc64le, linux) (push) Blocked by required conditions
Build and Release / build (riscv64, linux) (push) Blocked by required conditions
Build and Release / build (s390x, linux) (push) Blocked by required conditions
Test / test (macos-latest) (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
Test / test (windows-latest) (push) Waiting to run
* Add GetInboundUser in proto * Add get user logic for all existing inbounds * Add inbounduser command * Add option to get all users * Fix shadowsocks2022 config * Fix init users in shadowsocks2022 * Fix copy * Add inbound user count command This api costs much less than get inbound user, could be useful in some case * Update from latest main
68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
package vmess
|
|
|
|
import (
|
|
"google.golang.org/protobuf/proto"
|
|
"strings"
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
"github.com/xtls/xray-core/common/protocol"
|
|
"github.com/xtls/xray-core/common/uuid"
|
|
)
|
|
|
|
// MemoryAccount is an in-memory form of VMess account.
|
|
type MemoryAccount struct {
|
|
// ID is the main ID of the account.
|
|
ID *protocol.ID
|
|
// Security type of the account. Used for client connections.
|
|
Security protocol.SecurityType
|
|
|
|
AuthenticatedLengthExperiment bool
|
|
NoTerminationSignal bool
|
|
}
|
|
|
|
// Equals implements protocol.Account.
|
|
func (a *MemoryAccount) Equals(account protocol.Account) bool {
|
|
vmessAccount, ok := account.(*MemoryAccount)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return a.ID.Equals(vmessAccount.ID)
|
|
}
|
|
|
|
func (a *MemoryAccount) ToProto() proto.Message {
|
|
var test = ""
|
|
if a.AuthenticatedLengthExperiment {
|
|
test = "AuthenticatedLength|"
|
|
}
|
|
if a.NoTerminationSignal {
|
|
test = test + "NoTerminationSignal"
|
|
}
|
|
return &Account{
|
|
Id: a.ID.String(),
|
|
TestsEnabled: test,
|
|
SecuritySettings: &protocol.SecurityConfig{Type: a.Security},
|
|
}
|
|
}
|
|
|
|
// AsAccount implements protocol.Account.
|
|
func (a *Account) AsAccount() (protocol.Account, error) {
|
|
id, err := uuid.ParseString(a.Id)
|
|
if err != nil {
|
|
return nil, errors.New("failed to parse ID").Base(err).AtError()
|
|
}
|
|
protoID := protocol.NewID(id)
|
|
var AuthenticatedLength, NoTerminationSignal bool
|
|
if strings.Contains(a.TestsEnabled, "AuthenticatedLength") {
|
|
AuthenticatedLength = true
|
|
}
|
|
if strings.Contains(a.TestsEnabled, "NoTerminationSignal") {
|
|
NoTerminationSignal = true
|
|
}
|
|
return &MemoryAccount{
|
|
ID: protoID,
|
|
Security: a.SecuritySettings.GetSecurityType(),
|
|
AuthenticatedLengthExperiment: AuthenticatedLength,
|
|
NoTerminationSignal: NoTerminationSignal,
|
|
}, nil
|
|
}
|