Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ parameters:
# parameter_name: value

services:
# service_name:
# class: AppBundle\Directory\ClassName
# arguments: ["@another_service_name", "plain_value", "%parameter_name%"]
scontainer:
class: AppBundle\SContainer
4 changes: 2 additions & 2 deletions src/AppBundle/Controller/LookupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;


Expand All @@ -27,7 +26,8 @@ public function LookupRoute(Request $request) {
* @Route("/lookup/{domain}", name="domain_ip")
*/
public function LookupDomainRoute($domain) {
$d = gethostbyname($domain);
$scontainer = $this->get('scontainer');
$d = $scontainer->hostByName($domain);

return $this->render('lookup/domain.html.twig', ["domain" => $d]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/AppBundle/Controller/WhoIsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;

class WhoIsController extends Controller {
Expand All @@ -25,7 +24,8 @@ public function WhoisRoute(Request $request) {
* @Route("/whois/{ip}", name="ip_domain")
*/
public function WhoisIPRoute($ip) {
$ip = gethostbyaddr($ip);
$scontainer = $this->get('scontainer');
$ip = $scontainer->hostByAddr($ip);

if (filter_var($ip, FILTER_VALIDATE_IP)) {
$ip = 'Failed to find domain name';
Expand Down
23 changes: 23 additions & 0 deletions src/AppBundle/SContainer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace AppBundle;


class SContainer {

/**
* @param string $addr
* @return string
*/
public function hostByAddr($addr) {
return gethostbyaddr($addr);
}

/**
* @param string $name
* @return string
*/
public function hostByName($name) {
return gethostbyName($name);
}
}