mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
feat/docs: robustness and notes
This commit is contained in:
1 parent
7ed0f4e623
commit
c8cd2b21c4
9 files changed
+98
-33
No files matched your search
@@ -168,7 +168,7 @@ V2RayA 致力于提供最简单的操作,满足绝大部分需求。
|
||||
|
||||
1. 在更换配置时略有卡顿
|
||||
|
||||
### 支持 Windows、MacOSX 吗
|
||||
### 服务端支持 Windows、MacOSX 吗
|
||||
|
||||
目前仅在 Linux 进行过测试,并计划优先适配 Linux。目前尚未验证在 Windows 及 MacOSX 上存在的问题。
|
||||
|
||||
|
||||
+7
-5
@@ -3,7 +3,7 @@
|
||||
<b-navbar ref="navs" fixed-top shadow type="is-light">
|
||||
<template slot="brand">
|
||||
<b-navbar-item href="/">
|
||||
<img src="./assets/logo.png" alt="V2RayA" class="logo no-select" />
|
||||
<img src="./assets/logo2.png" alt="V2RayA" class="logo no-select" />
|
||||
</b-navbar-item>
|
||||
</template>
|
||||
<template slot="start">
|
||||
@@ -26,11 +26,11 @@
|
||||
<!-- 节点-->
|
||||
<!-- </b-navbar-item>-->
|
||||
<b-navbar-item tag="a" @click.native="handleClickSetting">
|
||||
<i class="iconfont icon-setting" style="font-size: 1.25em" />
|
||||
<i class="iconfont icon-setting" style="font-size: 1.25em"></i>
|
||||
设置
|
||||
</b-navbar-item>
|
||||
<b-navbar-item tag="a" @click.native="handleClickAbout">
|
||||
<i class="iconfont icon-heart" style="font-size: 1.25em" />
|
||||
<i class="iconfont icon-heart" style="font-size: 1.25em"></i>
|
||||
关于
|
||||
</b-navbar-item>
|
||||
<b-dropdown
|
||||
@@ -44,7 +44,7 @@
|
||||
<i
|
||||
class="iconfont icon-caret-down"
|
||||
style="position: relative; top: 1px; left:2px"
|
||||
/>
|
||||
></i>
|
||||
</a>
|
||||
|
||||
<b-dropdown-item custom aria-role="menuitem">
|
||||
@@ -60,7 +60,7 @@
|
||||
<i
|
||||
class="iconfont icon-logout"
|
||||
style="position: relative;top:1px;"
|
||||
/>
|
||||
></i>
|
||||
Logout
|
||||
</b-dropdown-item>
|
||||
</b-dropdown>
|
||||
@@ -279,6 +279,8 @@ export default {
|
||||
|
||||
.logo {
|
||||
min-height: 2.5rem;
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.navbar-item .iconfont {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="modal-card" style="max-width: 450px;margin:auto">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">
|
||||
{{ first ? "初来乍到,请先注册账号" : "登陆 - V2rayA" }}
|
||||
{{ first ? "初来乍到,注册一个管理员账号" : "登陆 - V2rayA" }}
|
||||
</p>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
@@ -10,7 +10,7 @@
|
||||
<img src="../assets/logo2.png" alt="V2RayA" />
|
||||
</p>
|
||||
<b-field label="Username" type="is-success">
|
||||
<b-input v-model="username" @keyup.enter.native="handleEnter" />
|
||||
<b-input v-model="username" @keyup.enter.native="handleEnter"></b-input>
|
||||
</b-field>
|
||||
<b-field label="Password" type="is-success">
|
||||
<b-input
|
||||
@@ -18,8 +18,13 @@
|
||||
type="password"
|
||||
maxlength="32"
|
||||
@keyup.enter.native="handleEnter"
|
||||
/>
|
||||
></b-input>
|
||||
</b-field>
|
||||
<b-message v-if="first" type="is-info" class="after-line-dot5">
|
||||
<p>请记住您注册的管理员账号,用于登录该管理页面。</p>
|
||||
<p>账号信息位于本地,我们不会上传任何信息到服务器。</p>
|
||||
<p>如不慎忘记密码,可通过清除配置文件重置。</p>
|
||||
</b-message>
|
||||
</section>
|
||||
<footer class="modal-card-foot flex-end">
|
||||
<b-button
|
||||
@@ -96,3 +101,11 @@ export default {
|
||||
background-color: rgba(10, 10, 10, 0.7) !important;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.after-line-dot5 {
|
||||
font-size: 14px;
|
||||
p {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -13,7 +13,6 @@ require (
|
||||
github.com/matoous/go-nanoid v1.1.0
|
||||
github.com/mattn/go-colorable v0.1.4 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.5 // indirect
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/sparrc/go-ping v0.0.0-20190613174326-4e5b6552494c
|
||||
github.com/stevenroose/gonfig v0.1.4
|
||||
|
||||
@@ -43,8 +43,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
|
||||
+32
-5
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"V2RayA/extra/quickdown"
|
||||
"V2RayA/global"
|
||||
"V2RayA/model/ipforward"
|
||||
"V2RayA/model/v2ray"
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gookit/color"
|
||||
"github.com/json-iterator/go/extra"
|
||||
jsonIteratorExtra "github.com/json-iterator/go/extra"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
@@ -43,6 +44,7 @@ func checkEnvironment() {
|
||||
|
||||
func initConfigure() {
|
||||
//初始化配置
|
||||
jsonIteratorExtra.RegisterFuzzyDecoders()
|
||||
if !configure.IsConfigureExists() {
|
||||
_ = os.MkdirAll(path.Dir(global.GetEnvironmentConfig().Config), os.ModeDir|0755)
|
||||
err := configure.SetConfigure(configure.New())
|
||||
@@ -61,7 +63,25 @@ func initConfigure() {
|
||||
_ = ipforward.WriteIpForward(setting.IpForward)
|
||||
}
|
||||
}
|
||||
extra.RegisterFuzzyDecoders()
|
||||
//检查geoip、geosite是否存在
|
||||
if !v2ray.IsGeoipExists() {
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(2)
|
||||
dld := func(filename string) {
|
||||
color.Red.Println("正在安装" + filename)
|
||||
defer wg.Done()
|
||||
u := "https://cdn.jsdelivr.net/gh/v2ray/v2ray-core@master/release/config/" + filename
|
||||
p := v2ray.GetV2rayLocationAsset() + "/" + filename
|
||||
err := quickdown.DownloadWithWorkersTo(u, 5, p)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = os.Chmod(p, os.FileMode(0755))
|
||||
}
|
||||
go dld("geoip.dat")
|
||||
go dld("geosite.dat")
|
||||
wg.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
func checkConnection() {
|
||||
@@ -75,10 +95,12 @@ func checkConnection() {
|
||||
}
|
||||
|
||||
func hello() {
|
||||
color.Red.Println("V2RayLocationAsset is:", v2ray.GetV2rayLocationAsset())
|
||||
color.Red.Println("V2RayLocationAsset is", v2ray.GetV2rayLocationAsset())
|
||||
wd, _ := v2ray.GetV2rayWorkingDir()
|
||||
color.Red.Println("V2Ray binary is", wd+"/v2ray")
|
||||
if global.ServiceControlMode != global.DockerMode {
|
||||
wd, _ := os.Getwd()
|
||||
color.Red.Println("V2RayA working directory is:", wd)
|
||||
wd, _ = os.Getwd()
|
||||
color.Red.Println("V2RayA working directory is", wd)
|
||||
color.Red.Println("Version:", global.Version)
|
||||
} else {
|
||||
fmt.Println("V2RayA is running in Docker. Compatible mode starts up.")
|
||||
@@ -87,6 +109,8 @@ func hello() {
|
||||
}
|
||||
func checkUpdate() {
|
||||
setting := service.GetSetting()
|
||||
|
||||
//检查PAC文件更新
|
||||
if setting.PacAutoUpdateMode == configure.AutoUpdate {
|
||||
switch setting.PacMode {
|
||||
case configure.GfwlistMode:
|
||||
@@ -103,6 +127,8 @@ func checkUpdate() {
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
||||
//检查订阅更新
|
||||
if setting.SubscriptionAutoUpdateMode == configure.AutoUpdate {
|
||||
go func() {
|
||||
subs := configure.GetSubscriptions()
|
||||
@@ -126,6 +152,7 @@ func checkUpdate() {
|
||||
wg.Wait()
|
||||
}()
|
||||
}
|
||||
// 检查服务端更新
|
||||
go func() {
|
||||
if foundNew, remote, err := service.CheckUpdate(); err == nil {
|
||||
global.FoundNew = foundNew
|
||||
|
||||
@@ -32,7 +32,7 @@ func GetV2rayLocationAsset() (s string) {
|
||||
var err error
|
||||
if s == "" {
|
||||
//默认为v2ray运行目录
|
||||
s, err = getV2rayWorkingDir()
|
||||
s, err = GetV2rayWorkingDir()
|
||||
}
|
||||
if err != nil {
|
||||
//再不行只能盲猜一个
|
||||
@@ -42,18 +42,25 @@ func GetV2rayLocationAsset() (s string) {
|
||||
return
|
||||
}
|
||||
|
||||
func getV2rayWorkingDir() (string, error) {
|
||||
out, err := exec.Command("sh", "-c", "which v2ray").CombinedOutput()
|
||||
if err == nil {
|
||||
return strings.TrimSpace(string(out)), nil
|
||||
func GetV2rayWorkingDir() (string, error) {
|
||||
switch global.ServiceControlMode {
|
||||
case global.SystemctlMode, global.ServiceMode:
|
||||
//从systemd的启动参数里找
|
||||
p, _ := GetV2rayServiceFilePath()
|
||||
out, err := exec.Command("sh", "-c", "cat "+p+"|grep ExecStart=").CombinedOutput()
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error() + string(out))
|
||||
}
|
||||
arr := strings.Split(strings.TrimSpace(string(out)), " ")
|
||||
return path.Dir(arr[0][len("ExecStart="):]), nil
|
||||
case global.DockerMode, global.CommonMode:
|
||||
//从环境变量里找
|
||||
out, err := exec.Command("sh", "-c", "which v2ray").CombinedOutput()
|
||||
if err == nil {
|
||||
return path.Dir(strings.TrimSpace(string(out))), nil
|
||||
}
|
||||
}
|
||||
p, _ := GetV2rayServiceFilePath()
|
||||
out, err = exec.Command("sh", "-c", "cat "+p+"|grep ExecStart=").CombinedOutput()
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error() + string(out))
|
||||
}
|
||||
arr := strings.Split(strings.TrimSpace(string(out)), " ")
|
||||
return path.Dir(arr[0][len("ExecStart="):]), nil
|
||||
return "", errors.New("not found")
|
||||
}
|
||||
|
||||
func IsH2yExists() bool {
|
||||
@@ -63,6 +70,20 @@ func IsH2yExists() bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func IsGeoipExists() bool {
|
||||
_, err := os.Stat(GetV2rayLocationAsset() + "/geoip.dat")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func IsGeositeExists() bool {
|
||||
_, err := os.Stat(GetV2rayLocationAsset() + "/geosite.dat")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func GetH2yModTime() (time.Time, error) {
|
||||
return tools.GetFileModTime(GetV2rayLocationAsset() + "/h2y.dat")
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"V2RayA/global"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -117,8 +116,13 @@ func IsV2rayServiceValid() bool {
|
||||
case global.ServiceMode:
|
||||
out, err := exec.Command("sh", "-c", "service v2ray status|grep not-found").Output()
|
||||
return err == nil && len(bytes.TrimSpace(out)) == 0
|
||||
case global.DockerMode, global.CommonMode:
|
||||
out, err := exec.Command("sh", "-c", fmt.Sprintf("ls %s/geoip.dat", GetV2rayLocationAsset())).Output()
|
||||
case global.DockerMode:
|
||||
return IsGeoipExists() && IsGeositeExists()
|
||||
case global.CommonMode:
|
||||
if !IsGeoipExists() || !IsGeositeExists() {
|
||||
return false
|
||||
}
|
||||
out, err := exec.Command("sh", "-c", "which v2ray").Output()
|
||||
return err == nil && len(bytes.TrimSpace(out)) > 0
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
)
|
||||
|
||||
func Run() error {
|
||||
engine := gin.Default()
|
||||
engine := gin.New()
|
||||
engine.Use(gin.Recovery())
|
||||
corsConfig := cors.DefaultConfig()
|
||||
corsConfig.AllowAllOrigins = true
|
||||
corsConfig.AddAllowHeaders("Authorization")
|
||||
|
||||
Reference in new issue
Block a user