mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Allow to determine if remote addresses should be obfuscated at configuration level
This commit is contained in:
@@ -12,6 +12,7 @@ return [
|
|||||||
'hostname' => '',
|
'hostname' => '',
|
||||||
],
|
],
|
||||||
'validate_url' => false,
|
'validate_url' => false,
|
||||||
|
'obfuscate_remote_addr' => true,
|
||||||
'visits_webhooks' => [],
|
'visits_webhooks' => [],
|
||||||
'default_short_codes_length' => DEFAULT_SHORT_CODES_LENGTH,
|
'default_short_codes_length' => DEFAULT_SHORT_CODES_LENGTH,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -54,7 +54,11 @@ return [
|
|||||||
Options\UrlShortenerOptions::class => ['config.url_shortener'],
|
Options\UrlShortenerOptions::class => ['config.url_shortener'],
|
||||||
|
|
||||||
Service\UrlShortener::class => [Util\UrlValidator::class, 'em', Resolver\PersistenceDomainResolver::class],
|
Service\UrlShortener::class => [Util\UrlValidator::class, 'em', Resolver\PersistenceDomainResolver::class],
|
||||||
Service\VisitsTracker::class => ['em', EventDispatcherInterface::class],
|
Service\VisitsTracker::class => [
|
||||||
|
'em',
|
||||||
|
EventDispatcherInterface::class,
|
||||||
|
'config.url_shortener.obfuscate_remote_addr',
|
||||||
|
],
|
||||||
Service\ShortUrlService::class => ['em', Service\ShortUrl\ShortUrlResolver::class, Util\UrlValidator::class],
|
Service\ShortUrlService::class => ['em', Service\ShortUrl\ShortUrlResolver::class, Util\UrlValidator::class],
|
||||||
Visit\VisitLocator::class => ['em'],
|
Visit\VisitLocator::class => ['em'],
|
||||||
Visit\VisitsStatsHelper::class => ['em'],
|
Visit\VisitsStatsHelper::class => ['em'],
|
||||||
|
|||||||
@@ -22,11 +22,16 @@ class VisitsTracker implements VisitsTrackerInterface
|
|||||||
{
|
{
|
||||||
private ORM\EntityManagerInterface $em;
|
private ORM\EntityManagerInterface $em;
|
||||||
private EventDispatcherInterface $eventDispatcher;
|
private EventDispatcherInterface $eventDispatcher;
|
||||||
|
private bool $obfuscateRemoteAddr;
|
||||||
|
|
||||||
public function __construct(ORM\EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher)
|
public function __construct(
|
||||||
{
|
ORM\EntityManagerInterface $em,
|
||||||
|
EventDispatcherInterface $eventDispatcher,
|
||||||
|
bool $obfuscateRemoteAddr
|
||||||
|
) {
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
|
$this->obfuscateRemoteAddr = $obfuscateRemoteAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +39,7 @@ class VisitsTracker implements VisitsTrackerInterface
|
|||||||
*/
|
*/
|
||||||
public function track(ShortUrl $shortUrl, Visitor $visitor): void
|
public function track(ShortUrl $shortUrl, Visitor $visitor): void
|
||||||
{
|
{
|
||||||
$visit = new Visit($shortUrl, $visitor);
|
$visit = new Visit($shortUrl, $visitor, $this->obfuscateRemoteAddr);
|
||||||
|
|
||||||
$this->em->persist($visit);
|
$this->em->persist($visit);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class VisitsTrackerTest extends TestCase
|
|||||||
$this->em = $this->prophesize(EntityManager::class);
|
$this->em = $this->prophesize(EntityManager::class);
|
||||||
$this->eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
|
$this->eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
|
||||||
|
|
||||||
$this->visitsTracker = new VisitsTracker($this->em->reveal(), $this->eventDispatcher->reveal());
|
$this->visitsTracker = new VisitsTracker($this->em->reveal(), $this->eventDispatcher->reveal(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
|
|||||||
Reference in New Issue
Block a user