From 30c6ce1bd0f8b212fa8830ccfef81c0872c008fd Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 1 Dec 2014 23:49:21 -0600 Subject: [PATCH] iplist: Reuse the p2p line regexp --- iplist/iplist.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iplist/iplist.go b/iplist/iplist.go index 4827f871..5467c330 100644 --- a/iplist/iplist.go +++ b/iplist/iplist.go @@ -50,6 +50,8 @@ func (me *IPList) Lookup(ip net.IP) (r *Range) { return } +var p2pBlocklistLineRe = regexp.MustCompile(`(.*):([\d.]+)-([\d.]+)`) + // Parse a line of the PeerGuardian Text Lists (P2P) Format. Returns !ok but // no error if a line doesn't contain a range but isn't erroneous, such as // comment and blank lines. @@ -58,7 +60,7 @@ func ParseBlocklistP2PLine(l string) (r Range, ok bool, err error) { if l == "" || strings.HasPrefix(l, "#") { return } - sms := regexp.MustCompile(`(.*):([\d.]+)-([\d.]+)`).FindStringSubmatch(l) + sms := p2pBlocklistLineRe.FindStringSubmatch(l) if sms == nil { err = fmt.Errorf("error parsing %q", l) return -- 2.48.1