From 6de26c5fa5dd821cf44af81c45edd886562f0097 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Apr 2025 22:49:36 +0200 Subject: [PATCH] bring support for simplex links now --- SimpleX/__pycache__/utils.cpython-311.pyc | Bin 0 -> 2621 bytes SimpleX/regex_simplexlinks.py | 3 +- scripts/lantern.py | 6 +- scripts/utils.py | 68 +++++++++++++++++++++- www/header.php | 15 ++++- www/style.css | 12 +++- 6 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 SimpleX/__pycache__/utils.cpython-311.pyc diff --git a/SimpleX/__pycache__/utils.cpython-311.pyc b/SimpleX/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..965119d7a99efa2827cc6676ba307d01b904c161 GIT binary patch literal 2621 zcmb_d-A~(A6u*uW0x={FCWJyiToNFGCh7ND*1@1EQujdD!KTp2+9Ck~kKob{rCAftQAN>u(cr-hh+?tB>~j0`(gDZ}-M&>Igei zjh!il^5FS!dks@>_onmY42POP*LXwVZMPg%)`Gd(5@*1YoBYe>Il286#N5Qeei=r=D}k@J;-u zOnLaR4!0Dlj#ZP{QC0k}nbkxS4rlg>=iJZCgOuj|yu1iAY4ZdU>eA+?W|DcOH&4x@ z1$qL_Q~t)q2^$CPMnnwH$Xs-qQz9ZK#Ao?v%$MLXKkMhBGRJdsyc89K}O@(D1o*B=P%DQi)1(F!5M#yd~czCH;<67k9vR5=fo{a#=#< z`qLKIMsv$*Z{g&S+B~c^4`-|!t!=B13TH;u*4tX^?F>`0J6}a#M4!*RoLRSb7wz47 zS+)0R_Pz{VV(hO5UJT^?D&y4{Zy6nLI9YPFtxc><#YmZkR=h@|_t4~$7TVuQ5IE!p=f$iN3cyW1Qbs^umlFp_NhC8tn?xO1K z(VRU6XJ|j%hYhBsj3|q1Uz8jzndI*C0a}@cbDzLt%D3BDiy^84~=UkKYnPUA3ib5=c}kf8c~i`vpb=YrzWFcKzZFgG~sm z43;7!1^6ShR3W8@aV5eLsBwTbP6Sp8OCpb9P~jo6bMg35T;#>%mfIx77#YP4pvL|6 zxDhmN0-@8uBA6w^79t2n^~R~Ga6F~}N6J%Em@uxNHYftOlI13Y-F68=CVvAQ0k@Mi z+b#K9ELHG+1}1#)%0GixLjTkw)OSin)?ClZS6nV3ZAdkwmVweolMh)-I?_~ zkGzaz=ncl6k)L0Ec{R(wxSqLg{Ou*CZJjw)WKQK|mGNkdr@(|Z+@4(s7moSfyW7{@ zJ%H9XwCX;qxz7S5oLv6y*z=VIcSly)f)gU(L8C6Gps$-B#^aJv z4ovd+72!@$Mv~k0*JtBGQW6Jn7t8?;ko*7yfQ+I_sA0)?%4QGc%7)7bRBqf*wc;!4 U7 bool: except Exception as e: return False +def IsSimpleXChatroomValid(url: str) -> bool: + """Validate the SimpleX chatroom URL.""" + REQUIRED_SUBSTRING = "#/?v=2-7&smp=smp%3A%2F" + + # Step 1: Check if it starts with http://, https://, or simplex:/ + if url.startswith(('http://', 'https://', 'simplex:/')): + # Step 1.5: If http:// or https://, check for valid clearnet or onion domain + if url.startswith(('http://', 'https://')) and not IsUrlValid(url): + return False + elif not url.startswith('simplex:/'): + return False # Must start with one of the valid protocols + + # Step 2: Check for the presence of the required substring + if REQUIRED_SUBSTRING not in url: + return False # Required substring not found + + # Step 3: Extract the part after "smp=smp%3A%2F" + smp_start = url.find("smp=smp%3A%2F") + if smp_start == -1: + return False # Required substring not found + + smp_start += len("smp=smp%3A%2F") + smp_end = url.find("&", smp_start) + if smp_end == -1: + smp_end = len(url) # Take until the end if no "&" is found + + smp_value = urllib.parse.unquote(url[smp_start:smp_end]) # Decode the URL-encoded string + + # Step 3.5: Check if the smp_value contains a valid hostname + if '@' not in smp_value: + return False # Must contain '@' to separate fingerprint and hostname + + fingerprint, hostname = smp_value.split('@', 1) + if not IsUrlValid(hostname): + return False # Invalid hostname + + # Step 4: Check for the presence of "%2F" in the original URL + if "%2F" not in url: + return False # Required substring not found + + # If all checks pass, return True + return True def IsUrlValid(url:str)->bool: """ Check if url is valid both dark net end clearnet. """ - pattern = re.compile("^[A-Za-z0-9:/.-]+$") + pattern = re.compile(r"^[A-Za-z0-9:/._%-=#?&@]+$") + onion_pattern = re.compile(r"^(\w+:)?(?://)?(\w+\.)?[a-z2-7]{56}\.onion") url = str(url) if len(url) < 4: return False - if url.endswith('.onion'): + if onion_pattern.match(url) is not None: return IsOnionValid(url) else: if not url.__contains__('.'): @@ -109,6 +155,24 @@ def IsUrlValid(url:str)->bool: return True +#def IsUrlValid(url:str)->bool: +# """ +# Check if url is valid both dark net end clearnet. +# """ +# pattern = re.compile("^[A-Za-z0-9:/.-]+$") +# url = str(url) +# if len(url) < 4: +# return False +# if url.endswith('.onion'): +# return IsOnionValid(url) +# else: +# if not url.__contains__('.'): +# return False +# if pattern.fullmatch(url) is None: +# return False +# return True + + def IsStatusValid(status: str)-> bool: """ Checks if status contains only ['YES','NO']. Verbose only if False is returned diff --git a/www/header.php b/www/header.php index 511c606..0e360fb 100644 --- a/www/header.php +++ b/www/header.php @@ -69,8 +69,13 @@ if (!preg_match("~^(?:f|ht)tps?://~i", $data[3])) { echo "

" . '

'; // category is already displayed so skip it (empty cell in category column) } + echo '

' ; // begin the table cell of link title - if($data[4] == "YES"){ + if(str_contains(strtolower($data[1]),'monero' )){ + echo '' . $data[1] . ' | '; // display the category as its the first row with this new category + $oldcatname=$data[1]; + }elseif( str_contains(strtolower($data[1]),'simplex' )){ + echo '' . $data[1] . ' | '; // display the category as its the first row with this new category + $oldcatname=$data[1]; + }else{ echo '' . $data[1] . ' | '; // display the category as its the first row with this new category $oldcatname=$data[1]; } + } } } } diff --git a/www/style.css b/www/style.css index ff7aafd..6c57a03 100644 --- a/www/style.css +++ b/www/style.css @@ -42,7 +42,15 @@ } .sensitivelink{ - color: #fc6e02; + color: #f43602; +} + +.xmr{ + color: #fcab0a; +} + +.sxc{ + color: #0ab7fc; } @@ -229,7 +237,7 @@ h1,h2,h3,p,td{ } .category{ - max-width: 80px; + max-width: 90px; word-wrap: break-word; } .linktitle{