Skip to content

Sockopt: Fix Windows Multicast interface bind#4568

Merged
RPRX merged 2 commits intoXTLS:mainfrom
xqzr:patch-1
Mar 30, 2025
Merged

Sockopt: Fix Windows Multicast interface bind#4568
RPRX merged 2 commits intoXTLS:mainfrom
xqzr:patch-1

Conversation

@xqzr
Copy link
Contributor

@xqzr xqzr commented Mar 29, 2025

No description provided.

@xqzr
Copy link
Contributor Author

xqzr commented Mar 29, 2025

测试可用
配置示例:

{
 "inbounds": [
  {
   "port": 53,
   "listen": "::1",
   "protocol": "dokodemo-door",
   "settings": {
    "address": "ff01::1", //or 224.0.0.1
    "port": 53,
    "network": "tcp,udp"
   },
   "streamSettings": {
    "sockopt": {
     "TcpKeepAliveIdle": -1
    }
   }
  }
 ],
 "outbounds": [
  {
   "protocol": "freedom",
   "streamSettings": {
    "sockopt": {
     "TcpKeepAliveIdle": -1,
     "interface": "s3"
    }
   }
  }
 ],
 "log": {
  "loglevel": "debug",
  "dnsLog": true
 }
}

@RPRX
Copy link
Member

RPRX commented Mar 29, 2025

我看 Linux 上的代码似乎无需区分是否 multicast,macOS 呢?

@xqzr
Copy link
Contributor Author

xqzr commented Mar 29, 2025

macOS 呢?

没有测试条件😇

@RPRX
Copy link
Member

RPRX commented Mar 29, 2025

既然发现了这个问题,你看下 macOS 有没有类似的东西,直接加上应该没问题

@RPRX
Copy link
Member

RPRX commented Mar 29, 2025

#4530 (comment) 那大概只有 Windows 上需要这个修复,16 和 17 行互换下位置 @xqzr

不过我刚发现 Linux 上也有个 IP_MULTICAST_IF,你看看 Linux 上现在的代码有没有问题?

@RPRX
Copy link
Member

RPRX commented Mar 29, 2025

if config.Interface != "" {
if err := syscall.BindToDevice(int(fd), config.Interface); err != nil {
return errors.New("failed to set Interface").Base(err)
}
}

就是说 Linux 上的 syscall.BindToDevice() 是否涵盖了所有情况?

@xqzr
Copy link
Contributor Author

xqzr commented Mar 29, 2025

你看看 Linux 上现在的代码有没有问题?

没问题

@xqzr
Copy link
Contributor Author

xqzr commented Mar 29, 2025

16 和 17 行互换下位置 @xqzr

IPv6 优先😉

@RPRX
Copy link
Member

RPRX commented Mar 30, 2025

请修改代码 @xqzr

@RPRX RPRX changed the title Try Fix sockopt Interface miss multicast on Windows Sockopt: Fix Windows multicast interface bind Mar 30, 2025
@RPRX RPRX changed the title Sockopt: Fix Windows multicast interface bind Sockopt: Fix Windows Multicast interface bind Mar 30, 2025
@RPRX RPRX merged commit 52a2c63 into XTLS:main Mar 30, 2025
35 checks passed
@xqzr xqzr deleted the patch-1 branch March 30, 2025 21:26
RPRX pushed a commit that referenced this pull request Apr 19, 2025
maoxikun pushed a commit to maoxikun/Xray-core that referenced this pull request Aug 23, 2025
maoxikun pushed a commit to maoxikun/Xray-core that referenced this pull request Aug 23, 2025
it2konst pushed a commit to it2konst/gametunnel-core that referenced this pull request Mar 1, 2026
it2konst pushed a commit to it2konst/gametunnel-core that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants