mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
1 parent
304510b311
commit
aebfb0a389
5 files changed
+10
-18
No files matched your search
@@ -10,7 +10,6 @@ func IsIpForwardOn() bool {
|
||||
return err == nil && strings.TrimSpace(string(out)) == "1"
|
||||
}
|
||||
|
||||
//返回ipv4.ip_forward的开启状态。该命令写的ip_forward状态重启将失效。
|
||||
func WriteIpForward(on bool) (err error) {
|
||||
val := "0"
|
||||
if on {
|
||||
|
||||
@@ -5,12 +5,11 @@ import (
|
||||
"encoding/hex"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v2rayA/v2rayA/core/ipforward"
|
||||
"github.com/v2rayA/v2rayA/common/errors"
|
||||
"github.com/v2rayA/v2rayA/db"
|
||||
"github.com/xujiajun/nutsdb"
|
||||
"log"
|
||||
"strings"
|
||||
"github.com/v2rayA/v2rayA/common/errors"
|
||||
)
|
||||
|
||||
type Configure struct {
|
||||
@@ -203,7 +202,6 @@ func GetSettingNotNil() *Setting {
|
||||
r = NewSetting()
|
||||
_ = db.Set("system", "setting", r)
|
||||
}
|
||||
r.IntranetSharing = ipforward.IsIpForwardOn() //永远用真实值
|
||||
if r.AntiPollution == "" {
|
||||
r.AntiPollution = AntipollutionNone
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
jsonIteratorExtra "github.com/json-iterator/go/extra"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v2rayA/v2rayA/common/netTools/ports"
|
||||
"github.com/v2rayA/v2rayA/core/ipforward"
|
||||
"github.com/v2rayA/v2rayA/core/iptables"
|
||||
"github.com/v2rayA/v2rayA/core/v2ray"
|
||||
"github.com/v2rayA/v2rayA/core/v2ray/asset"
|
||||
@@ -155,13 +154,6 @@ func initConfigure() {
|
||||
initDBValue()
|
||||
}
|
||||
}
|
||||
//配置ip转发
|
||||
setting := configure.GetSettingNotNil()
|
||||
if setting.Transparent != configure.TransparentClose {
|
||||
if setting.IntranetSharing != ipforward.IsIpForwardOn() {
|
||||
_ = ipforward.WriteIpForward(setting.IntranetSharing)
|
||||
}
|
||||
}
|
||||
//检查config.json是否存在
|
||||
if _, err := os.Stat(asset.GetV2rayConfigPath()); err != nil {
|
||||
//不存在就建一个。多数情况发生于docker模式挂载volume时覆盖了/etc/v2ray
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/v2rayA/v2rayA/core/ipforward"
|
||||
"github.com/v2rayA/v2rayA/core/v2ray"
|
||||
"github.com/v2rayA/v2rayA/core/v2ray/asset/gfwlist"
|
||||
"github.com/v2rayA/v2rayA/db/configure"
|
||||
@@ -73,6 +74,10 @@ func Connect(which *configure.Which) (err error) {
|
||||
return newError("which can not be nil")
|
||||
}
|
||||
checkResolvConf()
|
||||
//配置ip转发
|
||||
if setting.IntranetSharing != ipforward.IsIpForwardOn() {
|
||||
_ = ipforward.WriteIpForward(setting.IntranetSharing)
|
||||
}
|
||||
//定位Server
|
||||
tsr, err := which.LocateServer()
|
||||
if err != nil {
|
||||
|
||||
@@ -22,12 +22,10 @@ func UpdateSetting(setting *configure.Setting) (err error) {
|
||||
if (setting.Transparent == configure.TransparentGfwlist || setting.PacMode == configure.GfwlistMode) && !asset.IsGFWListExists() {
|
||||
return newError("cannot find GFWList files. update GFWList and try again")
|
||||
}
|
||||
if setting.Transparent != configure.TransparentClose {
|
||||
if setting.IntranetSharing != ipforward.IsIpForwardOn() {
|
||||
err = ipforward.WriteIpForward(setting.IntranetSharing)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if setting.IntranetSharing != ipforward.IsIpForwardOn() {
|
||||
err = ipforward.WriteIpForward(setting.IntranetSharing)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
err = configure.SetSetting(setting)
|
||||
|
||||
Reference in new issue
Block a user