mirror of https://github.com/XTLS/Xray-core
Refine time usage
parent
033d2ba2b9
commit
f42a518bf6
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/antireplay"
|
"github.com/xtls/xray-core/common/antireplay"
|
||||||
"github.com/xtls/xray-core/proxy/vmess/time"
|
"github.com/xtls/xray-core/proxy/vmess/vtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -105,7 +105,7 @@ func (a *AuthIDDecoderHolder) Match(authID [16]byte) (interface{}, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if math.Abs(math.Abs(float64(t))-float64(time.Now().Unix())) > 120 {
|
if math.Abs(math.Abs(float64(t))-float64(vtime.Now().Unix())) > 120 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/xtls/xray-core/proxy/vmess/time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateAuthID(t *testing.T) {
|
func TestCreateAuthID(t *testing.T) {
|
||||||
|
|
|
@ -8,11 +8,11 @@ import (
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/crypto"
|
"github.com/xtls/xray-core/common/crypto"
|
||||||
"github.com/xtls/xray-core/proxy/vmess/time"
|
"github.com/xtls/xray-core/proxy/vmess/vtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SealVMessAEADHeader(key [16]byte, data []byte) []byte {
|
func SealVMessAEADHeader(key [16]byte, data []byte) []byte {
|
||||||
generatedAuthID := CreateAuthID(key[:], time.Now().Unix())
|
generatedAuthID := CreateAuthID(key[:], vtime.Now().Unix())
|
||||||
|
|
||||||
connectionNonce := make([]byte, 8)
|
connectionNonce := make([]byte, 8)
|
||||||
if _, err := io.ReadFull(rand.Reader, connectionNonce); err != nil {
|
if _, err := io.ReadFull(rand.Reader, connectionNonce); err != nil {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/protocol"
|
"github.com/xtls/xray-core/common/protocol"
|
||||||
"github.com/xtls/xray-core/proxy/vmess"
|
"github.com/xtls/xray-core/proxy/vmess"
|
||||||
xtime "github.com/xtls/xray-core/proxy/vmess/time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *Handler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
|
func (h *Handler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
|
||||||
|
@ -26,7 +25,7 @@ func (h *Handler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
|
||||||
Account: account,
|
Account: account,
|
||||||
}
|
}
|
||||||
dest := net.TCPDestination(cmd.Host, cmd.Port)
|
dest := net.TCPDestination(cmd.Host, cmd.Port)
|
||||||
until := xtime.Now().Add(time.Duration(cmd.ValidMin) * time.Minute)
|
until := time.Now().Add(time.Duration(cmd.ValidMin) * time.Minute)
|
||||||
h.serverList.AddServer(protocol.NewServerSpec(dest, protocol.BeforeTime(until), user))
|
h.serverList.AddServer(protocol.NewServerSpec(dest, protocol.BeforeTime(until), user))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package time
|
package vtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
Loading…
Reference in New Issue