You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

  1. diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go
  2. index 9cca419..45f93a5 100644
  3. --- a/src/yggdrasil/tcp.go
  4. +++ b/src/yggdrasil/tcp.go
  5. @@ -25,6 +25,7 @@ import (
  6. "golang.org/x/net/proxy"
  7. + "github.com/yggdrasil-network/yggdrasil-go/src/address"
  8. "github.com/yggdrasil-network/yggdrasil-go/src/util"
  9. )
  10. @@ -386,6 +387,19 @@ func (t *tcp) handler(sock net.Conn, incoming bool, options interface{}, upgrade
  11. local, _, _ = net.SplitHostPort(sock.LocalAddr().String())
  12. remote, _, _ = net.SplitHostPort(sock.RemoteAddr().String())
  13. }
  14. + localIP := net.ParseIP(local)
  15. + if localIP = localIP.To16(); localIP != nil {
  16. + var laddr address.Address
  17. + var lsubnet address.Subnet
  18. + copy(laddr[:], localIP)
  19. + copy(lsubnet[:], localIP)
  20. + if laddr.IsValid() || lsubnet.IsValid() {
  21. + // The local address is with the network address/prefix range
  22. + // This would route ygg over ygg, which we don't want
  23. + t.link.core.log.Debugln("Dropping ygg-tunneled connection", local, remote)
  24. + return
  25. + }
  26. + }
  27. force := net.ParseIP(strings.Split(remote, "%")[0]).IsLinkLocalUnicast()
  28. link, err := t.link.core.link.create(&stream, name, proto, local, remote, incoming, force)
  29. if err != nil {