diff --git a/service/common/ntp/ntp.go b/service/common/ntp/ntp.go index 6f5351d3..05c3aa24 100644 --- a/service/common/ntp/ntp.go +++ b/service/common/ntp/ntp.go @@ -7,7 +7,7 @@ import ( ) const ( - DisplayFormat = "2006/01/02 15:04" + DisplayFormat = "2006/01/02 15:04 MST" ) func IsDatetimeSynced() (bool, time.Time, error) { diff --git a/service/core/serverObj/v2ray.go b/service/core/serverObj/v2ray.go index 5fdc734d..c9069f55 100644 --- a/service/core/serverObj/v2ray.go +++ b/service/core/serverObj/v2ray.go @@ -6,6 +6,7 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/tidwall/gjson" "github.com/v2rayA/v2rayA/common" + "github.com/v2rayA/v2rayA/common/ntp" "github.com/v2rayA/v2rayA/core/coreObj" "github.com/v2rayA/v2rayA/pkg/util/log" "net" @@ -13,6 +14,7 @@ import ( "regexp" "strconv" "strings" + "time" ) func init() { @@ -194,6 +196,9 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) { } switch strings.ToLower(v.Protocol) { case "vmess": + if ok, t, err := ntp.IsDatetimeSynced(); err == nil && !ok { + return Configuration{}, fmt.Errorf("please sync datetime first. Your datetime is %v, and the correct datetime is %v", time.Now().Local().Format(ntp.DisplayFormat), t.Local().Format(ntp.DisplayFormat)) + } core.Settings.Vnext = []coreObj.Vnext{ { Address: v.Add, diff --git a/service/core/v2ray/processManager.go b/service/core/v2ray/processManager.go index 4ee8afbc..bd02321f 100644 --- a/service/core/v2ray/processManager.go +++ b/service/core/v2ray/processManager.go @@ -2,13 +2,11 @@ package v2ray import ( "fmt" - "github.com/v2rayA/v2rayA/common/ntp" "github.com/v2rayA/v2rayA/common/resolv" "github.com/v2rayA/v2rayA/core/specialMode" "github.com/v2rayA/v2rayA/core/v2ray/asset" "github.com/v2rayA/v2rayA/db/configure" "github.com/v2rayA/v2rayA/pkg/util/log" - "time" ) type CoreProcessManager struct { @@ -45,9 +43,6 @@ func (m *CoreProcessManager) Stop(saveRunning bool) { func (m *CoreProcessManager) beforeStart(t *Template) (err error) { resolv.CheckResolvConf() - if ok, t, err := ntp.IsDatetimeSynced(); err == nil && !ok { - return fmt.Errorf("Please sync datetime first. Your datetime is %v, and the correct datetime is %v", time.Now().Local().Format(ntp.DisplayFormat), t.Local().Format(ntp.DisplayFormat)) - } if (t.Setting.Transparent == configure.TransparentGfwlist || t.Setting.RulePortMode == configure.GfwlistMode) && !asset.DoesV2rayAssetExist("LoyalsoldierSite.dat") { return fmt.Errorf("cannot find GFWList files. update GFWList and try again")