Cups And Easy Printer Sharing

22 Apr 2014 20:53

Today I decided I want to share an USB printer via CUPS. This has always been fun and easy thing to do.

After spending some time figuring out why this doesn't work out of the box, I learned most of the tutorials are not right about one thing. They claim to share the network in the same (sub)network you don't need any special configuration on the client. That's wrong. You need to install cups-browsed package on the client:

sudo apt-get install cups-browsed

Then you just wait 30 seconds and you're remote printers should appear in http://localhost:631/printers

If you want to print from a different network (or your stupid router doesn't bridge Wifi and Ethernet networks) you may need to add a line like that:

BrowsePoll server-name

to the /etc/cups/cups-browsed.conf file.

An update: actually BrowsePoll server-name doesn't seem to work. I needed to replace the server name with the server IP address.

Comments: 0

Flash I Silverlight

16 Mar 2014 20:18

Z Flashem do niedawna było całkiem nieźle. Wsparcie dla Linuksa było. Paczki w apcie były. W miarę działało. Silverlight był gorszy. Niby był moonlight, ale nigdy nie działał akurat z tymi stronami co się chciało.

Teraz Flash na Linuksa dostępny jest tylko w wersji 11. Jak chcesz wersję 12, to musisz mieć Chrome'a. Można jakimś hakiem wyciągnąć z Chrome'a samą wtyczkę i wrzucić do Chromium, ale to już trochę bez sensu.

Natomiast o Moonlighcie to już chyba wszyscy zapomnieli. Przekierowanie ze strony Microsoftu (gdzie kierują strony "brak wtyczki) prowadzi do 404-ki, w apcie susza, w sumie nie wiadomo co robić.

Ale dzisiaj odkryłem rozwiązanie obu problemów. Nazywa się ono pipelight. Jest to sprytna biblioteka instalująca Windowsowe wtyczki do przeglądarek jako wtyczki do przeglądarek na Linuksie, np. Firefoksa. Korzysta to z wine'a i sprawdziłem, że działa. Zarówno Silverlight jak i Flash 12 odtąd działa elegancko. Przynajmniej do oglądania filmów i transmisji na żywo. Obsługa kamerki w tej "wersji" Flasha nie działa.

Comments: 0

Useful oneliner to set your DNS to Google

12 Feb 2014 18:11

This thing eases things a lot when you deal with crappy internet connection (airport, AirBNB etc).


echo nameserver | sudo tee /etc/resolv.conf > /dev/null

Comments: 0

Ad Filtering On Adroid Phones

06 Apr 2012 21:44

Recently I installed a CM9-based Ice Cream Sandwitch ROM on my HTC Desire and it's cool, but I found one thing extremely frustrating: the ads. They are everywhere and slow things down. I haven't noticed them before, because I always used AdAway (and AdFree before that), but with this ROM those ad blockers refused to work.

The problem seems to be the /system/etc/hosts file is real file on flash filesystem and if modified it can be only as big as 2 kilobytes, so regular host-based ad-blocking can't be used here. For some reason creating symbolic link to /data also fails.

I though the ad blocking can be done differently — by DNS server. If we can't put much to /etc/hosts file, let's set up a DNS server (say dnsmasq) that reads the hosts-to-be-blocked file and returns for them and act as a proxy-DNS server for every other domain. But there was problem in settings DNS server in Android settings. It seems the ROM has hardcoded OpenDNS servers and you can only override this per each WiFi network. No way to do this for 3G.

But then I found, the ROM comes with iptables executable (possibly from busybox, haven't really checked) and more interestingly iptables-capable kernel. After a bit of trial and error (and Google searching) I found commands to redirect all DNS traffic comming from the phone to one predefined server:

iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination
iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination

The shell throws out one-line TODO (implement getprotobyname) errors but this is harmless to us. This is effective untill you flush iptables (with iptables -t nat -F) or reboot the phone.

At first I wanted to set up the ad-blocking DNS server myself, but I said, hey, someone just had to do it. I wasn't wrong, there were at least two relevant Google results for this: AdBarricade and FoolDNS. So you need to choose one and you're set.

But how do you compare those two? I mentioned I used AdAway and AdFree before and their block lists are very good (personal opinion), so I decided to download the hosts file generated by AdAway (it has the option to generate the hosts file anywhere, not just in plain /etc/hosts), shuffle it a bit and for top 1000 hosts check whether AdBarricade or FoolDNS block them. The results were:

FoolDNS ( 744/1000 hosts blocked
AdBarricade ( 234/1000 hosts blocked

For our purpose (measure by how many of AdAway-listed hosts are blocked) FoolDNS is a winner. That's why was used in the iptables scripts above.

Once we have our DNS-based iptables-powered ad filtering, we may want to make it persistent. BCM ROM has a script that's called during boot process, it's /etc/boot.d/99bash and we can just append two abovementioned lines to it, to make the boot process run them each time the phone boots.

Comments: 0

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License