. // // 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 ?> Christian Aurich http://c-aurich.de/wordpress all about my personal interests Wed, 15 Jun 2016 20:21:23 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.5 Brother P-touch QL570 on Raspberry Pi http://c-aurich.de/wordpress/2016/06/brother-p-touch-ql570-on-raspberry-pi/ http://c-aurich.de/wordpress/2016/06/brother-p-touch-ql570-on-raspberry-pi/#comments Wed, 15 Jun 2016 20:21:23 +0000 http://c-aurich.de/wordpress/?p=460 Continue reading "Brother P-touch QL570 on Raspberry Pi"

I just wanted to use a Brother P-touch QL570 printer on a Raspberry Pi that is used as “Desktop PC” replacement for web-based applications.

Here is how to setup the printer:

1. connect the printer to power and to the PI (via USB)

2. install cups and the printer driver on the pi:
sudo apt-get install cups printer-driver-ptouch

3. set up user rights:
sudo usermod -aG lpadmin pi
This steps enables you to access cups administration pages in the next step

4. install the printer in cups:
– open a browser and go to http://localhost:631
– when asked for a password use user “pi” and password “raspberry”
– add a new printer, select the QL570 which is locally connected
– use the driver for QL550 when asked for the driver you want to use

5. finish – enjoy printing

http://c-aurich.de/wordpress/2016/06/brother-p-touch-ql570-on-raspberry-pi/feed/ 4
Distinguishing between different FTDI devices http://c-aurich.de/wordpress/2014/05/distinguishing-between-different-ftdi-devices/ http://c-aurich.de/wordpress/2014/05/distinguishing-between-different-ftdi-devices/#respond Thu, 22 May 2014 12:05:12 +0000 http://c-aurich.de/wordpress/?p=449 Continue reading "Distinguishing between different FTDI devices"

Just a short note for myself and everybody who will find this via google 😉

At work I needed to distinguish between five tty devices in linux, which in this case were almost identical FTDI to TTL UART adapters.

I thought of using udev rules for it and give each one a specific name in the file system based on the FTDI device id/serial number. Fortunately I found an easier solution: you can access the device not via /dev/ttyUSB0 through /dev/ttyUSB4 but via /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AD023MTX-if00-port0, which is a symbolic link to the corresponding /dev/ttyUSB*.

To match the tty device to the physical device I needed to collect all serial numbers of the adapters. In the above example this is AD023MTX. I found this serial number out via executing udevadm info –name=/dev/ttyUSB0 –attribute-walk, where you need to look for a line beginning with ATTRS{serial}.

http://c-aurich.de/wordpress/2014/05/distinguishing-between-different-ftdi-devices/feed/ 0
import eagle boards in mechanical CAD drawings http://c-aurich.de/wordpress/2013/02/import-eagle-boards-in-mechanical-cad-drawings/ http://c-aurich.de/wordpress/2013/02/import-eagle-boards-in-mechanical-cad-drawings/#comments Sun, 10 Feb 2013 19:29:20 +0000 http://c-aurich.de/wordpress/?p=423 Continue reading "import eagle boards in mechanical CAD drawings"

Usually you use eagle to design your printed circuit boards (PCBs) only in 2 dimensions (when not considering the layers as 3rd layer). This gives you some headaches for narrow space designs like in small cases.

The common solution until now is to export your board with eagleUp and assemble it with a case in Sketchup. This also gives you some drawbacks. The most important to me was that the Sketchup files are mesh based like the data used for 3D printing usually, but for further use in CAD systems this is not really usable. You also will not be able to get a STEP model that you can give to your costumers out of this data.

Another solution is to use eagle3D, which gives you photorealistic renders of your boards. This images (or even videos) are really good for marketing brochures, but this way makes it impossible for you to play with your 3D models to estimate how much space is left in your case.

The solution I found was to write a macro for FreeCAD that interprets the XML Data that Eagle 6 uses to save your board (the .brd file). This means that my script reads the outline of the pcb and extrudes it with the thickness you specified in eagle. The XML file also contains the names of your parts, which you can map to 3D CAD Models (STEP Models) of them. The last step is to assemble the parts and the board. For more information on how to use it see my github repository.

The only drawback of the freecad solution is that somehow the colors of STEP models get lost – at this time I expect it to be a freecad problem that might be fixed in the future.

The result looks amazing:

Freecad Rendering of Eagle BRD File
Freecad Rendering of Eagle BRD File of I2SEs PLC-REL-M

Thanks to my boss Carsten Ziermann, who allowed me to make changes on the script in my time at work as well as to use the screenshot above.

http://c-aurich.de/wordpress/2013/02/import-eagle-boards-in-mechanical-cad-drawings/feed/ 10
My first 3d print http://c-aurich.de/wordpress/2012/07/my-first-3d-print/ http://c-aurich.de/wordpress/2012/07/my-first-3d-print/#comments Tue, 31 Jul 2012 05:00:55 +0000 http://c-aurich.de/wordpress/?p=415 Continue reading "My first 3d print"

Yeeehaaa – I finaly got my first 3d print that was not totally messed up.

I had a lot of experimenting with the belt tension and the endless settings for the slicer software. But finally I got it working. The printquality is not perfect – but I will tune it later for a better print quality. When I have final settings they will be published – but this might take some more time 😉


first 3d print result

For those who do not know 3d printing well: the layer below the cylinder is called “raft” and it is used to get an flat surface where you can print at. The second use of this is to prevent the printed object to stick to much to the printing platform.

http://c-aurich.de/wordpress/2012/07/my-first-3d-print/feed/ 3
Building a current / flux probe for contactless measurements http://c-aurich.de/wordpress/2012/04/building-a-current-flux-probe-for-contactless-measurements/ http://c-aurich.de/wordpress/2012/04/building-a-current-flux-probe-for-contactless-measurements/#respond Mon, 23 Apr 2012 21:02:00 +0000 http://c-aurich.de/wordpress/?p=401 Continue reading "Building a current / flux probe for contactless measurements"

In the last weeks I followed an idea to measure current without the need to cut the wires or even open a pcb trace. The solution i came up with is a hall effect based measurement.

I wrote some more about it in an article here: http://avrs-at-leipzig.de/dokuwiki/en/prokekte/fluxprobe

If you do not like to open the full arcitle here you can review the basic schematic as well as to see a foto of my first prototype:

schematic of the prototype
Foto of my prototype

The first but still impressing measurement:

flux probe measurement at 10Hz
flux probe measurement at 10Hz, 10ms/div, red: output of probe at 200mV/div, yellow current at 33,3mA/div
http://c-aurich.de/wordpress/2012/04/building-a-current-flux-probe-for-contactless-measurements/feed/ 0
Self driving car – Take 1 http://c-aurich.de/wordpress/2012/04/self-driving-car-take-1/ http://c-aurich.de/wordpress/2012/04/self-driving-car-take-1/#respond Sun, 22 Apr 2012 21:24:54 +0000 http://c-aurich.de/wordpress/?p=408 Continue reading "Self driving car – Take 1"


The following video shows the first quasi autonomous movements of my 1:8 sized buggy. I wrote a little script that makes movements suitable for turning the car.  I had no space in my flat for letting it run right now so I stuck with the ‘dry run’ for now. After adding some more sensors I will replace the script to be event driven instead of timer based.

The electronic components are: Toradex Colibri T20 on an Iris carier board running Linux (I got that one at embedded world this year) and an Arduino for controlling the servos. There also is a DC motor controller for driving the wheels that came with the car.

http://c-aurich.de/wordpress/2012/04/self-driving-car-take-1/feed/ 0
Finishing the construction of my 3D Printer http://c-aurich.de/wordpress/2012/04/finishing-the-construction-of-my-3d-printer/ http://c-aurich.de/wordpress/2012/04/finishing-the-construction-of-my-3d-printer/#comments Tue, 17 Apr 2012 21:37:49 +0000 http://c-aurich.de/wordpress/?p=405 Continue reading "Finishing the construction of my 3D Printer"

Over the weekend I finished the mechanical work on my 3d printer. It now has all parts assembled. It took a long time because the seller needed two more tries to deliver all missing parts. But finally I got all parts plus a few bonus parts. Thanks for that to John from seemecnc.com!

As in my last post I have shot timelapse videos to show you the progress:

I connected all the motors, the heater and the thermosensor to the printer. Surprisingly all the axes were working instandly. Unfortunately the heater and the sensor were not working at all and the stepsize of the motors seem not to fit. Als I have to attach the end stop sensors to the printer for the Gen6 hardware… This means it will take some more time until I finally can print 😉

http://c-aurich.de/wordpress/2012/04/finishing-the-construction-of-my-3d-printer/feed/ 2
SeeMeCNC construction http://c-aurich.de/wordpress/2012/03/seemecnc-construction/ http://c-aurich.de/wordpress/2012/03/seemecnc-construction/#comments Wed, 07 Mar 2012 15:56:04 +0000 http://c-aurich.de/wordpress/?p=391 Continue reading "SeeMeCNC construction"

Yesterday I was coming home and a parcel from the USA was waiting for me – It was of course the kit of my 3D printer 🙂 I could not wait a second to start building it up. So here we are – the video shows about 8h in 3:20 minutes.

At some points you can see me confused for some time and putting unfinished modules aside. This is because a few parts were missing… John got back to me over the night and promised to send the missing parts out today. Well, that means I will wait for these parts to arrive for one or two weeks. In this time I can also order some other missing things like plugs for the motors and glue to hold the temperature sensor in place.

Here is a picture of the machine how it is looking at the moment – without any adjustments because I will have to take some parts out again:

SeeMeCNC H1, half built up
http://c-aurich.de/wordpress/2012/03/seemecnc-construction/feed/ 1
day 3 of embedded world http://c-aurich.de/wordpress/2012/03/day-3-of-embedded-world/ http://c-aurich.de/wordpress/2012/03/day-3-of-embedded-world/#respond Thu, 01 Mar 2012 19:46:01 +0000 http://c-aurich.de/wordpress/?p=388 Continue reading "day 3 of embedded world"


The final day of the exhibition “embedded world” was a bit less exhausting. We spend some time speaking to the people of the stand linux meets industry. This organisation is supporting big companies running and developing open source software as well as spreading the open source thinking.

The rest of my day was quite relaxed… we walked around a bit and talked to several companies as well as some people who were interested in the project leobots.

All in all the exhibition was a big success for the team as well as for me. We all got some great impressions what the embedded industry is like at the moment.

http://c-aurich.de/wordpress/2012/03/day-3-of-embedded-world/feed/ 0
day 2 of embedded world http://c-aurich.de/wordpress/2012/02/day-2-of-embedded-world/ http://c-aurich.de/wordpress/2012/02/day-2-of-embedded-world/#respond Wed, 29 Feb 2012 22:09:58 +0000 http://c-aurich.de/wordpress/?p=382 Continue reading "day 2 of embedded world"

source: http://www.embedded-world.de/de/presse/mediacenter/download/

Today I spoke to some companies that I might work for in saxony. There are quite a lot of them, that I did not know before or I did not know that they also develop hardware themselves. This is why today was a great success for me. But on the other hand the days get more and more exhausting – fortunately the exhibition ends one hour earlier tomorrow. I’m very tired right now…

After the official end of the visitor opening times there were some parties at the microsoft and ebv stand among others. Thanks to them for providing some food and drinks for us while playing music! Also thanks to the “open source meets industry” guys who are always worth talking to! Especially I was enjoying to meet Benedikt Sauter (http://embedded-projects.net/) finally after following his work since several years now.

One thing I want to show you finally is an automatic solver for the rubik cube. Basically they built a lego mindstorms robot that handles all the turning and used a smartphone to capture the recent state of the cube. These two elements are combined by a pc that solves the game and controlls the robot while capturing the images form the smartphone:

http://c-aurich.de/wordpress/2012/02/day-2-of-embedded-world/feed/ 0