Skip to content

Commit

Permalink
fix: fix set ipv6 on windows failed bug (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
wencaiwulue authored Feb 27, 2024
1 parent d1d4361 commit 5879aa4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Connect(ctx context.Context, CIDRs []string, conf pkgutil.SshConfig) error
})
}
ipv4 := net.IPv4(223, 253, 0, 1)
ipv6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
ipv6 := net.ParseIP("efff:ffff:ffff:ffff:ffff:ffff:ffff:8888")
tunConf := pkgtun.Config{
Addr: (&net.IPNet{IP: ipv4, Mask: net.CIDRMask(32, 32)}).String(),
Addr6: (&net.IPNet{IP: ipv6, Mask: net.CIDRMask(128, 128)}).String(),
Expand Down
8 changes: 7 additions & 1 deletion pkg/client/udphandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,16 @@ func addRoute(i []byte, n int, r routing.Router, tunName string) {
if errs == nil && tunName == iface.Name {
continue
}
var mask net.IPMask
if answer.IP.To4() != nil {
mask = net.CIDRMask(32, 32)
} else {
mask = net.CIDRMask(128, 128)
}
err := tun.AddRoutes(tunName, types.Route{
Dst: net.IPNet{
IP: answer.IP,
Mask: net.CIDRMask(len(answer.IP)*8, len(answer.IP)*8),
Mask: mask,
},
GW: nil,
})
Expand Down

0 comments on commit 5879aa4

Please sign in to comment.