[Rabbit-dev] ad blocking

Luis Soltero lsoltero at globalmarinenet.com
Mon Dec 27 08:56:01 CET 2010


hi Robo,

I need some assistance configuring the database resources.  Here is what I have

The database is setup and configured with one table containing a column called hostname which contain all the banned hosts
Database: xauth (names and passwords have been changed for obvious reasons)
User: xauth
Password: xxxxxx

spider:/usr/local/RabbitDev/rabbit # mysql -p -u xauth xauth
mysql> show tables;
+---------------------+
| Tables_in_xauth |
+---------------------+
| banedhosts          |
+---------------------+
2 rows in set (0.00 sec)

mysql> select 1 from banedhosts where hostname='www.winaproduct.com';
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

when i try to start rabbit I get the following error...
Exception in thread "main" java.lang.RuntimeException: javax.naming.NotContextException: java:comp does not name a
context, bindings: {}
    at rabbit.filter.authenticate.SQLAuthenticator.<init>(SQLAuthenticator.java:42)
    at rabbit.filter.ProxyAuth.setup(ProxyAuth.java:127)
    at rabbit.proxy.HttpHeaderFilterer.loadHttpFilters(HttpHeaderFilterer.java:119)
    at rabbit.proxy.HttpHeaderFilterer.<init>(HttpHeaderFilterer.java:25)
    at rabbit.proxy.HttpProxy.loadClasses(HttpProxy.java:479)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:394)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:145)
    at rabbit.proxy.ProxyStarter.startProxy(ProxyStarter.java:69)
    at rabbit.proxy.ProxyStarter.start(ProxyStarter.java:63)
    at rabbit.proxy.ProxyStarter.main(ProxyStarter.java:18)
Caused by: javax.naming.NotContextException: java:comp does not name a context, bindings: {}
    at rabbit.jndi.HierContext.lookup(HierContext.java:116)
    at rabbit.jndi.HierContext.lookup(HierContext.java:82)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at rabbit.filter.DataSourceHelper.<init>(DataSourceHelper.java:36)
    at rabbit.filter.authenticate.SQLAuthenticator.<init>(SQLAuthenticator.java:40)
    ... 9 more


Obviously there is some issue connecting to the database. Here are my settings from rabbit.conf
[data_sources]
resources=user_database,host_blocker

[rabbit.filter.SQLBlockFilter]
resource=host_blocker
user=xauth
password=xxxxx
select=select 1 from banedhosts where hostname=?

[rabbit.filter.ProxyAuth]
cachetime=5
allow_without_auth=(^http://(www.)?globalmarinenet.com/|^http://webmail([0-9])?.gmn-usa.com)
authenticator=sql
userfile=conf/allowed
resource=user_database
user=xauth
password=xxxxxxx
select=select password from rabbit where username=?

[user_database]
#class=org.apache.derby.jdbc.ClientConnectionPoolDataSource40
#bind_name=java:comp/env/jdbc/user_database
#setServerName=userDatabase
#setDatabaseName=database
#DataSource=oracle.jdbc.OracleDataSource
#url=jdbc:oracle:thin:@127.0.0.1:1521:mysid
#setUser=
#setPassword=
class=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/xauth
setUser=xauth
setPassword=xxxxxxx

[host_blocker]
#class=org.apache.derby.jdbc.ClientConnectionPoolDataSource40
#bind_name=java:comp/env/jdbc/host_blocker_database
#setServerName=hostBlockerDatabase
#setDatabaseName=database
class=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/xauth
setUser=xauth
setPassword=xxxxx



Here is the sql authentication filter from a working rabbit 4.8 configuration.
[rabbit.filter.ProxyAuth]
one_ip_only=false
cachetime=5
allow_without_auth=(^http://(www.)?globalmarinenet.com/|^http://webmail([0-9])?.gmn-usa.com)
authenticator=sql
userfile=conf/allowed
driver=com.mysql.jdbc.Driver
user=xauth
password=xxxxxx
select=select password from rabbit where username=?


I have tried many different iterations of the above but always get the same error.  I have tried using bind_name in
several permutations but still get the java:comp does not name a context binding error.

I am sure I am making a simple mistake... Any pointers are greatly appreciated. I look forward to hearing back from you.

--luis



On 12/26/10 11:25 AM, Robert Olofsson wrote:
> On Tue, 14 Dec 2010 14:58:13 -0500
> Luis Soltero <lsoltero at globalmarinenet.com> wrote:
>
>> The idea is to first check the url against a the tables...If there is a hit then you execute the Block/NoAd.Gif action. 
>> If there is no hit then you fall through to the regex evaluation as you do now.
> Ok, I have made a first attempt at blocking based on sql lookup for the 
> hostname. (I am not fully clear if you only want the hostname or if you
> want to use more of the url).
>
> This far it is only blocking requests, there is no ad-filtering going on.
>
> The changes this far are in a way quite big.
> In order to ease database handling in different parts I have moved to 
> using DataSources that can be configured in rabbit.conf, so if you want
> to try it you have to check the changes I have mad in rabbit.conf.
> This change also affects the SQLAuthenticator, so check it's configuration
> as well.
>
> Now I really feel like I should fix the class loading so that database
> drivers can used more easily. But that will have to wait a day or two.
>
> Very, very lightly tested, but I would be happy if anyone else could
> take a look and see how it looks this far, but note that it is likely
> to crash and burn.
>
> Get the latest source from git:
> git clone http://www.khelekore.org/rabbit/rabbit.git
> (or just "git pull" if you already have a clone).
>
> /robo
>


-- 


Luis Soltero, Ph.D., MCS
Director of Software Development, CTO
Global Marine Networks, LLC
StarPilot, LLC
Tel: 865-379-8723
Fax: 865-681-5017
E-Mail: lsoltero at globalmarinenet.net
Web: http://www.globalmarinenet.net
Web: http://www.starpilotllc.com





More information about the Rabbit-dev mailing list