///////////////////////////////////////////////////////////////////////////
//
// DNSBL - Spam IP address checker.
// Copyright (C) 2011 Alexey A.Znayev
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// Alexey A.Znayev, znaeff@mail.ru, http://xbsoft.org, http://xbsoft.ru
//
///////////////////////////////////////////////////////////////////////////
// This file contains public class DNSBL
// This class performs IP address check in spam blocking lists as described
// on http://ru.wikipedia.org/wiki/RBL
class DNSBL {
private $_aCheckers = array( // list of checkers available for individual checking
'spamhaus' => array('.zen.spamhaus.org', true), //available for group checking with 'all' key
'spamcop' => array('.bl.spamcop.net', true), //available for group checking with 'all' key
'dsbl' => array('.list.dsbl.org', false), //not available for group checking with 'all' key
'ordb' => array('.relays.ordb.org', false), //not available for group checking with 'all' key
'sorbs' => array('.dnsbl.sorbs.net', false), //not available for group checking with 'all' key
'njabl' => array('.dnsbl.njabl.org', false) //not available for group checking with 'all' key
); // AZ - 1. Key 'all' is illegal
// AZ - 2. Most of spammer IP addresses is covered by 'spamhaus' & 'spamcop' (and they are fast),
// some of the rest may not work sometimes, you can make them group checking available after individual testing
private $_sDefaultChecker = 'spamhaus';
///////////////////////////////////////////////////////////////////////////
// CheckSpamIP - check IP for spam in checkers : given, default or all available for group checking (may be slow)
// parameters:
// string $ip - ip address
// string $checker - checker name or 'all' or nothing
// returns:
// true when IP exitsts in spam-lists of $checker or at least one of all checkers
// false when not or when ip address is local or not correct
public function CheckSpamIP($ip, $checker = ''){
if(empty($ip)) return false;
if(preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $ip) != 1) return false;
$octets = explode('.', $ip);
if($octets[0] == '127') return false;
if($octets[0] == '10') return false;
if($octets[0] == '192' && $octets[0] == '168') return false;
if($octets[0] == '169' && $octets[0] == '254') return false; // ms windows
if((int)$octets[0] > 255 || (int)$octets[1] > 255 || (int)$octets[2] > 255 || (int)$octets[3] > 255 ) return false;
$ret_val = false;
$PTR = implode(array_reverse($octets), '.');
if($checker === 'all'){
foreach(array_values($this->_aCheckers) as $c){
if($c[1]){
$ret_val = $ret_val || $this->_CheckDNSAnswer(dns_get_record($PTR . $c[0], DNS_A));
}
if($ret_val) break;
}
}else if(array_key_exists($checker, $this->_aCheckers)){
$ret_val = $this->_CheckDNSAnswer(dns_get_record($PTR . $this->_aCheckers[$checker][0], DNS_A));
}else{
$ret_val = $this->_CheckDNSAnswer(dns_get_record($PTR . $this->_aCheckers[$this->_sDefaultChecker][0], DNS_A));
}
return $ret_val;
}
///////////////////////////////////////////////////////////////////////////
// GetCheckers - gets list of available checker names
// returns:
// array of strings
public function GetCheckers(){
return array_keys($this->_aCheckers);
}
///////////////////////////////////////////////////////////////////////////
// GetGroupCheckers - gets list of checker names available for group checking with 'all' key
// returns:
// array of strings
public function GetGroupCheckers(){
$ret_val = array();
foreach(array_keys($this->_aCheckers) as $k) if($this->_aCheckers[$k][1]) array_push($ret_val, $k);
return $ret_val;
}
///////////////////////////////////////////////////////////////////////////
// GetDefaultChecker - gets default checker name
// returns:
// string
public function GetDefaultChecker(){
return $this->_sDefaultChecker;
}
///////////////////////////////////////////////////////////////////////////
// SetDefaultChecker - sets default checker name
// parameters:
// string $new_checker - new default checker name
// returns:
// true when success
// false when failed ($new_checker is not in the list of available checker names)
public function SetDefaultChecker($new_checker){
if(array_key_exists($new_checker, $this->_aCheckers)){
$this->_sDefaultChecker = $new_checker;
return true;
}else{
return false;
}
}
///////////////////////////////////////////////////////////////////////////
// EnableGroupChecking - sets checker available for group checking
// parameters:
// string $checker - checker name
// returns:
// true when success ($checker is included)
// false when failed ($checker is not in the list of available checker names)
public function EnableGroupChecking($checker){
if(array_key_exists($checker, $this->_aCheckers)){
$this->_aCheckers[$checker][1] = true;
return true;
}else{
return false;
}
}
///////////////////////////////////////////////////////////////////////////
// DisableGroupChecking - sets checker not available for group checking
// parameters:
// string $checker - checker name
// returns:
// true when success ($checker is excluded)
// false when failed ($checker is not in the list of available checker names)
public function DisableGroupChecking($checker){
if(array_key_exists($checker, $this->_aCheckers)){
$this->_aCheckers[$checker][1] = false;
return true;
}else{
return false;
}
}
// private methods
///////////////////////////////////////////////////////////////////////////
// _CheckDNSAnswer - checks DNS-server answer for 127.0.0.* values
// returns:
// true when success
// false when failed
private function _CheckDNSAnswer($dns_answer){
if(!is_array($dns_answer)) return false;
$len = count($dns_answer);
if($len <= 0) return false;
for($i=0; $i<$len; $i++){
$obj = $dns_answer[$i];
if(!(is_object($obj) || is_array($obj))) return false;
$ip_str = $obj['ip'];
if(!is_string($ip_str)) return false;
$pos = strpos($ip_str, '127.0.0.');
if($pos !== false) return true;
}
return false;
}
} // end of class DNSBL
?>
Alpine Linux – bits and pieces
https://blog.fabian-affolter.ch
primary Fedora and some negligibilities...hauptsächlich Fedora und ein paar Nebensächlichkeiten...Sun, 24 Sep 2023 10:11:42 +0000en-UShourly1https://wordpress.org/?v=4.9.25Alpine 3.9.0 released
https://blog.fabian-affolter.ch/alpine-3-9-0-released/
https://blog.fabian-affolter.ch/alpine-3-9-0-released/#respondWed, 30 Jan 2019 04:45:09 +0000http://fabian-affolter.ch/blog/?p=3715
There is now support for armv7 and it’s again OpenSSL instead of LibreSSL.
]]>
https://blog.fabian-affolter.ch/alpine-3-9-0-released/feed/0Alpine Linux 3.6.0 released
https://blog.fabian-affolter.ch/alpine-linux-3-6-0-released/
https://blog.fabian-affolter.ch/alpine-linux-3-6-0-released/#respondWed, 24 May 2017 21:35:06 +0000http://fabian-affolter.ch/blog/?p=3484Continue reading →]]>The Alpine Linux Project is pleased to announce the immediate availability of version 3.6.0 of its Alpine Linux operating system.
Support for 64-bit little-endian POWER machines (ppc64le) and for64-bit IBM z Systems (s390x) is now included.
]]>https://blog.fabian-affolter.ch/alpine-linux-3-6-0-released/feed/0Package for Fedora and Alpine Linux
https://blog.fabian-affolter.ch/package-for-fedora-and-alpine-linux/
https://blog.fabian-affolter.ch/package-for-fedora-and-alpine-linux/#respondWed, 09 Nov 2016 10:54:24 +0000http://fabian-affolter.ch/blog/?p=3398Continue reading →]]>Home Assistant ships its own management logic for the dependencies. This works pretty well and keep the dependency tree minimal. Usually it doesn’t make sense to install the binding for X if you don’t use X. The issue here is that there are modules which requires compiling c extensions and this is time-consuming.
The idea is now to use as many dependencies as possible through the distribution’s package management system. Especially netifaces or the whole Z-Wave stuff. This way the installation is faster and the modules are system-wide available.
]]>https://blog.fabian-affolter.ch/package-for-fedora-and-alpine-linux/feed/0Alpine Linux 3.3.1 released
https://blog.fabian-affolter.ch/alpine-linux-3-3-1-released/
https://blog.fabian-affolter.ch/alpine-linux-3-3-1-released/#respondThu, 07 Jan 2016 10:26:23 +0000http://fabian-affolter.ch/blog/?p=3248Continue reading →]]>The Alpine Linux Project is pleased to announce the immediate availability of version 3.3.1 of its Alpine Linux operating system.
This is a bugfix release of the v3.3 musl based branch. Main focus of this release is fixing regressions related to specific boot environments.
]]>https://blog.fabian-affolter.ch/alpine-linux-3-3-1-released/feed/0Alpine Linux 3.3.0 released
https://blog.fabian-affolter.ch/alpine-linux-3-3-0-released/
https://blog.fabian-affolter.ch/alpine-linux-3-3-0-released/#respondSat, 19 Dec 2015 21:26:06 +0000http://fabian-affolter.ch/blog/?p=3247Continue reading →]]>The Alpine Linux Project is pleased to announce Alpine Linux 3.3.0, the first release in v3.3 stable series.
The ISO images have been renamed. Current images are now:
alpine (previously ‘alpine-mini’). Minimalisitic boot media for network access.
alpine-vanilla (same as before). Same as ‘alpine’ but with vanilla kernel.
alpine-extended (previously ‘alpine’). Same as ‘alpine’ but with slightly more packages available in the repository. Handy where network access is limited.
alpine-xen (same as before). Boot media for Xen Dom 0.
refactored initramfs. alpine_dev boot option no longer needed and better support for cryptroot, lvm, mdadm.
]]>https://blog.fabian-affolter.ch/alpine-linux-3-3-0-released/feed/0Alpine Linux 3.2.3 released
https://blog.fabian-affolter.ch/alpine-linux-3-2-3-released/
https://blog.fabian-affolter.ch/alpine-linux-3-2-3-released/#respondFri, 14 Aug 2015 19:27:15 +0000http://fabian-affolter.ch/blog/?p=3186Continue reading →]]>The Alpine Linux Project is pleased to announce Alpine Linux 3.2.3.
This is a bugfix release of the v3.2 musl based branch. This release is based on the 3.18.20 kernel which has some critical security fixes.
]]>https://blog.fabian-affolter.ch/alpine-linux-3-2-3-released/feed/0Alpine Linux stats
https://blog.fabian-affolter.ch/alpine-linux-stats/
https://blog.fabian-affolter.ch/alpine-linux-stats/#respondThu, 30 Jul 2015 06:37:37 +0000http://fabian-affolter.ch/blog/?p=3166A bit late…the basic statistics about the Alpine Linux packages are now up-to-date.
]]>https://blog.fabian-affolter.ch/alpine-linux-stats/feed/0Alpine Linux 3.2.2 released
https://blog.fabian-affolter.ch/alpine-linux-3-2-2-released/
https://blog.fabian-affolter.ch/alpine-linux-3-2-2-released/#respondWed, 15 Jul 2015 17:26:32 +0000http://fabian-affolter.ch/blog/?p=3162Continue reading →]]>The Alpine Linux Project is pleased to announce Alpine Linux 3.2.2.
This is a bugfix release of the v3.2 musl based branch. This release is based on the 3.18.18 kernel which has some critical security fixes.
]]>https://blog.fabian-affolter.ch/alpine-linux-3-2-2-released/feed/0Alpine Linux 3.1.4 released
https://blog.fabian-affolter.ch/alpine-linux-3-1-4-released/
https://blog.fabian-affolter.ch/alpine-linux-3-1-4-released/#respondFri, 15 May 2015 05:59:41 +0000http://fabian-affolter.ch/blog/?p=3130Continue reading →]]>The Alpine Linux Project is pleased to announce Alpine Linux 3.1.4.
This is a bugfix release of the v3.1 musl based branch. This release is based on the 3.14.41 kernel which has some critical security fixes.
]]>https://blog.fabian-affolter.ch/alpine-linux-3-1-4-released/feed/0Alpine Linux 3.1.3 released
https://blog.fabian-affolter.ch/alpine-linux-3-1-3-released/
https://blog.fabian-affolter.ch/alpine-linux-3-1-3-released/#respondSat, 21 Mar 2015 10:24:24 +0000http://fabian-affolter.ch/blog/?p=3124Continue reading →]]>The Alpine Linux Project is pleased to announce Alpine Linux 3.1.3.
This is a bugfix release of the v3.1 musl based branch. This release is based on the 3.14.36 kernel which has some critical security fixes.