chore: all listeners support specialProxy
This commit is contained in:
parent
fd9c4cbfa5
commit
46d23d9b86
4 changed files with 29 additions and 12 deletions
|
@ -21,3 +21,9 @@ func WithSpecialRules(specialRules string) Addition {
|
||||||
metadata.SpecialRules = specialRules
|
metadata.SpecialRules = specialRules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithSpecialProxy(specialProxy string) Addition {
|
||||||
|
return func(metadata *C.Metadata) {
|
||||||
|
metadata.SpecialProxy = specialProxy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -670,39 +670,45 @@ listeners:
|
||||||
port: 10808
|
port: 10808
|
||||||
#listen: 0.0.0.0 # 默认监听 0.0.0.0
|
#listen: 0.0.0.0 # 默认监听 0.0.0.0
|
||||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理
|
||||||
# udp: false # 默认 true
|
# udp: false # 默认 true
|
||||||
|
|
||||||
- name: http-in-1
|
- name: http-in-1
|
||||||
type: http
|
type: http
|
||||||
port: 10809
|
port: 10809
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
|
|
||||||
- name: mixed-in-1
|
- name: mixed-in-1
|
||||||
type: mixed # HTTP(S) 和 SOCKS 代理混合
|
type: mixed # HTTP(S) 和 SOCKS 代理混合
|
||||||
port: 10810
|
port: 10810
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
# udp: false # 默认 true
|
# udp: false # 默认 true
|
||||||
|
|
||||||
- name: reidr-in-1
|
- name: reidr-in-1
|
||||||
type: redir
|
type: redir
|
||||||
port: 10811
|
port: 10811
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
|
|
||||||
- name: tproxy-in-1
|
- name: tproxy-in-1
|
||||||
type: tproxy
|
type: tproxy
|
||||||
port: 10812
|
port: 10812
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
# udp: false # 默认 true
|
# udp: false # 默认 true
|
||||||
|
|
||||||
- name: shadowsocks-in-1
|
- name: shadowsocks-in-1
|
||||||
type: shadowsocks
|
type: shadowsocks
|
||||||
port: 10813
|
port: 10813
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
password: vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg=
|
password: vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg=
|
||||||
cipher: 2022-blake3-aes-256-gcm
|
cipher: 2022-blake3-aes-256-gcm
|
||||||
|
|
||||||
|
@ -710,7 +716,8 @@ listeners:
|
||||||
type: vmess
|
type: vmess
|
||||||
port: 10814
|
port: 10814
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
users:
|
users:
|
||||||
- username: 1
|
- username: 1
|
||||||
uuid: 9d0cb9d0-964f-4ef6-897d-6c6b3ccf9e68
|
uuid: 9d0cb9d0-964f-4ef6-897d-6c6b3ccf9e68
|
||||||
|
@ -720,7 +727,8 @@ listeners:
|
||||||
type: tuic
|
type: tuic
|
||||||
port: 10815
|
port: 10815
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
# token:
|
# token:
|
||||||
# - TOKEN
|
# - TOKEN
|
||||||
# certificate: ./server.crt
|
# certificate: ./server.crt
|
||||||
|
@ -736,13 +744,15 @@ listeners:
|
||||||
type: tunnel
|
type: tunnel
|
||||||
port: 10816
|
port: 10816
|
||||||
listen: 0.0.0.0
|
listen: 0.0.0.0
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
network: [ tcp, udp ]
|
network: [ tcp, udp ]
|
||||||
target: target.com
|
target: target.com
|
||||||
|
|
||||||
- name: tun-in-1
|
- name: tun-in-1
|
||||||
type: tun
|
type: tun
|
||||||
# rule: sub-rule
|
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||||
|
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||||
stack: system # gvisor / lwip
|
stack: system # gvisor / lwip
|
||||||
dns-hijack:
|
dns-hijack:
|
||||||
- 0.0.0.0:53 # 需要劫持的 DNS
|
- 0.0.0.0:53 # 需要劫持的 DNS
|
||||||
|
|
|
@ -76,6 +76,7 @@ type BaseOption struct {
|
||||||
Listen string `inbound:"listen,omitempty"`
|
Listen string `inbound:"listen,omitempty"`
|
||||||
Port int `inbound:"port,omitempty"`
|
Port int `inbound:"port,omitempty"`
|
||||||
SpecialRules string `inbound:"rule,omitempty"`
|
SpecialRules string `inbound:"rule,omitempty"`
|
||||||
|
SpecialProxy string `inbound:"proxy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o BaseOption) Name() string {
|
func (o BaseOption) Name() string {
|
||||||
|
@ -90,6 +91,7 @@ func (o BaseOption) Additions() []inbound.Addition {
|
||||||
return []inbound.Addition{
|
return []inbound.Addition{
|
||||||
inbound.WithInName(o.NameStr),
|
inbound.WithInName(o.NameStr),
|
||||||
inbound.WithSpecialRules(o.SpecialRules),
|
inbound.WithSpecialRules(o.SpecialRules),
|
||||||
|
inbound.WithSpecialProxy(o.SpecialProxy),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ type TunnelOption struct {
|
||||||
BaseOption
|
BaseOption
|
||||||
Network []string `inbound:"network"`
|
Network []string `inbound:"network"`
|
||||||
Target string `inbound:"target"`
|
Target string `inbound:"target"`
|
||||||
Proxy string `inbound:"proxy,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o TunnelOption) Equal(config C.InboundConfig) bool {
|
func (o TunnelOption) Equal(config C.InboundConfig) bool {
|
||||||
|
@ -74,11 +73,11 @@ func (t *Tunnel) Listen(tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter
|
||||||
for _, network := range t.config.Network {
|
for _, network := range t.config.Network {
|
||||||
switch network {
|
switch network {
|
||||||
case "tcp":
|
case "tcp":
|
||||||
if t.ttl, err = tunnel.New(t.RawAddress(), t.config.Target, t.config.Proxy, tcpIn, t.Additions()...); err != nil {
|
if t.ttl, err = tunnel.New(t.RawAddress(), t.config.Target, t.config.SpecialProxy, tcpIn, t.Additions()...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case "udp":
|
case "udp":
|
||||||
if t.tul, err = tunnel.NewUDP(t.RawAddress(), t.config.Target, t.config.Proxy, udpIn, t.Additions()...); err != nil {
|
if t.tul, err = tunnel.NewUDP(t.RawAddress(), t.config.Target, t.config.SpecialProxy, udpIn, t.Additions()...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue