From dbfb9e2716c1f7ac6db92236bdb8a8387c196df0 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Wed, 17 Nov 2021 09:10:52 -0400 Subject: [PATCH] fix: remove dup function --- waku/v2/node/wakunode2.go | 44 --------------------------------------- 1 file changed, 44 deletions(-) diff --git a/waku/v2/node/wakunode2.go b/waku/v2/node/wakunode2.go index a7ad1c41..5200f065 100644 --- a/waku/v2/node/wakunode2.go +++ b/waku/v2/node/wakunode2.go @@ -73,26 +73,6 @@ type WakuNode struct { connStatusChan chan ConnStatus } -func freePort() (int, error) { - addr, err := net.ResolveTCPAddr("tcp", "localhost:0") - if err != nil { - return 0, err - } - - l, err := net.ListenTCP("tcp", addr) - if err != nil { - return 0, err - } - - port := l.Addr().(*net.TCPAddr).Port - err = l.Close() - if err != nil { - return 0, err - } - - return port, nil -} - func New(ctx context.Context, opts ...WakuNodeOption) (*WakuNode, error) { params := new(WakuNodeParameters) @@ -191,30 +171,6 @@ func (w *WakuNode) onAddrChange() { } } -// IsPrivate reports whether ip is a private address, according to -// RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses). -// Copied/Adapted from https://go-review.googlesource.com/c/go/+/272668/11/src/net/ip.go -// Copyright (c) The Go Authors. All rights reserved. -// @TODO: once Go 1.17 is released in Q42021, remove this function as it will become part of the language -func IsPrivate(ip net.IP) bool { - if ip4 := ip.To4(); ip4 != nil { - // Following RFC 4193, Section 3. Local IPv6 Unicast Addresses which says: - // The Internet Assigned Numbers Authority (IANA) has reserved the - // following three blocks of the IPv4 address space for private internets: - // 10.0.0.0 - 10.255.255.255 (10/8 prefix) - // 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) - // 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) - return ip4[0] == 10 || - (ip4[0] == 172 && ip4[1]&0xf0 == 16) || - (ip4[0] == 192 && ip4[1] == 168) - } - // Following RFC 4193, Section 3. Private Address Space which says: - // The Internet Assigned Numbers Authority (IANA) has reserved the - // following block of the IPv6 address space for local internets: - // FC00:: - FDFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF (FC00::/7 prefix) - return len(ip) == net.IPv6len && ip[0]&0xfe == 0xfc -} - func (w *WakuNode) checkForAddressChanges() { addrs := w.ListenAddresses() first := make(chan struct{}, 1)