mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
修订代码
This commit is contained in:
@@ -317,20 +317,21 @@ func mainFunc() (result int) {
|
||||
|
||||
//将@前缀的 回落dest配置 替换成 实际的 地址。
|
||||
|
||||
if len(standardConf.Fallbacks) != 0 {
|
||||
if len(standardConf.Fallbacks) > 0 {
|
||||
for _, fbConf := range standardConf.Fallbacks {
|
||||
if fbConf.Dest != nil {
|
||||
if deststr, ok := fbConf.Dest.(string); ok {
|
||||
if strings.HasPrefix(deststr, "@") {
|
||||
for _, s := range allServers {
|
||||
if s.GetTag() == deststr[1:] {
|
||||
log.Println("got tag fallback dest, will set to ", s.AddrStr())
|
||||
fbConf.Dest = s.AddrStr()
|
||||
}
|
||||
}
|
||||
if fbConf.Dest == nil {
|
||||
continue
|
||||
}
|
||||
if deststr, ok := fbConf.Dest.(string); ok && strings.HasPrefix(deststr, "@") {
|
||||
for _, s := range allServers {
|
||||
if s.GetTag() == deststr[1:] {
|
||||
log.Println("got tag fallback dest, will set to ", s.AddrStr())
|
||||
fbConf.Dest = s.AddrStr()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,8 @@ type Fallback interface {
|
||||
}
|
||||
|
||||
type FallbackResult struct {
|
||||
Addr netLayer.Addr
|
||||
Xver int
|
||||
ToTag string
|
||||
Addr netLayer.Addr
|
||||
Xver int
|
||||
}
|
||||
|
||||
func (r *FallbackResult) GetFallback(ftype byte, _ ...string) *FallbackResult {
|
||||
@@ -83,10 +82,11 @@ type FallbackConf struct {
|
||||
|
||||
Xver int `toml:"xver" json:"xver"` //use PROXY protocol or not, and which version
|
||||
|
||||
//必填
|
||||
Dest any `toml:"dest" json:"dest"` //see netLayer.NewAddrFromAny for details about "any" addr
|
||||
|
||||
ToTag string `toml:"toTag" json:"toTag"` //有些回落 像 unix domain socket 的话,地址可能很长,写起来不方便,所以还是 写到 toTag 里比较简单 明了
|
||||
//必填。
|
||||
//see netLayer.NewAddrFromAny for details about "any" addr.
|
||||
//
|
||||
// 约定,如果该项是字符串 且 开头为@,则我们认为它给出的是 tag 名称,要将其替换为 实际 该tag的 listen 的地址。
|
||||
Dest any `toml:"dest" json:"dest"`
|
||||
|
||||
//几种匹配方式,可选
|
||||
|
||||
|
||||
Reference in New Issue
Block a user