Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions phantomtcp/phantom.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,27 +988,28 @@ func CreateOutbounds(Outbounds []OutboundConfig) []string {
}
}
}

if outbound.Device != "" && Hint&HINT_IPV4 == 0 && Hint&HINT_IPV6 == 0 {
ip6, _ := GetLocalTCPAddr(outbound.Device, true)
if ip6 != nil {
Hint |= HINT_IPV6
}
ip4, _ := GetLocalTCPAddr(outbound.Device, false)
if ip4 != nil {
Hint |= HINT_IPV4
}
}

if Hint&HINT_IPV4 == 0 && Hint&HINT_IPV6 == 0 {
Hint |= HINT_IPV4
}

_, ok := OutboundsMap[outbound.Device]
if !ok && !contains(devices, outbound.Device) {
devices = append(devices, outbound.Device)
}
}

if outbound.Device != "" && Hint&HINT_IPV4 == 0 && Hint&HINT_IPV6 == 0 {
ip6, _ := GetLocalTCPAddr(outbound.Device, true)
if ip6 != nil {
outbound.Hint |= HINT_IPV6
}
ip4, _ := GetLocalTCPAddr(outbound.Device, false)
if ip4 != nil {
outbound.Hint |= HINT_IPV4
}
}

if Hint&HINT_IPV4 == 0 && Hint&HINT_IPV6 == 0 {
outbound.Hint |= HINT_IPV4
}

}

default_outbound, ok := OutboundsMap["default"]
Expand Down
2 changes: 1 addition & 1 deletion phantomtcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func GetLocalTCPAddr(name string, ipv6 bool) (*net.TCPAddr, error) {
if !ok || len(localAddr.IP) != 16{
continue
}
if localAddr.IP[0] != 0 && (localAddr.IP[0] != 0xfe && localAddr.IP[1]&0xc0 == 0x80) {
if localAddr.IP[0] != 0 && !localAddr.IP.IsLinkLocalUnicast() {
ip := make([]byte, 16)
copy(ip[:16], localAddr.IP)
addr6 = &net.TCPAddr{IP: ip[:], Port: 0}
Expand Down
Loading