Skip to content

Commit f172397

Browse files
authored
Merge pull request #19 from pedramktb/fix/dns_rules
fix: update dns type to net.UDPAddr and adjust routing rules accordingly
2 parents da561a5 + 8a4c963 commit f172397

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pkg/wireguard/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Manager struct {
1616
mtu uint16
1717
netV4, netV6 net.IPNet
1818
addrV4, addrV6 net.IP
19-
dnsV4, dnsV6 net.IP
19+
dnsV4, dnsV6 net.UDPAddr
2020
}
2121

2222
func NewManager(

pkg/wireguard/routing_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (m *Manager) addRouting() error {
3535
return fmt.Errorf("failed to add masquerade rule for ipv6: %w", err)
3636
}
3737

38-
err = ip6t.Insert("nat", "PREROUTING", 1, "-d", m.addrV6.String(), "-p", "udp", "--dport", "53", "-j", "DNAT", "--to-destination", fmt.Sprintf("[%s]", m.dnsV6.String()))
38+
err = ip6t.Insert("nat", "PREROUTING", 1, "-d", m.addrV6.String(), "-p", "udp", "--dport", "53", "-j", "DNAT", "--to-destination", m.dnsV6.String())
3939
if err != nil {
4040
return fmt.Errorf("failed to add dns rule for ipv6: %w", err)
4141
}
@@ -74,7 +74,7 @@ func (m *Manager) removeRouting() error {
7474
errs = append(errs, fmt.Errorf("failed to delete masquerade rule for ipv6: %w", err))
7575
}
7676

77-
err = ip6t.DeleteIfExists("nat", "PREROUTING", "-d", m.addrV4.String(), "-p", "udp", "--dport", "53", "-j", "DNAT", "--to-destination", fmt.Sprintf("[%s]", m.dnsV6.String()))
77+
err = ip6t.DeleteIfExists("nat", "PREROUTING", "-d", m.addrV4.String(), "-p", "udp", "--dport", "53", "-j", "DNAT", "--to-destination", m.dnsV6.String())
7878
if err != nil {
7979
errs = append(errs, fmt.Errorf("failed to delete dns rule for ipv6: %w", err))
8080
}

0 commit comments

Comments
 (0)