/** * Connect * * @param float timeout default 2.0 * @return bool success * @throws peer.ConnectException */ public function connect($timeout = 2.0) { static $domains = array(AF_INET => 'AF_INET', AF_INET6 => 'AF_INET6', AF_UNIX => 'AF_UNIX'); static $types = array(SOCK_STREAM => 'SOCK_STREAM', SOCK_DGRAM => 'SOCK_DGRAM', SOCK_RAW => 'SOCK_RAW', SOCK_SEQPACKET => 'SOCK_SEQPACKET', SOCK_RDM => 'SOCK_RDM'); if ($this->isConnected()) { return TRUE; } // Short-cuircuit this // Create socket... if (!($this->_sock = socket_create($this->domain, $this->type, $this->protocol))) { $e = new ConnectException(sprintf('Create of %s socket (type %s, protocol %s) failed: %d: %s', $domains[$this->domain], $types[$this->type], getprotobynumber($this->protocol), $e = socket_last_error(), socket_strerror($e))); xp::gc(__FILE__); throw $e; } // Set options foreach ($this->options as $level => $pairs) { foreach ($pairs as $name => $value) { socket_set_option($this->_sock, $level, $name, $value); } } // ... and connection timeouts $origTimeout = $this->getTimeout(); $this->setTimeout($timeout); // ...and connect it switch ($this->domain) { case AF_INET: case AF_INET6: $host = NULL; if ($this->host instanceof InetAddress) { $host = $this->host->asString(); } else { // TBD: Refactor $host = gethostbyname($this->host); } $r = socket_connect($this->_sock, $host, $this->port); break; case AF_UNIX: $r = socket_connect($this->_sock, $this->host); break; } // Reset initial timeout settings $this->setTimeout($origTimeout); // Check return status if (FALSE === $r) { $e = new ConnectException(sprintf('Connect to %s:%d failed: %s', $this->host, $this->port, $this->getLastError())); xp::gc(__FILE__); throw $e; } return TRUE; }
} $json_properties .= "]}"; $json_properties .= "]}]"; break; case "tree_container_2": $services_list = Host_services::get_ip_data($conn, $ip, '1'); if (!is_array($services_list)) { $services_list = array(); } $num_s = count($services_list); $cont = 0; $is_folder = $num_s > 0 ? "true" : "false"; $json_properties = "[{title: '<span>" . _("Services") . "</span>', addClass:'size12', key:'property_8', isFolder:" . $is_folder . ", hideCheckbox: true, icon:'" . $image_url . getPropertyImage('services') . "', children:["; foreach ($services_list as $k => $v) { $cont++; $service_name = "<span class=\\'size12n nagios\\'>" . $v['service'] . "</span><span class=\\'size10n ml3 nagios\\'> (" . $v['port'] . "/" . getprotobynumber($v['protocol']) . ")</span>"; $img_nagios = $v['nagios'] == true ? "nagios_ok" : "nagios_ko"; $select_nagios = $v['nagios'] == true ? "select: true," : ""; $nagios = "<img src=\\'../pixmaps/theme/" . getPropertyImage($img_nagios) . "\\'/>"; $service_key = "nagios_{$cont}###" . $v['port'] . "###" . $img_nagios; $json_properties .= "{ title: '<span>" . $service_name . "</span>', key:'{$service_key}', {$select_nagios} isFolder:true, icon:'" . $image_url . getPropertyImage("") . "', children:["; $json_properties .= "{ title: '<span class=\\'size12n\\'>" . _("Version") . ": </span><span class=\\'ml3 size12b\\'>" . $v['version'] . "</span>', key:'serv_version_" . $cont . "', hideCheckbox: true, isFolder:false, icon:'" . $image_url . getPropertyImage('property') . "'},"; $json_properties .= "{ title: '<span class=\\'size12n\\'>" . _("Date") . ": </span><span class=\\'ml3 size12b\\'> " . $v['date'] . "</span>', key:'serv_date_" . $cont . "', hideCheckbox: true, isFolder:false, icon:'" . $image_url . getPropertyImage('property') . "'},"; $json_properties .= "{ title: '<span class=\\'size12n\\'>" . _("Nagios") . ": </span><span class=\\'ml3 size12b\\'>{$nagios}</span>', hideCheckbox: true, key:'serv_nag_" . $cont . "', isFolder:false, icon:'" . $image_url . getPropertyImage('property') . "'}"; $json_properties .= $num_s == $cont ? "]}" : "]},"; } $json_properties .= "]}]"; break; } $db->close($conn); echo $json_properties;
?> </td> <td><?php echo $Host_services_ip["port"]; ?> </td> <td><?php echo $Host_services_ip["service"] . "/" . getprotobynumber($Host_services_ip["protocol"]) . " [" . $Host_services_ip["version"] . "]"; ?> </td> <td><?php echo $Host_services_ip["date"]; ?> </td> <td><?php echo $Host_services_ip["old_service"] . "/" . getprotobynumber($Host_services_ip["old_protocol"]) . " [" . $Host_services_ip["old_version"] . "]"; ?> </td> <td><?php echo $Host_services_ip["old_date"]; ?> </td> <?php //comprobación protocol version ?> <td><?php echo $delta; ?> </td>
public function protocolName(int $number) : string { return getprotobynumber($number); }
?> " value="<?php echo $services['port']; ?> "></td> </tr> <?php } } } elseif (GET('origin') == 'passive') { if ($services_list = Host_services::get_ip_data($conn, $host, '0')) { foreach ($services_list as $services) { ?> <tr> <td><?php echo $services['service'] . " (" . $services['port'] . "/" . getprotobynumber($services['protocol']) . ")"; ?> </td> <td><?php echo $services['version']; ?> </td> <td><?php echo $services['date']; ?> </td> <td><input type="checkbox" name="port<?php echo $servs; ?> " value="<?php echo $services['port'];
echo $anom_services_ip["sensor"]; ?> ,<?php echo $anom_services_ip["old_date"]; ?> ,<?php echo $anom_services_ip["port"]; ?> " value="<?php echo "ignore" . $anom_services_ip["ip"]; ?> "> </td> <td> <a href="<?php echo "../incidents/newincident.php?ref=Anomaly&anom_type=service&anom_ip=" . $anom_services_ip["ip"] . "&a_sen=" . $anom_services_ip["sensor"] . "[" . $anom_services_ip["interface"] . "]&a_port=" . $anom_services_ip["port"] . "&a_prot=" . getprotobynumber($anom_services_ip["protocol"]) . "&a_ver_o=" . $anom_services_ip["version"] . "&a_prot_o=" . getprotobynumber($anom_services_ip["old_protocol"]) . "&a_ver=" . $anom_services_ip["old_version"] . "&a_date=" . $anom_services_ip["date"] . "&title=Host " . $anom_services_ip["ip"] . " changed protocol/version at port " . $anom_services_ip["port"]; ?> "> <img src="../pixmaps/incident.png" width="12" alt="i" border="0"/> </a> </td> </tr> <?php } } } } } ?> <tr>
public function protocolName($number = 0) { if (!is_numeric($number)) { return Error::set('Error', 'numericParameter', '1.(number)'); } return getprotobynumber($number); }
<thead> <tr> <th>Prudukt</th> <th>Anzahl</th> <th>Status</th> <th>Aktionen</th> </tr> </thead> <tbody> <tr class="odd"> <?php print_r(mysqli_fetch_assoc($order->getProductsToServe($dsatz['b_id']))); while ($dsatz = mysqli_fetch_assoc($order->getProductsToServe($dsatz['b_id']))) { ?> <td><?php getprotobynumber($dsatz['p_id']); ?> </td> <td><?php echo $dsatz['count']; ?> </td> <td><?php echo $dsatz['status']; ?> </td> <td>Fancy Butoons</td> <?php } ?> </tr>
public function format() { $gps_address = \ipLocation::getInstance()->getaddress($this->wan_ip); $wan_gps = \Util::gbkToUtf8($gps_address['area1'] . ' ' . $gps_address['area2']); return array_merge($this->stat->format(), array('l4protocol' => strtoupper(getprotobynumber($this->l4protocol)), 'l7prot' => $this->l7prot, 'lan_ip' => $this->lan_ip, 'wan_ip' => $this->wan_ip, 'lan_port' => $this->lan_port, 'wan_port' => $this->wan_port, 'continue_time' => time() - $this->start_time, 'start_time' => (double) sprintf('%u', $this->start_time), 'wan_gps' => $wan_gps)); }
necho(140, gethostbyaddr('127.0.0.1')); necho(150, gethostbyaddr('216.244.107.14')); necho(160, gethostbyaddr('216.239.59.99')); // dns_check_record --- apparently they do not actually implement this, though it says they do in the manual //necho(180, dns_check_record('kobain.roadsend.com', 'a')); //necho(190, dns_check_record('hendrix.roadsend.com', 'any')); // getprotobyname necho(200, getprotobyname('ip')); necho(210, getprotobyname('tcp')); necho(220, getprotobyname('icmp')); necho(230, getprotobyname('udp')); // getprotobynumber necho(240, getprotobynumber(0)); necho(250, getprotobynumber(1)); necho(260, getprotobynumber(17)); necho(270, getprotobynumber(6)); // getservbyname necho(280, getservbyname('smtp', 'tcp')); necho(290, getservbyname('daytime', 'udp')); necho(300, getservbyname('echo', 'tcp')); necho(310, getservbyname('ssh', 'tcp')); necho(320, getservbyname('foobar', 'udp')); // getservbyport necho(330, getservbyport(19, 'udp')); necho(340, getservbyport(23, 'tcp')); necho(350, getservbyport(7, 'udp')); necho(360, getservbyport(119, 'tcp')); necho(370, getservbyport(123, 'udp')); /* if (PHP_OS != 'WINNT') {
$r[] = '[' . $record['ipv6'] . ']'; } else { if (isset($record['ip'])) { $r[] = $record['ip']; } } } } return $r; } var_dump(gethostname() != false); var_dump(strpos(gethostbyaddr("127.0.0.1"), 'localhost')); var_dump(gethostbyname("localhost")); var_dump(gethostbynamel("localhost")[0]); var_dump(getprotobyname("tcp")); var_dump(getprotobynumber(6)); var_dump(getservbyname("http", "tcp")); var_dump(getservbyport(80, "tcp")); $packed = chr(127) . chr(0) . chr(0) . chr(1); var_dump(inet_ntop($packed)); $packed = str_repeat(chr(0), 15) . chr(1); var_dump(inet_ntop($packed)); $packed = chr(127) . chr(0) . chr(0) . chr(1); var_dump(inet_pton("127.0.0.1")); $packed = str_repeat(chr(0), 15) . chr(1); var_dump(inet_pton("::1")); var_dump(inet_pton("::1")); var_dump(ip2long("127.0.0.1")); var_dump(long2ip(2130706433)); define_syslog_variables(); openlog("TestExtNetwork", LOG_ODELAY, LOG_USER);