diff --git a/config/rootfiles/common/inetutils b/config/rootfiles/common/inetutils
index 3cea63cb3..fb33fb07e 100644
--- a/config/rootfiles/common/inetutils
+++ b/config/rootfiles/common/inetutils
@@ -5,7 +5,6 @@ bin/ping
#usr/bin/rsh
#usr/bin/talk
#usr/bin/tftp
-usr/bin/whois
#usr/sbin/ftpd
#usr/sbin/inetd
#usr/sbin/rexecd
diff --git a/config/rootfiles/common/jwhois b/config/rootfiles/common/jwhois
new file mode 100644
index 000000000..4ee96ba66
--- /dev/null
+++ b/config/rootfiles/common/jwhois
@@ -0,0 +1,23 @@
+etc/jwhois.conf
+usr/bin/jwhois
+usr/bin/whois
+#usr/share/info/jwhois.info
+#usr/share/locale/es/LC_MESSAGES/jwhois.mo
+#usr/share/locale/fr/LC_MESSAGES/jwhois.mo
+#usr/share/locale/hu/LC_MESSAGES/jwhois.mo
+#usr/share/locale/id/LC_MESSAGES/jwhois.mo
+#usr/share/locale/it/LC_MESSAGES/jwhois.mo
+#usr/share/locale/nl/LC_MESSAGES/jwhois.mo
+#usr/share/locale/pl/LC_MESSAGES/jwhois.mo
+#usr/share/locale/pt_BR/LC_MESSAGES/jwhois.mo
+#usr/share/locale/ro/LC_MESSAGES/jwhois.mo
+#usr/share/locale/ru/LC_MESSAGES/jwhois.mo
+#usr/share/locale/rw/LC_MESSAGES/jwhois.mo
+#usr/share/locale/sv/LC_MESSAGES/jwhois.mo
+#usr/share/locale/tr/LC_MESSAGES/jwhois.mo
+#usr/share/locale/vi/LC_MESSAGES/jwhois.mo
+#usr/share/locale/zh_TW/LC_MESSAGES/jwhois.mo
+#usr/share/man/man1/jwhois.1
+#usr/share/man/sv
+#usr/share/man/sv/man1
+#usr/share/man/sv/man1/jwhois.1
diff --git a/lfs/inetutils b/lfs/inetutils
index 468c2af32..ba87c9c99 100644
--- a/lfs/inetutils
+++ b/lfs/inetutils
@@ -80,5 +80,9 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
cd $(DIR_APP) && make $(MAKETUNING)
cd $(DIR_APP) && make install
mv -v /usr/bin/ping /bin
+
+ # Don't use whois command from here.
+ rm -vf /usr/bin/whois
+
@rm -rf $(DIR_APP)
@$(POSTBUILD)
diff --git a/lfs/jwhois b/lfs/jwhois
new file mode 100644
index 000000000..46abec4ed
--- /dev/null
+++ b/lfs/jwhois
@@ -0,0 +1,90 @@
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
+# #
+# 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 . #
+# #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER = 4.0
+
+THISAPP = jwhois-$(VER)
+DL_FILE = $(THISAPP).tar.gz
+DL_FROM = $(URL_IPFIRE)
+DIR_APP = $(DIR_SRC)/$(THISAPP)
+TARGET = $(DIR_INFO)/$(THISAPP)
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = 977d0ba90ee058a7998c94d933fc9546
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+ @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+ @$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+ @$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+ @$(PREBUILD)
+ @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-conf_update.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-conf_update2.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-connect.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-fclose.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-idna.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-ipv6match.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-multi-homed.patch
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/jwhois-4.0-select.patch
+
+ cd $(DIR_APP) && ./configure --prefix=/usr --sysconfdir=/etc
+ cd $(DIR_APP) && make $(MAKETUNING)
+ cd $(DIR_APP) && make install
+
+ # Add alias for whois command.
+ ln -svf jwhois /usr/bin/whois
+
+ @rm -rf $(DIR_APP)
+ @$(POSTBUILD)
diff --git a/make.sh b/make.sh
index 71df2c9b2..8ae949193 100755
--- a/make.sh
+++ b/make.sh
@@ -336,6 +336,7 @@ buildbase() {
lfsmake2 gzip
lfsmake2 inetutils
lfsmake2 iproute2
+ lfsmake2 jwhois
lfsmake2 kbd
lfsmake2 less
lfsmake2 make
diff --git a/src/patches/jwhois-4.0-conf_update.patch b/src/patches/jwhois-4.0-conf_update.patch
new file mode 100644
index 000000000..512d30006
--- /dev/null
+++ b/src/patches/jwhois-4.0-conf_update.patch
@@ -0,0 +1,714 @@
+diff -up jwhois-4.0/example/jwhois.conf.orig jwhois-4.0/example/jwhois.conf
+--- jwhois-4.0/example/jwhois.conf.orig 2007-03-26 11:12:08.000000000 +0200
++++ jwhois-4.0/example/jwhois.conf 2010-12-20 14:26:06.450882316 +0100
+@@ -17,6 +17,11 @@ whois-servers {
+ type = regex;
+
+ #
++ # Catch ENUM domains
++ #
++ "\\([0-9]\\.\\)+e164\\.arpa" = "struct enum-blocks";
++
++ #
+ # You can use the special value `struct' to redirect the query
+ # to another block which optionally can use another type of matching.
+ # Here we use it to have IPv4 numbers matched using CIDR blocks instead
+@@ -27,6 +32,7 @@ whois-servers {
+ "^CORE-[0-9]+$" = "struct handles";
+ "^CO[CH]O-[0-9]+$" = "struct handles";
+ ".*-[A-Z]+$" = "struct handles";
++ ".*-6BONE$" = "struct handles";
+
+ #
+ # Catch AS numbers
+@@ -81,6 +87,7 @@ whois-servers {
+ # Pseudo-ccTLDs must be listed above gTLDs
+ #
+ "\\.ae\\.org$" = "whois.centralnic.net";
++ "\\.ar\\.com$" = "whois.centralnic.com";
+ "\\.br\\.com$" = "whois.centralnic.net";
+ "\\.cn\\.com$" = "whois.centralnic.net";
+ "\\.de\\.com$" = "whois.centralnic.net";
+@@ -103,17 +110,30 @@ whois-servers {
+ "\\.uy\\.com$" = "whois.centralnic.net";
+ "\\.web\\.com$" = "whois.centralnic.net";
+ "\\.za\\.com$" = "whois.centralnic.net";
++ "\\.za\\.net$" = "whois.za.net";
++ "\\.za\\.org$" = "whois.za.org";
+
+ "\\.ac$" = "whois.nic.ac";
+- "\\.ae$" = "whois.uaenic.ae";
++ "\\.ae$" = "whois.aeda.net.ae";
++ "\\.co\\.ae$" = "whois.aeda.net.ae";
++ "\\.net\\.ae$" = "whois.aeda.net.ae";
++ "\\.org\\.ae$" = "whois.aeda.net.ae";
++ "\\.sch\\.ae$" = "whois.aeda.net.ae";
++ "\\.ac\\.ae$" = "whois.aeda.net.ae";
++ "\\.mil\\.ae$" = "whois.aeda.net.ae";
++ "\\.gov\\.ae$" = "whois.aeda.net.ae";
++ "\\.1\\.7\\.9\\.e164\\.arpa$" = "whois.aeda.net.ae";
+ "\\.aero$" = "whois.aero";
+- "\\.af$" = "whois.nic.af";
++ "\\.af$" = "whois.cocca.cx";
+ "\\.ag$" = "whois.nic.ag";
+- "\\.ai$" = "whois.offshore.ai";
+- "\\.al$" = "whois.ripe.net";
++ "\\.ai$" = "whois.ai";
++ "\\.al$" = "www.ert.gov.al";
+ "\\.am$" = "whois.amnic.net";
++ "\\.edu\\.ar$" = "www.riu.edu.ar";
+ "\\.ar$" = "www.nic.ar";
++ "\\.arpa$" = "whois.iana.org";
+ "\\.as$" = "whois.nic.as";
++ "\\.asia$" = "whois.nic.asia";
+ "\\.at$" = "whois.nic.at";
+ "\\.asn\\.au$" = "whois.ausregistry.net.au";
+ "\\.com\\.au$" = "whois.ausregistry.net.au";
+@@ -125,30 +145,40 @@ whois-servers {
+ "\\.ba$" = "whois.ripe.net";
+ "\\.be$" = "whois.dns.be";
+ "\\.bg$" = "whois.register.bg";
+- "\\.bi$" = "www.nic.bi";
+- "\\.biz$" = "whois.neulevel.biz";
++ "\\.bi$" = "whois.nic.bi";
++ "\\.biz$" = "whois.biz";
+ "\\.bj$" = "whois.nic.bj";
+ "\\.bm$" = "rwhois.ibl.bm 4321";
++ "\\.bo$" = "whois.nic.bo";
+ "\\.br$" = "whois.nic.br";
++ "\\.bs$" = "www.register.bs";
+ "\\.bv$" = "whois.ripe.net";
+- "\\.by$" = "whois.ripe.net";
++ "\\.by$" = "www.domain.by";
+ "\\.bz$" = "whois.belizenic.bz";
++ "\\.co\\.ca$" = "whois.co.ca";
+ "\\.ca$" = "whois.cira.ca";
+ "\\.cat$" = "whois.cat";
+- "\\.cc$" = "whois.nic.cc";
++ "\\.cc$" {
++ whois-server = "ccwhois.verisign-grs.com";
++ query-format = "domain $*";
++ }
+ "\\.cd$" = "whois.nic.cd";
+ "\\.cg$" = "www.nic.cg";
+ "\\.ch$" = "whois.nic.ch";
+ "\\.ci$" = "whois.nic.ci";
+ "\\.ck$" = "whois.nic.ck";
+ "\\.cl$" = "whois.nic.cl";
++ "\\.co\\.cm$" = "whois.netcom.cm";
++ "\\.com\\.cm$" = "whois.netcom.cm";
++ "\\.net\\.cm$" = "whois.netcom.cm";
+ "\\.edu\\.cn$" = "whois.edu.cn";
+- "\\.cn$" = "whois.cnnic.net.cn";
++ "\\.cn$" = "whois.cnnic.cn";
+ "\\.com$" {
+ whois-server = "whois.verisign-grs.com";
+ query-format = "domain $*";
+ }
+ "\\.coop$" = "whois.nic.coop";
++ "\\.cu$" = "www.nic.cu";
+ "\\.cx$" = "whois.nic.cx";
+ "\\.cy$" = "whois.ripe.net";
+ "\\.cz$" = "whois.nic.cz";
+@@ -156,12 +186,15 @@ whois-servers {
+ whois-server = "whois.denic.de";
+ query-format = "-C UTF-8 -T dn,ace $*";
+ }
+- "\\.dk$" = "whois.dk-hostmaster.dk";
++ "\\.dk$" {
++ whois-server = "whois.dk-hostmaster.dk";
++ query-format = "--show-handles $*";
++ }
+ "\\.dm$" = "whois.nic.dm";
+ "\\.do$" = "whois.nic.do";
+- "\\.dz$" = "whois.ripe.net";
++ "\\.dz$" = "www.nic.dz";
+ "\\.ec$" = "www.nic.ec";
+- "\\.edu$" = "whois.educause.net";
++ "\\.edu$" = "whois.educause.edu";
+ "\\.ee$" = "whois.eenet.ee";
+ "\\.eg$" = "whois.ripe.net";
+ "\\.es$" = "www.nic.es";
+@@ -171,17 +204,20 @@ whois-servers {
+ "\\.fm$" = "www.dot.fm";
+ "\\.fo$" = "whois.ripe.net";
+ "\\.fr$" = "whois.nic.fr";
+- "\\.gi$" = "www.nic.gi";
++ "\\.gd$" = "whois.adamsnames.com";
++ "\\.gi$" = "whois2.afilias-grs.net";
+ "\\.gov$" = "whois.nic.gov";
+- "\\.gg$" = "whois.isles.net";
++ "\\.gg$" = "whois.gg";
+ "\\.gm$" = "whois.ripe.net";
+ "\\.gp$" = "whois.nic.gp";
+ "\\.gr$" = "whois.ripe.net";
+- "\\.gs$" = "203.119.12.22";
++ "\\.gs$" = "whois.nic.gs";
+ "\\.gt$" = "www.gt";
+- "\\.hk$" = "whois.hkdnr.net.hk";
++ "\\.hk$" = "whois.hkirc.hk";
+ "\\.hm$" = "whois.registry.hm";
++ "\\.hn$" = "whois2.afilias-grs.net";
+ "\\.hr$" = "www.dns.hr";
++ "\\.ht$" = "whois.nic.ht";
+ "\\.hu$" = "whois.nic.hu";
+ "\\.id$" = "whois.idnic.net.id";
+ "\\.ie$" = "whois.domainregistry.ie";
+@@ -195,69 +231,94 @@ whois-servers {
+ "\\.is$" = "whois.isnic.is";
+ "\\.it$" = "whois.nic.it";
+ "\\.je$" = "whois.isles.net";
++ "\\.jobs$" {
++ whois-server = "jobswhois.verisign-grs.com";
++ query-format = "domain $*";
++ }
+ "\\.jp$" {
+ whois-server = "whois.jprs.jp";
+ query-format = "$* /e";
+ }
++ "\\.ke$" = "whois.kenic.or.ke";
++ "\\.kp$" = "whois.kcce.kp";
+ "\\.kg$" = "whois.domain.kg";
+- "\\.ki$" = "whois.nic.ki";
++ "\\.ki$" = "whois.cocca.cx";
+ "\\.kr$" = "whois.krnic.net";
+ "\\.kz$" = "whois.nic.kz";
+ "\\.la$" = "whois.nic.la";
+ "\\.lb$" = "cgi.aub.edu.lb";
++ "\\.lc$" = "whois2.afilias-grs.net";
+ "\\.li$" = "whois.nic.li";
+ "\\.lk$" = "whois.nic.lk";
+ "\\.lt$" = "whois.domreg.lt";
+ "\\.lu$" = "whois.dns.lu";
+ "\\.lv$" = "whois.nic.lv";
+ "\\.ly$" = "whois.nic.ly";
+- "\\.ma$" = "whois.ripe.net";
++ "\\.ma$" = "whois.iam.net.ma";
++ "\\.md$" = "whois.nic.md";
++ "\\.me$" = "whois.nic.me";
+ "\\.mil$" = "whois.nic.mil";
+ "\\.mk$" = "whois.ripe.net";
+ "\\.mm$" = "whois.nic.mm";
++ "\\.mn$" = "whois2.afilias-grs.net";
+ "\\.mobi$" = "whois.dotmobiregistry.net";
+- "\\.ms$" = "whois.adamsnames.tc";
+- "\\.mt$" = "www.um.edu.mt";
++ "\\.ms$" = "whois.nic.ms";
++ "\\.mt$" = "whois.nic.org.mt";
+ "\\.mu$" = "whois.nic.mu";
+ "\\.museum$" = "whois.museum";
+ "\\.mw$" = "www.tarsus.net";
+ "\\.mx$" = "whois.nic.mx";
+- "\\.my$" = "whois.mynic.net.my";
++ "\\.my$" = "whois.domainregistry.my";
+ "\\.na$" = "whois.na-nic.com.na";
+- "\\.name$" = "whois.nic.name";
++ "\\.name$" {
++ whois-server = "whois.nic.name";
++ query-format = "domain = $*";
++ }
+ "\\.net$" {
+ whois-server = "whois.verisign-grs.com";
+ query-format = "domain $*";
+ }
+- "\\.ng$" = "whois.rg.net";
++ "\\.nf$" = "whois.cocca.cx";
++ "\\.ng$" = "whois.nic.net.ng";
+ "\\.nl$" = "whois.domain-registry.nl";
+ "\\.no$" = "whois.norid.no";
+ "\\.nu$" = "whois.nic.nu";
+ "\\.nz$" = "whois.srs.net.nz";
+ "\\.org$" = "whois.publicinterestregistry.net";
+- "\\.pe$" = "whois.nic.pe";
++ "\\.pa$" = "www.nic.pa";
++ "\\.pe$" = "kero.yachay.pe";
+ "\\.pk$" = "pknic.net.pk";
+ "\\.pl$" = "whois.dns.pl";
+ "\\.pm$" = "whois.nic.pm";
++ "\\.pr$" = "whois.nic.pr";
+ "\\.pro$" = "whois.registrypro.pro";
++ "\\.ps$" = "www.nic.ps";
+ "\\.pt$" = "whois.dns.pt";
+ "\\.pw$" = "whois.nic.pw";
+ "\\.re$" = "whois.nic.re";
+ "\\.ro$" = "whois.rotld.ro";
++ "\\.edu\.ru$" = "whois.informika.ru";
+ "\\.ru$" = "whois.ripn.net";
+ "\\.rw$" = "www.nic.rw";
+ "\\.sa$" = "saudinic.net.sa";
++ "\\.sb$" = "whois.nic.sb";
++ "\\.sc$" = "whois2.afilias-grs.net";
+ "\\.se$" = "whois.iis.se";
+- "\\.sg$" = "whois.nic.net.sg";
++ "\\.sg$" = "whois.sgnic.sg";
+ "\\.sh$" = "whois.nic.sh";
+ "\\.si$" = "whois.arnes.si";
+ "\\.sj$" = "whois.ripe.net";
+- "\\.sk$" = "whois.ripe.net";
++ "\\.sk$" = "whois.sk-nic.sk";
++ "\\.sl$" = "whois.nic.sl";
+ "\\.sm$" = "whois.ripe.net";
++ "\\.sn$" = "whois.nic.sn";
++ "\\.so$" = "whois.nic.so";
+ "\\.sr$" = "whois.register.sr";
+ "\\.st$" = "whois.nic.st";
+ "\\.su$" = "whois.ripn.net";
++ "\\.sv$" = "www.svnet.org.sv";
+ "\\.tc$" = "whois.adamsnames.tc";
++ "\\.tel$" = "whois.nic.tel";
+ "\\.tf$" = "whois.afnic.fr";
+ "\\.tg$" = "www.nic.tg";
+ "\\.th$" = "whois.thnic.net";
+@@ -268,8 +329,12 @@ whois-servers {
+ "\\.tn$" = "whois.ripe.net";
+ "\\.to$" = "whois.tonic.to";
+ "\\.tr$" = "whois.nic.tr";
++ "\\.travel$" = "whois.nic.travel";
+ "\\.tt$" = "www.nic.tt";
+- "\\.tv$" = "whois.nic.tv";
++ "\\.tv$" {
++ whois-server = "tvwhois.verisign-grs.com";
++ query-format = "domain $*";
++ }
+ "\\.tw$" = "whois.twnic.net";
+ "\\.ua$" = "whois.com.ua";
+ "\\.ug$" = "whois.co.ug";
+@@ -279,9 +344,12 @@ whois-servers {
+ "\\.fed\\.us$" = "whois.nic.gov";
+ "\\.us$" = "whois.nic.us";
+ "\\.com\\.uy$" = "dns.antel.net.uy";
+- "\\.uy$" = "www.rau.edu.uy"; # is a whois server
+- "\\.uz$" = "www.noc.uz";
++ "\\.uy$" = "whois.nic.org.uy";
++ "\\.co\\.uz$" = "whois.reg.uz";
++ "\\.com\\.uz$" = "whois.reg.uz";
++ "\\.uz$" = "whois.cctld.uz";
+ "\\.va$" = "whois.ripe.net";
++ "\\.vc$" = "whois2.afilias-grs.net";
+ "\\.ve$" = "whois.nic.ve";
+ "\\.vi$" = "www.nic.vi";
+ "\\.vg$" = "whois.adamsnames.tc";
+@@ -289,12 +357,15 @@ whois-servers {
+ "\\.vu$" = "www.vunic.vu";
+ "\\.wf$" = "whois.nic.wf";
+ "\\.ws$" = "whois.worldsite.ws";
++ "\\.xn--mgbaam7a8h$" = "whois.aeda.net.ae";
+ "\\.yt$" = "whois.nic.yt";
+- "\\.yu$" = "whois.ripe.net";
++ "\\.yu$" = "www.nic.yu";
+ "\\.ac\\.za$" = "whois.ac.za";
+ "\\.org\\.za$" = "rwhois.org.za 4321";
+ "\\.co\\.za$" = "whois.co.za";
++ "\\.nom\\.za$" = "www.nom.za";
+ # "\\.za$" = "whois.frd.ac.za";
++ "\\.co\\.zw$" = "www.zispa.co.zw";
+
+ #
+ # Specify different port numbers to connect to by postfixing the IP
+@@ -311,6 +382,16 @@ whois-servers {
+ }
+
+ #
++# enum-blocks
++#
++enum-blocks {
++ type = regex;
++
++ "\\.9\\.4\\.e164\\.arpa$" = "whois.enum.denic.de";
++ "\\.1\\.6\\.e164\\.arpa$" = "whois-check.enum.com.au";
++}
++
++#
+ # cidr-blocks contains a list of all known CIDR blocks assigned to
+ # RIPE or APNIC. Default all queries to ARIN which has most other blocks.
+ #
+@@ -580,7 +661,7 @@ cidr-blocks {
+ cidr6-blocks {
+ type = cidr6;
+
+- "2001:0000::/23" = "whois.iana.org";
++ "2001:0000::/23" = "whois.iana.org"; # correct, but nothing usable is returned
+ "2001:0200::/23" = "whois.apnic.net";
+ "2001:0400::/23" = "whois.arin.net";
+ "2001:0600::/23" = "whois.ripe.net";
+@@ -593,13 +674,13 @@ cidr6-blocks {
+ "2001:1600::/23" = "whois.ripe.net";
+ "2001:1800::/23" = "whois.arin.net";
+ "2001:1A00::/23" = "whois.ripe.net";
+- "2001:1C00::/23" = "whois.ripe.net";
+- "2001:1E00::/23" = "whois.ripe.net";
++ "2001:1C00::/22" = "whois.ripe.net";
+ "2001:2000::/20" = "whois.ripe.net";
+ "2001:3000::/21" = "whois.ripe.net";
+ "2001:3800::/22" = "whois.ripe.net";
++ "2001:3C00::/22" = "whois.arin.net"; # not correct, but shows better information
+ "2001:4000::/23" = "whois.ripe.net";
+- "2001:4200::/23" = "whois.arin.net";
++ "2001:4200::/23" = "whois.afrinic.net";
+ "2001:4400::/23" = "whois.apnic.net";
+ "2001:4600::/23" = "whois.ripe.net";
+ "2001:4800::/23" = "whois.arin.net";
+@@ -610,23 +691,47 @@ cidr6-blocks {
+ "2001:A000::/20" = "whois.apnic.net";
+ "2001:B000::/20" = "whois.apnic.net";
+
++ "2002:0000::/16" = "whois.arin.net"; # not correct, but shows better information
++
+ "2003:0000::/18" = "whois.ripe.net";
+
+- "2400:0000::/19" = "whois.apnic.net";
+- "2400:2000::/19" = "whois.apnic.net";
+- "2400:4000::/21" = "whois.apnic.net";
+- "2404:0000::/23" = "whois.apnic.net";
+-
+- "2600:0000::/22" = "whois.arin.net";
+- "2604:0000::/22" = "whois.arin.net";
+- "2608:0000::/22" = "whois.arin.net";
+- "260C:0000::/22" = "whois.arin.net";
++ "2400:0000::/12" = "whois.apnic.net";
++
++ "2600:0000::/12" = "whois.arin.net";
+ "2610:0000::/23" = "whois.arin.net";
++ "2620:0000::/23" = "whois.arin.net";
++
++ "2800:0000::/12" = "whois.lacnic.net";
+
+- "2800:0000::/23" = "whois.lacnic.net";
++ "2C00:0000::/12" = "whois.afrinic.net";
+
+- "2A00:0000::/21" = "whois.ripe.net";
+- "2A01:0000::/16" = "whois.ripe.net";
++ #
++ # IPv6 blocks by carriers used for SixXS;
++ # see e.g. http://www.sixxs.net/pops/
++ #
++ "2001:0610::/32" = "whois.sixxs.net";
++ "2001:06A0::/32" = "whois.sixxs.net";
++ "2001:06A8::/32" = "whois.sixxs.net";
++ "2001:06F8::/32" = "whois.sixxs.net";
++ "2001:0770::/32" = "whois.sixxs.net";
++ "2001:07B8::/32" = "whois.sixxs.net";
++ "2001:0808::/32" = "whois.sixxs.net";
++ "2001:0838::/32" = "whois.sixxs.net";
++ "2001:0960::/32" = "whois.sixxs.net";
++ "2001:0A60::/32" = "whois.sixxs.net";
++ "2001:0AD0::/32" = "whois.sixxs.net";
++ "2001:0B18::/32" = "whois.sixxs.net";
++ "2001:1418::/32" = "whois.sixxs.net";
++ "2001:14B8::/32" = "whois.sixxs.net";
++ "2001:15C0::/32" = "whois.sixxs.net";
++ "2001:16D8::/32" = "whois.sixxs.net";
++ "2001:1938::/32" = "whois.sixxs.net";
++ "2001:4830::/32" = "whois.sixxs.net";
++ "2001:4978::/32" = "whois.sixxs.net";
++ "2001:41E0::/32" = "whois.sixxs.net";
++ "2001:4428::/32" = "whois.sixxs.net";
++ "2A01:0198::/32" = "whois.sixxs.net";
++ "2A01:0348::/32" = "whois.sixxs.net";
+
+ #
+ # Experimental IPv6 network 6bone (RFC2471)
+@@ -662,7 +767,7 @@ handles {
+ ".*-NICAT$" = "whois.nic.at";
+ ".*-CZ$" = "whois.nic.cz";
+ ".*-NICIR$" = "whois.nic.ir";
+- ".*-UYNIC$" = "www.rau.edu.uy";
++ ".*-UYNIC$" = "whois.nic.org.uy";
+ ".*-ITNIC$" = "whois.nic.it";
+ ".*-FRNIC$" = "whois.nic.fr";
+ ".*-LACNIC$" = "whois.lacnic.net";
+@@ -671,6 +776,49 @@ handles {
+ whois-server = "saudinic.net.sa";
+ query-format = "PERSON $*";
+ }
++ ".*-SIXXS$" = "whois.sixxs.net";
++ ".*-6BONE$" = "whois.6bone.net";
++ ".*-IRNIC$" = "whois.nic.ir";
++ ".*-RIPN$" = "whois.ripn.net";
++ ".*-AFRINIC$" = "whois.afrinic.net";
++ "^C[0-9]+-LRMS$" {
++ whois-server = "whois.afilias.info";
++ query-format = "CONTACT ID $*";
++ }
++ "^D[0-9]+-LRMS$" {
++ whois-server = "whois.afilias.info";
++ query-format = "DOMAIN ID $*";
++ }
++ "^H[0-9]+-LRMS$" {
++ whois-server = "whois.afilias.info";
++ query-format = "HOST ID $*";
++ }
++ "^R[0-9]+-LRMS$" {
++ whois-server = "whois.afilias.info";
++ query-format = "REGISTRAR ID $*";
++ }
++ ".*-KENIC$" = "whois.kenic.or.ke";
++ ".*-UANIC$" = "whois.com.ua";
++ ".*-COOP$" {
++ whois-server = "whois.nic.coop";
++ query-format = "CONTACT $*";
++ }
++ ".*CONTACT-NAME$" {
++ whois-server = "whois.nic.name";
++ query-format = "contact = $*";
++ }
++ ".*REGISTRAR-NAME$" {
++ whois-server = "whois.nic.name";
++ query-format = "registrar = $*";
++ }
++ "^C[0-9]+-AERO$" {
++ whois-server = "whois.aero";
++ query-format = "CONTACT ID $*";
++ }
++ "^D[0-9]+-AERO$" {
++ whois-server = "whois.aero";
++ query-format = "DOMAIN ID $*";
++ }
+ }
+
+ #
+@@ -678,11 +826,6 @@ handles {
+ # each host.
+ #
+ server-options {
+- "rwhois\\.nic\\.ve" {
+- rwhois = true;
+- rwhois-display = "dump";
+- rwhois-limit = 10;
+- }
+ "rwhois\\.exodus\\.net" {
+ rwhois = true;
+ }
+@@ -754,13 +897,6 @@ server-options {
+ form-element = "name";
+ }
+
+- "www\\.um\\.edu\\.mt" {
+- http = "true";
+- http-method = "GET";
+- http-action = "/cgi-bin/nic/whois";
+- form-element = "domain";
+- }
+-
+ "www\\.gt" {
+ http = "true";
+ http-method = "GET";
+@@ -777,13 +913,6 @@ server-options {
+ query-format = "Upit=${+2}"; # All but last domain segment
+ }
+
+- "whois\\.offshore\\.ai" {
+- http = "true";
+- http-method = "POST";
+- http-action = "/cgi-bin/whois.pl";
+- form-element = "domain-name";
+- }
+-
+ "www\\.io\\.io" {
+ http = "true";
+ http-method = "GET";
+@@ -813,11 +942,12 @@ server-options {
+ form-element = "query";
+ }
+
+- "www\\.nic\\.bi" {
+- http = "true";
+- http-method = "POST";
+- http-action = "/cgi-bin/whoisbi.pl"; # Formatting problems in Lynx
+- form-element = "DOMAINWHOIS";
++ "whois\\.nic\\.bi" {
++ http = "true"; # I can't connect on port 43
++ http-method = "GET";
++ http-action = "/register/whois.hei";
++ form-element = "query";
++ form-extra = "type=domain";
+ }
+
+ "www\\.nic\\.cg" {
+@@ -848,13 +978,6 @@ server-options {
+ form-element = "name";
+ }
+
+- "www\\.noc\\.uz" {
+- http = "true";
+- http-method = "POST";
+- http-action = "/whois.php4";
+- form-element = "dname";
+- }
+-
+ "www\\.nic\\.vi" {
+ http = "true";
+ http-method = "POST";
+@@ -878,9 +1001,9 @@ server-options {
+
+ "www\\.nic\\.tg" {
+ http = "true";
+- http-method = "GET";
+- http-action = "/moteur/info_dom.php";
+- form-element = "domaine";
++ http-method = "POST";
++ http-action = "/nictg/indexplus.php?pg=verifdom&op=whois";
++ query-format = "tosearch=${+2}&typedom=.tg";
+ }
+
+ "cgi\\.aub\\.edu\\.lb" {
+@@ -910,33 +1033,152 @@ server-options {
+ form-element = "nombre";
+ }
+
+- "www\\.denic\\.de" {
+- http = "true";
+- http-method = "POST";
+- http-action = "/en/whois/data.jsp";
+- form-element = "domainname";
+- form-extra = "service=WhoisData&lang=en&submit=Accept";
+- }
+ "whois\\.denic\\.de" {
+ whois-server = "whois.denic.de";
+ query-format = "-C UTF-8 -T dn,ace $*";
+ answer-charset = "UTF-8";
+ }
++
++ "whois\\.enum\\.denic\\.de" {
++ whois-server = "whois.enum.denic.de";
++ query-format = "-C UTF-8 -T dn $*";
++ answer-charset = "UTF-8";
++ }
++
+ "whois\\.nic\\.ad\\.jp" {
+ query-format = "$*/e";
+ }
++
+ "whois\\.nic\\.ch" {
+ answer-charset = "UTF-8";
+ }
++
+ "whois\\.nic\\.li" {
+ answer-charset = "UTF-8";
+ }
++
+ "whois\\.centralnic\\.*" {
+ whois-redirect = ".*Whois Server: \\(.*\\)";
+ }
++
+ ".*\\.verisign-grs\\.com" {
+ whois-redirect = ".*Whois Server: \\(.*\\)";
+ }
++
++ "whois\\.sixxs\\.net" {
++ whois-redirect = ".*ReferralServer: whois:\/\/\\(.*\\)";
++ }
++
++ "whois2\\.afilias-grs\\.net" {
++ whois-redirect = "Whois Server:\\(.*\\)";
++ }
++
++ "whois\\.registrar\\.telekom\\.de" {
++ query-format = "full $*";
++ }
++
++ "whois\\.rrpproxy\\.net" {
++ answer-charset = "UTF-8";
++ }
++
++ "www\\.nom\\.za" {
++ http = "true";
++ http-method = "POST";
++ http-action = "/do.php";
++ query-format = "chkDomain=${+3}&chkAvail=Check";
++ }
++
++ "www\\.nic\\.pa" {
++ http = "true";
++ http-method = "GET";
++ http-action = "/egh/whois.php";
++ form-element = "nombre_d";
++ }
++
++ "www\\.nic\\.dz" {
++ http = "true";
++ http-method = "POST";
++ http-action = "/index.php?option=com_content&task=view&id=37&Itemid=51";
++ form-element = "domain_name";
++ }
++
++ "www\\.nic\\.yu" {
++ http = "true";
++ http-method = "GET";
++ http-action = "/cgi-bin/checkavail.cgi";
++ form-element = "domain";
++ }
++
++ "whois\\.dotster\\.com" {
++ answer-charset = "UTF-8";
++ }
++
++ "www\\.ert\\.gov\\.al" {
++ http = "true";
++ http-method = "POST";
++ http-action = "/ert_eng/domain_res.html";
++ query-format = "Domain=${+2}";
++ }
++
++ "www\\.nic\\.cu" {
++ http = "true";
++ http-method = "GET";
++ http-action = "/dom_det.php";
++ form-element = "domsrch";
++ }
++
++ "www\\.nic\\.ps" {
++ http = "true";
++ http-method = "GET";
++ http-action = "/whois/domain_whois.php";
++ form-element = "dname";
++ }
++
++ "www\\.svnet\\.org\\.sv" {
++ http = "true";
++ http-method = "POST";
++ http-action = "/registro/consultas/whois.php";
++ form-element = "subdominio";
++ }
++
++ "www\\.zispa\\.co\\.zw" {
++ http = "true";
++ http-method = "GET";
++ http-action = "/cgi-bin/search";
++ form-element = "domain";
++ }
++
++ "www\\.riu\\.edu\\.ar" {
++ http = "true";
++ http-method = "POST";
++ http-action = "/cgi-bin/verdom.pl.nuevo";
++ query-format = "username=${+3}";
++ }
++
++ "www\\.register\\.bs" {
++ http = "true";
++ http-method = "POST";
++ http-action = "/cgi-bin/search.pl";
++ form-element = "name";
++ }
++
++ "www\\.domain\\.by" {
++ http = "true";
++ http-method = "POST";
++ http-action = "/cgi-bin/registry.cgi";
++ query-format = "domain=${+2}&lang=e&mode=slquest";
++ }
++
++ "www\\.nic\\.ac" {
++ http = "true";
++ http-method = "GET";
++ http-action = "/cgi-bin/whois";
++ form-element = "textfield";
++ }
++
++ "whois\\.1api\\.net" {
++ answer-charset = "UTF-8";
++ }
+ }
+
+ #
diff --git a/src/patches/jwhois-4.0-conf_update2.patch b/src/patches/jwhois-4.0-conf_update2.patch
new file mode 100644
index 000000000..72dd300ff
--- /dev/null
+++ b/src/patches/jwhois-4.0-conf_update2.patch
@@ -0,0 +1,163 @@
+Patch by Robert Scheck for jwhois >= 4.0, which adds various new
+IDN top-level-domains, updates some whois servers of ccTLDs and corrects the answer charset
+setting for some whois servers, too.
+
+--- jwhois-4.0/example/jwhois.conf 2011-05-22 20:36:19.000000000 +0200
++++ jwhois-4.0/example/jwhois.conf.conf_update2 2011-05-22 23:46:21.000000000 +0200
+@@ -122,7 +122,6 @@
+ "\\.ac\\.ae$" = "whois.aeda.net.ae";
+ "\\.mil\\.ae$" = "whois.aeda.net.ae";
+ "\\.gov\\.ae$" = "whois.aeda.net.ae";
+- "\\.1\\.7\\.9\\.e164\\.arpa$" = "whois.aeda.net.ae";
+ "\\.aero$" = "whois.aero";
+ "\\.af$" = "whois.cocca.cx";
+ "\\.ag$" = "whois.nic.ag";
+@@ -192,7 +191,7 @@
+ }
+ "\\.dm$" = "whois.nic.dm";
+ "\\.do$" = "whois.nic.do";
+- "\\.dz$" = "www.nic.dz";
++ "\\.dz$" = "whois.nic.dz";
+ "\\.ec$" = "www.nic.ec";
+ "\\.edu$" = "whois.educause.edu";
+ "\\.ee$" = "whois.eenet.ee";
+@@ -243,7 +242,7 @@
+ "\\.kp$" = "whois.kcce.kp";
+ "\\.kg$" = "whois.domain.kg";
+ "\\.ki$" = "whois.cocca.cx";
+- "\\.kr$" = "whois.krnic.net";
++ "\\.kr$" = "whois.kr";
+ "\\.kz$" = "whois.nic.kz";
+ "\\.la$" = "whois.nic.la";
+ "\\.lb$" = "cgi.aub.edu.lb";
+@@ -292,13 +291,14 @@
+ "\\.pm$" = "whois.nic.pm";
+ "\\.pr$" = "whois.nic.pr";
+ "\\.pro$" = "whois.registrypro.pro";
+- "\\.ps$" = "www.nic.ps";
++ "\\.ps$" = "whois.pnina.ps";
+ "\\.pt$" = "whois.dns.pt";
+ "\\.pw$" = "whois.nic.pw";
+ "\\.re$" = "whois.nic.re";
+ "\\.ro$" = "whois.rotld.ro";
++ "\\.rs$" = "whois.rnids.rs";
+ "\\.edu\.ru$" = "whois.informika.ru";
+- "\\.ru$" = "whois.ripn.net";
++ "\\.ru$" = "whois.tcinet.ru";
+ "\\.rw$" = "www.nic.rw";
+ "\\.sa$" = "saudinic.net.sa";
+ "\\.sb$" = "whois.nic.sb";
+@@ -317,6 +317,7 @@
+ "\\.st$" = "whois.nic.st";
+ "\\.su$" = "whois.ripn.net";
+ "\\.sv$" = "www.svnet.org.sv";
++ "\\.sy$" = "whois.tld.sy";
+ "\\.tc$" = "whois.adamsnames.tc";
+ "\\.tel$" = "whois.nic.tel";
+ "\\.tf$" = "whois.afnic.fr";
+@@ -335,7 +336,7 @@
+ whois-server = "tvwhois.verisign-grs.com";
+ query-format = "domain $*";
+ }
+- "\\.tw$" = "whois.twnic.net";
++ "\\.tw$" = "whois.twnic.net.tw";
+ "\\.ua$" = "whois.com.ua";
+ "\\.ug$" = "whois.co.ug";
+ "\\.ac\\.uk$" = "whois.ja.net";
+@@ -357,9 +358,25 @@
+ "\\.vu$" = "www.vunic.vu";
+ "\\.wf$" = "whois.nic.wf";
+ "\\.ws$" = "whois.worldsite.ws";
++ "\\.xn--3e0b707e$" = "whois.kr";
++ "\\.xn--90a3ac$" = "whois.rnids.rs";
++ "\\.xn--clchc0ea0b2g2a9gcd$" = "whois.sgnic.sg";
++ "\\.xn--fiqs8s$" = "cwhois.cnnic.cn";
++ "\\.xn--fiqz9s$" = "cwhois.cnnic.cn";
++ "\\.xn--fzc2c9e2c$" = "whois.nic.lk";
++ "\\.xn--j6w193g$" = "whois.hkirc.hk";
++ "\\.xn--kprw13d$" = "whois.twnic.net.tw";
++ "\\.xn--kpry57d$" = "whois.twnic.net.tw";
++ "\\.xn--lgbbat1ad8j$" = "whois.nic.dz";
+ "\\.xn--mgbaam7a8h$" = "whois.aeda.net.ae";
++ "\\.xn--mgberp4a5d4ar$" = "whois.nic.net.sa";
++ "\\.xn--o3cw4h$" = "whois.thnic.co.th";
++ "\\.xn--ogbpf8fl$" = "whois.tld.sy";
++ "\\.xn--p1ai$" = "whois.tcinet.ru";
++ "\\.xn--xkc2al3hye2a$" = "whois.nic.lk";
++ "\\.xn--yfro4i67o$" = "whois.sgnic.sg";
++ "\\.xn--ygbi2ammx$" = "whois.pnina.ps";
+ "\\.yt$" = "whois.nic.yt";
+- "\\.yu$" = "www.nic.yu";
+ "\\.ac\\.za$" = "whois.ac.za";
+ "\\.org\\.za$" = "rwhois.org.za 4321";
+ "\\.co\\.za$" = "whois.co.za";
+@@ -389,6 +406,7 @@
+
+ "\\.9\\.4\\.e164\\.arpa$" = "whois.enum.denic.de";
+ "\\.1\\.6\\.e164\\.arpa$" = "whois-check.enum.com.au";
++ "\\.1\\.7\\.9\\.e164\\.arpa$" = "whois.aeda.net.ae";
+ }
+
+ #
+@@ -1095,20 +1113,6 @@
+ form-element = "nombre_d";
+ }
+
+- "www\\.nic\\.dz" {
+- http = "true";
+- http-method = "POST";
+- http-action = "/index.php?option=com_content&task=view&id=37&Itemid=51";
+- form-element = "domain_name";
+- }
+-
+- "www\\.nic\\.yu" {
+- http = "true";
+- http-method = "GET";
+- http-action = "/cgi-bin/checkavail.cgi";
+- form-element = "domain";
+- }
+-
+ "whois\\.dotster\\.com" {
+ answer-charset = "UTF-8";
+ }
+@@ -1127,13 +1131,6 @@
+ form-element = "domsrch";
+ }
+
+- "www\\.nic\\.ps" {
+- http = "true";
+- http-method = "GET";
+- http-action = "/whois/domain_whois.php";
+- form-element = "dname";
+- }
+-
+ "www\\.svnet\\.org\\.sv" {
+ http = "true";
+ http-method = "POST";
+@@ -1179,6 +1176,26 @@
+ "whois\\.1api\\.net" {
+ answer-charset = "UTF-8";
+ }
++
++ "whois\\.kr" {
++ answer-charset = "EUC-KR";
++ }
++
++ "whois\\.nic\\.or\\.kr" {
++ answer-charset = "EUC-KR";
++ }
++
++ "whois\\.nic\\.dz" {
++ answer-charset = "UTF-8";
++ }
++
++ "whois\\.nic\\.lk" {
++ answer-charset = "ISO-8859-11";
++ }
++
++ "whois\\.iana\\.org" {
++ answer-charset = "UTF-8";
++ }
+ }
+
+ #
diff --git a/src/patches/jwhois-4.0-connect.patch b/src/patches/jwhois-4.0-connect.patch
new file mode 100644
index 000000000..2a639d779
--- /dev/null
+++ b/src/patches/jwhois-4.0-connect.patch
@@ -0,0 +1,58 @@
+This fixes somewhat reversed logic of trying to connect to WHOIS server.
+Tue Nov 20 2007, Lubomir Kundrak
+
+--- jwhois-4.0/src/utils.c.connect 2007-06-26 09:00:20.000000000 +0200
++++ jwhois-4.0/src/utils.c 2007-11-20 17:05:33.000000000 +0100
+@@ -247,7 +247,7 @@ make_connect(const char *host, int port)
+ {
+ return -1;
+ }
+- while (res)
++ for (; res; res = res->ai_next)
+ {
+ sa = res->ai_addr;
+ sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+@@ -266,15 +266,15 @@ make_connect(const char *host, int port)
+ flags = fcntl(sockfd, F_GETFL, 0);
+ if (fcntl(sockfd, F_SETFL, flags|O_NONBLOCK) == -1)
+ {
++ close (sockfd);
+ return -1;
+ }
+
+-
+ error = connect(sockfd, res->ai_addr, res->ai_addrlen);
+-
+ if (error < 0 && errno != EINPROGRESS)
+ {
+- break;
++ close (sockfd);
++ continue;
+ }
+
+ FD_ZERO(&fdset);
+@@ -283,18 +283,20 @@ make_connect(const char *host, int port)
+ error = select(FD_SETSIZE, NULL, &fdset, NULL, &timeout);
+ if (error == 0)
+ {
+- break;
++ close (sockfd);
++ return -1;
+ }
+
+ retlen = sizeof(retval);
+ error = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &retval, &retlen);
+ if (error < 0 || retval)
+ {
+- break;
++ close (sockfd);
++ return -1;
+ }
+- res = res->ai_next;
++
++ break;
+ }
+- if (error < 0 || retval) return -1;
+ #endif
+
+ return sockfd;
diff --git a/src/patches/jwhois-4.0-fclose.patch b/src/patches/jwhois-4.0-fclose.patch
new file mode 100644
index 000000000..e9c896f68
--- /dev/null
+++ b/src/patches/jwhois-4.0-fclose.patch
@@ -0,0 +1,12 @@
+diff -up jwhois-4.0/src/init.c_old jwhois-4.0/src/init.c
+--- jwhois-4.0/src/init.c_old 2007-06-26 08:59:17.000000000 +0200
++++ jwhois-4.0/src/init.c 2009-01-27 15:49:35.000000000 +0100
+@@ -283,6 +283,8 @@ parse_args(int *argc, char ***argv)
+ if (in)
+ jconfig_parse_file(in);
+
++ fclose(in);
++
+ if (verbose>1)
+ {
+ printf("[Debug: Cache = %s]\n", cache?"On":"Off");
diff --git a/src/patches/jwhois-4.0-idna.patch b/src/patches/jwhois-4.0-idna.patch
new file mode 100644
index 000000000..ff13a4f71
--- /dev/null
+++ b/src/patches/jwhois-4.0-idna.patch
@@ -0,0 +1,43 @@
+diff -up jwhois-4.0/src/jwhois.c.orig jwhois-4.0/src/jwhois.c
+--- jwhois-4.0/src/jwhois.c.orig 2007-06-26 08:59:35.000000000 +0200
++++ jwhois-4.0/src/jwhois.c 2011-05-24 12:29:37.398892451 +0200
+@@ -98,7 +98,7 @@ main(int argc, char **argv)
+
+ /* Parse remaining arguments and place them into the wq
+ structure. */
+- while (optind < argc)
++ while (optind < argc-1)
+ {
+ count += strlen(argv[optind])+1;
+ if (!qstring)
+@@ -116,19 +116,25 @@ main(int argc, char **argv)
+ strcat(qstring, " ");
+ optind++;
+ }
+- qstring[strlen(qstring)-1] = '\0';
+ #ifdef LIBIDN
+- rc = idna_to_ascii_lz(qstring, &idn, 0);
++ rc = idna_to_ascii_lz(argv[optind], &idn, 0);
+ if (rc != IDNA_SUCCESS)
+ {
+- printf("[IDN encoding of '%s' failed with error code %d]\n", qstring, rc);
++ printf("[IDN encoding of '%s' failed with error code %d]\n", argv[optind], rc);
+ exit(1);
+ }
+- wq.query = strdup(idn);
++ qstring = realloc(qstring, count+strlen(idn)+1);
++ memcpy(qstring+count,
++ idn,
++ strlen(idn)+1);
+ free(idn);
+ #else
+- wq.query = qstring;
++ qstring = realloc(qstring, count+strlen(argv[optind])+1);
++ memcpy(qstring+count,
++ argv[optind],
++ strlen(argv[optind])+1);
+ #endif
++ wq.query = qstring;
+
+ if (ghost)
+ {
diff --git a/src/patches/jwhois-4.0-ipv6match.patch b/src/patches/jwhois-4.0-ipv6match.patch
new file mode 100644
index 000000000..0e5ad0e9a
--- /dev/null
+++ b/src/patches/jwhois-4.0-ipv6match.patch
@@ -0,0 +1,15 @@
+When IPv6 address mask did not end on an octed boundary, the the opposite
+part of last byte of host address was taken into account when a match was
+attempted. -- Lubomir Kundrak
+
+--- jwhois-4.0/src/lookup.c.ipv6-match 2007-12-04 17:09:57.000000000 +0100
++++ jwhois-4.0/src/lookup.c 2007-12-04 17:10:20.000000000 +0100
+@@ -149,7 +149,7 @@ static int ipv6_address_is_in_network(co
+ }
+ /* i == bits / 8 */
+ if (bits % 8 != 0
+- && (addr->s6_addr[i] & (0xFFu << (bits % 8))) != net->s6_addr[i])
++ && (addr->s6_addr[i] & (0xFFu << 8-(bits % 8))) != net->s6_addr[i])
+ return 0;
+ return 1;
+ }
diff --git a/src/patches/jwhois-4.0-multi-homed.patch b/src/patches/jwhois-4.0-multi-homed.patch
new file mode 100644
index 000000000..05d6f46af
--- /dev/null
+++ b/src/patches/jwhois-4.0-multi-homed.patch
@@ -0,0 +1,15 @@
+diff -up jwhois-4.0/src/utils.c.orig jwhois-4.0/src/utils.c
+--- jwhois-4.0/src/utils.c.orig 2010-09-29 16:19:24.453608330 +0200
++++ jwhois-4.0/src/utils.c 2010-09-29 16:20:10.686608189 +0200
+@@ -292,7 +292,10 @@ make_connect(const char *host, int port)
+ if (error < 0 || retval)
+ {
+ close (sockfd);
+- return -1;
++ if (retval == ENETUNREACH)
++ continue;
++ else
++ return -1;
+ }
+
+ break;
diff --git a/src/patches/jwhois-4.0-select.patch b/src/patches/jwhois-4.0-select.patch
new file mode 100644
index 000000000..b60ec9692
--- /dev/null
+++ b/src/patches/jwhois-4.0-select.patch
@@ -0,0 +1,27 @@
+diff -ur jwhois-4.0.old/src/whois.c jwhois-4.0/src/whois.c
+--- jwhois-4.0.old/src/whois.c 2007-06-26 03:00:29.000000000 -0400
++++ jwhois-4.0/src/whois.c 2009-04-29 11:42:56.000000000 -0400
+@@ -115,6 +115,7 @@
+ unsigned int count, start_count;
+ int ret;
+ char data[MAXBUFSIZE];
++ fd_set rfds;
+
+ count = 0;
+
+@@ -124,7 +125,15 @@
+
+ do
+ {
++ FD_ZERO(&rfds);
++ FD_SET(fd, &rfds);
++ ret = select(fd + 1, &rfds, NULL, NULL, NULL);
++
++ if (ret <= 0)
++ return -1;
++
+ ret = read(fd, data, MAXBUFSIZE-1);
++
+ if (ret >= 0)
+ {
+ count += ret;