tValidate v3 hidden service addresses in ValidateOnionAddress - tordam - A library for peer discovery inside the Tor network
 (HTM) git clone https://git.parazyd.org/tordam
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit b6eeb8f1d4739b896abddc403c81931f7a797c5f
 (DIR) parent fa9e1a189c8a8f09abce98feefb6ad863ddb58ff
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Wed, 13 Dec 2017 02:48:39 +0100
       
       Validate v3 hidden service addresses in ValidateOnionAddress
       
       Diffstat:
         M pkg/damlib/validate.go              |       8 ++++----
       
       1 file changed, 4 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/pkg/damlib/validate.go b/pkg/damlib/validate.go
       t@@ -14,11 +14,11 @@ import (
        // ValidateOnionAddress matches a string against a regular expression matching
        // a Tor hidden service address. Returns true on success and false on failure.
        func ValidateOnionAddress(addr string) bool {
       -        re, _ := regexp.Compile("^[a-z2-7]{16}\\.onion$")
       -        if len(re.FindString(addr)) != 22 {
       -                return false
       +        re, _ := regexp.Compile("^[a-z2-7](?:.{55}|.{15})\\.onion")
       +        if len(re.FindString(addr)) == 22 || len(re.FindString(addr)) == 62 {
       +                return true
                }
       -        return true
       +        return false
        }
        
        // sanityCheck performs basic sanity checks against the incoming request.