fix: the problem that some setting can not work

This commit is contained in:
mzz2017 committed 2019-11-18 03:07:53 +08:00
1 parent e07f1794b0
commit e9e5620110
6 files changed
+45 -42

No files matched your search

+2 -1
View File
@@ -27,7 +27,7 @@ V2RayA是V2Ray的一个Web客户端。
- [x] websocket、kcp、tcp、http、tls、shadowsocks全支持
- [x] 测试节点Ping时延
- [x] 二维码、地址分享
- [x] 自定义PAC模式(GFWList、大陆白名单、自定义路由规则)
- [x] 自定义PAC模式(GFWList、大陆白名单)
- [x] 服务端启动自动检查PAC、订阅更新
- [x] 多路复用、TCPFastOpen支持
@@ -36,6 +36,7 @@ V2RayA是V2Ray的一个Web客户端。
- [ ] 手动添加/修改节点
- [ ] 测试节点HTTP时延
- [ ] VPN模式全局代理支持
- [ ] 自定义路由规则
- [ ] QUIC协议支持
- [ ] 登陆与安全
+7 -7
View File
@@ -79,8 +79,8 @@
label-position="on-border"
>
<b-select v-model="pacAutoUpdateMode" expanded>
<option value="none">不自动更新GFWList</option>
<option value="auto_update">服务端启动时更新GFWList</option>
<option value="none">不自动更新PAC文件</option>
<option value="auto_update">服务端启动时更新PAC文件</option>
</b-select>
</b-field>
<b-field label="自动更新订阅" label-position="on-border">
@@ -102,6 +102,7 @@
<b-tooltip
type="is-dark"
label="简化TCP握手流程以加速建立连接,可能会增加封包的特征。"
multilined
position="is-right"
>
<b-icon
@@ -122,7 +123,8 @@
多路复用
<b-tooltip
type="is-dark"
label="复用TCP连接以减少握手延迟而非提高吞吐量,可能有反效果。"
label="复用TCP连接以减少握手延迟,但会影响吞吐量大的使用场景,如观看视频、下载、测速。"
multilined
position="is-right"
>
<b-icon
@@ -133,8 +135,8 @@
</b-tooltip>
</template>
<b-select v-model="muxOn" expanded style="flex: 1">
<option value="no">关闭多路复用</option>
<option value="yes">启用多路复用</option>
<option value="no">关闭</option>
<option value="yes">启用</option>
</b-select>
<cus-b-input
v-if="muxOn === 'yes'"
@@ -182,9 +184,7 @@ export default {
muxOn: "no",
mux: "8",
pacAutoUpdateMode: "none",
pacAutoUpdateTime: null,
subscriptionAutoUpdateMode: "none",
subscriptionAutoUpdateTime: null,
customSiteDAT: {},
pacMode: "whitelist",
customPac: {
+29 -25
View File
@@ -60,33 +60,36 @@ func hello() {
}
func checkUpdate() {
setting := service.GetSetting()
if setting.GFWListAutoUpdateMode == configure.AutoUpdate {
go func() {
update, tRemote, err := service.IsUpdate()
if err != nil {
logs.Print("自动更新GFWList失败" + err.Error())
return
}
if update {
logs.Print("自动更新GFWList:目前最新版本为" + tRemote.Format("2006-01-02") + ",您的本地文件已最新,无需更新")
return
}
/* 更新h2y.dat */
localGFWListVersion, err := service.UpdateLocalGFWList()
if err != nil {
logs.Print("自动更新GFWList失败" + err.Error())
return
}
logs.Print("自动更新GFWList完成,本地文件时间:" + localGFWListVersion)
}()
}
if setting.CustomAutoUpdateMode == configure.AutoUpdate {
//TODO
log.Println("PacAutoUpdateMode", setting.PacAutoUpdateMode)
if setting.PacAutoUpdateMode == configure.AutoUpdate {
switch setting.PacMode {
case configure.GfwlistMode:
go func() {
update, tRemote, err := service.IsUpdate()
if err != nil {
logs.Print("自动更新PAC文件失败" + err.Error())
return
}
if update {
logs.Print("自动更新PAC文件:目前最新版本为" + tRemote.Format("2006-01-02") + ",您的本地文件已最新,无需更新")
return
}
/* 更新h2y.dat */
localGFWListVersion, err := service.UpdateLocalGFWList()
if err != nil {
logs.Print("自动更新PAC文件失败" + err.Error())
return
}
logs.Print("自动更新PAC文件完成,本地文件时间:" + localGFWListVersion)
}()
case configure.CustomMode:
//TODO
}
}
if setting.SubscriptionAutoUpdateMode == configure.AutoUpdate {
subs := configure.GetSubscriptions()
lenSubs := len(subs)
go func() {
subs := configure.GetSubscriptions()
lenSubs := len(subs)
control := make(chan struct{}, 2) //并发限制同时更新2个订阅
wg := new(sync.WaitGroup)
for i := 0; i < lenSubs; i++ {
@@ -95,7 +98,7 @@ func checkUpdate() {
control <- struct{}{}
err := service.UpdateSubscription(i)
if err != nil {
logs.Print(fmt.Sprintf("自动更新订阅失败,id: %d,地址: %s,err: %v", i, subs[i].Address, err.Error()))
logs.Print(fmt.Sprintf("自动更新订阅失败,id: %d,err: %v", i, subs[i].Address, err.Error()))
} else {
logs.Print(fmt.Sprintf("自动更新订阅成功,id: %d,地址: %s", i, subs[i].Address))
}
@@ -111,6 +114,7 @@ func checkUpdate() {
func main() {
gin.SetMode(gin.ReleaseMode)
checkEnvironment()
logs.Print("V2RayA已启动")
initConfigure()
checkConnection()
hello()
+2 -4
View File
@@ -8,8 +8,7 @@ type Setting struct {
PacMode PacMode `json:"pacMode"`
CustomPac CustomPac `json:"customPac"`
ProxyModeWhenSubscribe ProxyModeWhenSubscribe `json:"proxyModeWhenSubscribe"`
GFWListAutoUpdateMode AutoUpdateMode `json:"pacAutoUpdateMode"`
CustomAutoUpdateMode AutoUpdateMode `json:"pacAutoUpdateMode"`
PacAutoUpdateMode AutoUpdateMode `json:"pacAutoUpdateMode"`
SubscriptionAutoUpdateMode AutoUpdateMode `json:"subscriptionAutoUpdateMode"`
TcpFastOpen DefaultYesNo `json:"tcpFastOpen"`
MuxOn DefaultYesNo `json:"muxOn"`
@@ -25,8 +24,7 @@ func NewSetting() (setting *Setting) {
RoutingRules: []RoutingRule{},
},
ProxyModeWhenSubscribe: ProxyModeDirect,
GFWListAutoUpdateMode: NotAutoUpdate,
CustomAutoUpdateMode: NotAutoUpdate,
PacAutoUpdateMode: NotAutoUpdate,
SubscriptionAutoUpdateMode: NotAutoUpdate,
TcpFastOpen: Default,
MuxOn: No,
+1 -3
View File
@@ -2,7 +2,6 @@ package logs
import (
"V2RayA/persistence"
"log"
"time"
)
@@ -11,6 +10,5 @@ func format(s string) string {
}
func Print(s string) {
persistence.DoAndSave("rpush", "V2RayA.log", format(s))
log.Println(s)
_, _ = persistence.DoAndSave("rpush", "V2RayA.log", format(s))
}
+4 -2
View File
@@ -8,6 +8,8 @@ import (
"time"
)
const saveInterval = 10 * time.Second
var once sync.Once
var pool *redis.Pool
var nextSave = time.Now().Add(30 * 24 * time.Hour)
@@ -19,7 +21,7 @@ func saveLater() {
c := RedisPool().Get()
_, _ = c.Do("BGSAVE")
}
time.Sleep(5 * time.Second)
time.Sleep(saveInterval / 2)
}
}
@@ -55,6 +57,6 @@ func Do(command string, args ...interface{}) (reply interface{}, err error) {
}
func DoAndSave(command string, args ...interface{}) (reply interface{}, err error) {
nextSave = time.Now().Add(5 * time.Second) //延迟5秒save,这样如果连续调用本函数,将会推迟save时间
nextSave = time.Now().Add(saveInterval) //延迟一段时间save,这样如果连续调用本函数,将会推迟save时间
return Do(command, args...)
}