Files
v2ray_simple/proxy/config_simple.go
hahahrfool 2d384314f4 修订,重构代码, 修复dns的bug; 添加Dns的DoT功能.
修复dns配置中"特殊服务器" 无法被正确配置、使用的bug

将 proxy.Standard结构 移动到 项目根目录的 StandardConf.
将 proxy.AppConf, LoadTomlConfStr, LoadTomlConfFile 函数 移动到根目录

因为 StandardConf和 AppConf里包含很多App级别的配置, 不宜放到proxy子包中

将 proxy.RuleConf 移动到 netLayer
将 proxy.LoadRulesForRoutePolicy 移动到 netLayer
将 proxy.LoadDnsMachine 移动到 netLayer

在dnsquery失败后,会判断错误, 若发现是Read错误,则会试图重新拨号
2022-04-07 13:45:24 +08:00

54 lines
1.4 KiB
Go

package proxy
import (
"encoding/json"
"io/ioutil"
"os"
"github.com/hahahrfool/v2ray_simple/httpLayer"
"github.com/hahahrfool/v2ray_simple/netLayer"
"github.com/hahahrfool/v2ray_simple/utils"
)
//极简配置模式;不支持 ws/grpc
type Simple struct {
Server_ThatListenPort_Url string `json:"listen"`
Client_ThatDialRemote_Url string `json:"dial"`
Route []*netLayer.RuleConf `json:"route" toml:"route"`
Fallbacks []*httpLayer.FallbackConf `json:"fallbacks"`
MyCountryISO_3166 string `toml:"mycountry" json:"mycountry"`
}
func LoadSimpleConfigFile(fileNamePath string) (config Simple, hasError bool, E utils.ErrInErr) {
if cf, err := os.Open(fileNamePath); err == nil {
defer cf.Close()
bs, _ := ioutil.ReadAll(cf)
if err = json.Unmarshal(bs, &config); err != nil {
hasError = true
E = utils.ErrInErr{
ErrDesc: "can not parse config file ",
ErrDetail: err,
Data: fileNamePath,
}
}
return
} else {
hasError = true
E = utils.ErrInErr{ErrDesc: "can't open config file", ErrDetail: err}
return
}
}
func LoadSimpleConfigFromStr(str string) (config Simple, hasE bool, E utils.ErrInErr) {
if err := json.Unmarshal([]byte(str), &config); err != nil {
E = utils.ErrInErr{ErrDesc: "can not parse config ", ErrDetail: err}
hasE = true
}
return
}