mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-19 20:29:20 +07:00
feat: add dial_mode domain+
This commit is contained in:
@ -12,11 +12,12 @@ type DialMode string
|
|||||||
const (
|
const (
|
||||||
DialMode_Ip DialMode = "ip"
|
DialMode_Ip DialMode = "ip"
|
||||||
DialMode_Domain DialMode = "domain"
|
DialMode_Domain DialMode = "domain"
|
||||||
|
DialMode_DomainPlus DialMode = "domain+"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseDialMode(mode string) (DialMode, error) {
|
func ParseDialMode(mode string) (DialMode, error) {
|
||||||
switch mode {
|
switch mode {
|
||||||
case "ip", "domain":
|
case "ip", "domain", "domain+":
|
||||||
return DialMode(mode), nil
|
return DialMode(mode), nil
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("unsupported dial mode: %v", mode)
|
return "", fmt.Errorf("unsupported dial mode: %v", mode)
|
||||||
|
@ -408,15 +408,20 @@ func (c *ControlPlane) finishInitDnsUpstreamResolve(raw common.UrlOrEmpty, dnsUp
|
|||||||
|
|
||||||
func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip.AddrPort, domain string) (dialTarget string) {
|
func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip.AddrPort, domain string) (dialTarget string) {
|
||||||
mode := consts.DialMode_Ip
|
mode := consts.DialMode_Ip
|
||||||
if c.dialMode == consts.DialMode_Domain &&
|
|
||||||
!outbound.IsReserved() && // Direct, block, etc. should be skipped.
|
if !outbound.IsReserved() && domain != "" {
|
||||||
domain != "" {
|
switch c.dialMode {
|
||||||
|
case consts.DialMode_Domain:
|
||||||
dstIp := common.ConvergeIp(dst.Addr())
|
dstIp := common.ConvergeIp(dst.Addr())
|
||||||
cache := c.lookupDnsRespCache(domain, common.AddrToDnsType(dstIp))
|
cache := c.lookupDnsRespCache(domain, common.AddrToDnsType(dstIp))
|
||||||
if cache != nil && cache.IncludeIp(dstIp) {
|
if cache != nil && cache.IncludeIp(dstIp) {
|
||||||
mode = consts.DialMode_Domain
|
mode = consts.DialMode_Domain
|
||||||
}
|
}
|
||||||
|
case consts.DialMode_DomainPlus:
|
||||||
|
mode = consts.DialMode_Domain
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case consts.DialMode_Ip:
|
case consts.DialMode_Ip:
|
||||||
dialTarget = dst.String()
|
dialTarget = dst.String()
|
||||||
|
Reference in New Issue
Block a user