mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
44
proxy/vmess/outbound/command.go
Normal file
44
proxy/vmess/outbound/command.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
// +build !confonly
|
||||
|
||||
package outbound
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/xtls/xray-core/v1/common"
|
||||
"github.com/xtls/xray-core/v1/common/net"
|
||||
"github.com/xtls/xray-core/v1/common/protocol"
|
||||
"github.com/xtls/xray-core/v1/proxy/vmess"
|
||||
)
|
||||
|
||||
func (h *Handler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
|
||||
rawAccount := &vmess.Account{
|
||||
Id: cmd.ID.String(),
|
||||
AlterId: uint32(cmd.AlterIds),
|
||||
SecuritySettings: &protocol.SecurityConfig{
|
||||
Type: protocol.SecurityType_LEGACY,
|
||||
},
|
||||
}
|
||||
|
||||
account, err := rawAccount.AsAccount()
|
||||
common.Must(err)
|
||||
user := &protocol.MemoryUser{
|
||||
Email: "",
|
||||
Level: cmd.Level,
|
||||
Account: account,
|
||||
}
|
||||
dest := net.TCPDestination(cmd.Host, cmd.Port)
|
||||
until := time.Now().Add(time.Duration(cmd.ValidMin) * time.Minute)
|
||||
h.serverList.AddServer(protocol.NewServerSpec(dest, protocol.BeforeTime(until), user))
|
||||
}
|
||||
|
||||
func (h *Handler) handleCommand(dest net.Destination, cmd protocol.ResponseCommand) {
|
||||
switch typedCommand := cmd.(type) {
|
||||
case *protocol.CommandSwitchAccount:
|
||||
if typedCommand.Host == nil {
|
||||
typedCommand.Host = dest.Address
|
||||
}
|
||||
h.handleSwitchAccount(typedCommand)
|
||||
default:
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue