mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-14 01:40:32 +07:00
feat: dns routing (#26)
This commit is contained in:
@ -12,6 +12,7 @@ import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
internal "github.com/v2rayA/dae/pkg/ebpf_internal"
|
||||
"golang.org/x/net/dns/dnsmessage"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
@ -48,7 +49,7 @@ func ARangeU32(n uint32) []uint32 {
|
||||
|
||||
func Ipv6ByteSliceToUint32Array(_ip []byte) (ip [4]uint32) {
|
||||
for j := 0; j < 16; j += 4 {
|
||||
ip[j/4] = binary.LittleEndian.Uint32(_ip[j : j+4])
|
||||
ip[j/4] = internal.NativeEndian.Uint32(_ip[j : j+4])
|
||||
}
|
||||
return ip
|
||||
}
|
||||
@ -61,7 +62,7 @@ func Ipv6ByteSliceToUint8Array(_ip []byte) (ip [16]uint8) {
|
||||
func Ipv6Uint32ArrayToByteSlice(_ip [4]uint32) (ip []byte) {
|
||||
ip = make([]byte, 16)
|
||||
for j := 0; j < 4; j++ {
|
||||
binary.LittleEndian.PutUint32(ip[j*4:], _ip[j])
|
||||
internal.NativeEndian.PutUint32(ip[j*4:], _ip[j])
|
||||
}
|
||||
return ip
|
||||
}
|
||||
@ -372,13 +373,20 @@ func BoolToString(b bool) string {
|
||||
}
|
||||
}
|
||||
|
||||
func ConvergeIp(addr netip.Addr) netip.Addr {
|
||||
func ConvergeAddr(addr netip.Addr) netip.Addr {
|
||||
if addr.Is4In6() {
|
||||
addr = netip.AddrFrom4(addr.As4())
|
||||
}
|
||||
return addr
|
||||
}
|
||||
|
||||
func ConvergeAddrPort(addrPort netip.AddrPort) netip.AddrPort {
|
||||
if addrPort.Addr().Is4In6() {
|
||||
return netip.AddrPortFrom(netip.AddrFrom4(addrPort.Addr().As4()), addrPort.Port())
|
||||
}
|
||||
return addrPort
|
||||
}
|
||||
|
||||
func NewGcm(key []byte) (cipher.AEAD, error) {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user