mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
fix yggdrasil host validation
This commit is contained in:
parent
e3f312f6f3
commit
f3896534ae
7 changed files with 28 additions and 29 deletions
|
|
@ -110,7 +110,7 @@ define('COMMENT_MIN_LENGTH', 1);
|
||||||
define('COMMENT_MAX_LENGTH', 1000);
|
define('COMMENT_MAX_LENGTH', 1000);
|
||||||
|
|
||||||
// Yggdrasil
|
// Yggdrasil
|
||||||
define('YGGDRASIL_URL_REGEX', '/^0{0,1}[2-3][a-f0-9]{0,2}:/'); // thanks to @ygguser (https://github.com/YGGverse/YGGo/issues/1#issuecomment-1498182228 )
|
define('YGGDRASIL_HOST_REGEX', '/^0{0,1}[2-3][a-f0-9]{0,2}:/'); // thanks to @ygguser (https://github.com/YGGverse/YGGo/issues/1#issuecomment-1498182228 )
|
||||||
|
|
||||||
// Crawler
|
// Crawler
|
||||||
define('CRAWLER_SCRAPE_QUEUE_LIMIT', 1);
|
define('CRAWLER_SCRAPE_QUEUE_LIMIT', 1);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
case 'jidenticon':
|
case 'jidenticon':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -85,7 +85,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
case 'approved':
|
case 'approved':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -166,7 +166,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
case 'public':
|
case 'public':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -236,7 +236,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
case 'new':
|
case 'new':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -329,7 +329,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
case 'star':
|
case 'star':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -396,7 +396,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
case 'download':
|
case 'download':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -489,7 +489,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$uri->value)));
|
$uri->value)));
|
||||||
|
|
||||||
// Yggdrasil url only
|
// Yggdrasil url only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $url))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -521,7 +521,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$uri->value)));
|
$uri->value)));
|
||||||
|
|
||||||
// Yggdrasil url only
|
// Yggdrasil url only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $url))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -547,7 +547,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
$uri->value)));
|
$uri->value)));
|
||||||
|
|
||||||
// Yggdrasil url only
|
// Yggdrasil url only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $url))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -567,7 +567,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
case 'new':
|
case 'new':
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -659,7 +659,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
{
|
{
|
||||||
if ($url = Yggverse\Parser\Url::parse($tr))
|
if ($url = Yggverse\Parser\Url::parse($tr))
|
||||||
{
|
{
|
||||||
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
if (preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
||||||
{
|
{
|
||||||
$db->initMagnetToAddressTrackerId(
|
$db->initMagnetToAddressTrackerId(
|
||||||
$magnetId,
|
$magnetId,
|
||||||
|
|
@ -685,7 +685,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
{
|
{
|
||||||
if ($url = Yggverse\Parser\Url::parse($as))
|
if ($url = Yggverse\Parser\Url::parse($as))
|
||||||
{
|
{
|
||||||
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
if (preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
||||||
{
|
{
|
||||||
$db->initMagnetToAcceptableSourceId(
|
$db->initMagnetToAcceptableSourceId(
|
||||||
$magnetId,
|
$magnetId,
|
||||||
|
|
@ -705,7 +705,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||||
{
|
{
|
||||||
if ($url = Yggverse\Parser\Url::parse($xs))
|
if ($url = Yggverse\Parser\Url::parse($xs))
|
||||||
{
|
{
|
||||||
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
if (preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
||||||
{
|
{
|
||||||
$db->initMagnetToExactSourceId(
|
$db->initMagnetToExactSourceId(
|
||||||
$magnetId,
|
$magnetId,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ $response = (object)
|
||||||
];
|
];
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
@ -123,8 +123,8 @@ $response = (object)
|
||||||
$host->value,
|
$host->value,
|
||||||
$uri->value)));
|
$uri->value)));
|
||||||
|
|
||||||
// Yggdrasil url only
|
// Yggdrasil host only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $host->value)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -154,9 +154,8 @@ $response = (object)
|
||||||
$uri->value) : sprintf('%s://%s%s', $scheme->value,
|
$uri->value) : sprintf('%s://%s%s', $scheme->value,
|
||||||
$host->value,
|
$host->value,
|
||||||
$uri->value)));
|
$uri->value)));
|
||||||
|
// Yggdrasil host only
|
||||||
// Yggdrasil url only
|
if (!preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $host->value)))
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -181,8 +180,8 @@ $response = (object)
|
||||||
$host->value,
|
$host->value,
|
||||||
$uri->value)));
|
$uri->value)));
|
||||||
|
|
||||||
// Yggdrasil url only
|
// Yggdrasil host only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $url))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $host->value)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ $response = (object)
|
||||||
];
|
];
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required to enable resource features');
|
$response->message = _('Yggdrasil connection required to enable resource features');
|
||||||
|
|
@ -370,7 +370,7 @@ else {
|
||||||
{
|
{
|
||||||
if ($url = Yggverse\Parser\Url::parse($tr))
|
if ($url = Yggverse\Parser\Url::parse($tr))
|
||||||
{
|
{
|
||||||
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
if (preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
||||||
{
|
{
|
||||||
$db->initMagnetToAddressTrackerId(
|
$db->initMagnetToAddressTrackerId(
|
||||||
$magnet->magnetId,
|
$magnet->magnetId,
|
||||||
|
|
@ -406,7 +406,7 @@ else {
|
||||||
{
|
{
|
||||||
if ($url = Yggverse\Parser\Url::parse($as))
|
if ($url = Yggverse\Parser\Url::parse($as))
|
||||||
{
|
{
|
||||||
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
if (preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
||||||
{
|
{
|
||||||
$db->initMagnetToAcceptableSourceId(
|
$db->initMagnetToAcceptableSourceId(
|
||||||
$magnet->magnetId,
|
$magnet->magnetId,
|
||||||
|
|
@ -442,7 +442,7 @@ else {
|
||||||
{
|
{
|
||||||
if ($url = Yggverse\Parser\Url::parse($xs))
|
if ($url = Yggverse\Parser\Url::parse($xs))
|
||||||
{
|
{
|
||||||
if (preg_match(YGGDRASIL_URL_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
if (preg_match(YGGDRASIL_HOST_REGEX, str_replace(['[',']'], false, $url->host->name)))
|
||||||
{
|
{
|
||||||
$db->initMagnetToExactSourceId(
|
$db->initMagnetToExactSourceId(
|
||||||
$magnet->magnetId,
|
$magnet->magnetId,
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ $response = (object)
|
||||||
];
|
];
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required to enable resource features');
|
$response->message = _('Yggdrasil connection required to enable resource features');
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ $response = (object)
|
||||||
];
|
];
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required to enable resource features');
|
$response->message = _('Yggdrasil connection required to enable resource features');
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ $response = (object)
|
||||||
];
|
];
|
||||||
|
|
||||||
// Yggdrasil connections only
|
// Yggdrasil connections only
|
||||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
if (!preg_match(YGGDRASIL_HOST_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||||
{
|
{
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = _('Yggdrasil connection required for this action');
|
$response->message = _('Yggdrasil connection required for this action');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue