diff --git a/gui/src/locales/en.js b/gui/src/locales/en.js index 5d422b32..e0ee10b8 100644 --- a/gui/src/locales/en.js +++ b/gui/src/locales/en.js @@ -21,8 +21,8 @@ export default { default: "V2RayA service is running,Version: {version}", newVersion: "Detected new version: {version}", messages: [ - "There is no servers now.", - "You can create a server or import a subscription now. Vmess, SS and SSR are supported." + "There is no server.", + "You can create a server or import a subscription. Vmess, SS and SSR are supported." ] }, v2ray: { @@ -64,11 +64,11 @@ export default { helpManual: "Help & Manual" }, register: { - title: "Nice to meet you! Create an admin account now", + title: "Create an admin account first", messages: [ "Remember your admin account which is importantly used to login.", "Account information is stored in local. We never send information to any server.", - "Once password is forgot, you can delete the config file and restart V2RayA service to reset." + "Once password was forgot, you could delete the config file and restart V2RayA service to reset." ] }, login: { diff --git a/service/global/environmentConfig.go b/service/global/environmentConfig.go index 6b26d75d..80f2cd8d 100644 --- a/service/global/environmentConfig.go +++ b/service/global/environmentConfig.go @@ -12,8 +12,9 @@ type Params struct { Address string `id:"address" short:"a" default:"0.0.0.0:2017" desc:"监听地址"` Config string `id:"config" short:"c" default:"/etc/v2ray/v2raya.json" desc:"V2RayA配置文件路径"` Mode string `id:"mode" short:"m" desc:"可选systemctl, service, docker, common. 不设置则自动检测"` - SSRListenPort int `short:"s" default:"12346" desc:"使用ss或ssr时的ssr server监听端口,默认12346"` + SSRListenPort int `short:"s" default:"12346" desc:"使用ss或ssr时的ssr server监听端口"` PassCheckRoot bool `desc:"可跳过启动时的权限检查"` + ResetPassword bool `id:"reset-password"` ShowVersion bool `id:"version"` } diff --git a/service/main.go b/service/main.go index d644cfd6..eb922088 100644 --- a/service/main.go +++ b/service/main.go @@ -34,12 +34,21 @@ func checkEnvironment() { _, _ = fmt.Scanf("\n") os.Exit(1) } - if !global.GetEnvironmentConfig().PassCheckRoot { + conf := global.GetEnvironmentConfig() + if !conf.PassCheckRoot || conf.ResetPassword { if os.Getegid() != 0 { log.Fatal("请以sudo或root权限执行本程序. 如您确信已sudo或已拥有root权限, 可使用--passcheckroot参数跳过检查") } } - _, port, err := net.SplitHostPort(global.GetEnvironmentConfig().Address) + if conf.ResetPassword { + err := configure.ResetAccounts() + if err != nil { + log.Fatal(err) + } + fmt.Println("ok") + os.Exit(0) + } + _, port, err := net.SplitHostPort(conf.Address) if err != nil { log.Fatal(err) } diff --git a/service/persistence/configure/configure.go b/service/persistence/configure/configure.go index d8b26e81..5c1b8d57 100644 --- a/service/persistence/configure/configure.go +++ b/service/persistence/configure/configure.go @@ -213,6 +213,9 @@ func SetAccount(username, password string) (err error) { path := fmt.Sprintf("accounts.%s", username) return persistence.Set(path, password) } +func ResetAccounts() (err error) { + return persistence.Set("accounts", nil) +} func ExistsAccount(username string) bool { return persistence.Exists(fmt.Sprintf("accounts.%s", username)) }