December 07, 2021, 12:47:22 AM

News : Linux Help Community Forum..

Author Topic: trouble in writing my own external acl for Squid  (Read 2175 times)

Offline Farzaneh

  • New Member
  • Posts: 1
trouble in writing my own external acl for Squid
« on: August 24, 2008, 09:12:53 AM »
Hi all,
I need to write an acl for squid. this is writen in java. when I check my program with stdin & stdout , it works fine. I also has tried adding a simple test acl (getting IDENt and always print OK)to squid and it works fine, I mean I have no problem with external acl configuration for squid.

But when I replace the simple test acl with the main one ,Squid does'nt works.It restarts successfully but when I try to connect to the server ,it says that the server is not working well.

my acl should checks if the user has not used more than 1G in the last month. I have writen a daemon that reads access.log and stores data in a database (I use mysql) and the only thing the acl does , is connecting to database, finding username in a table and print OK or ERR base on a boolean col in table.
I have the impression ,that maybe my program takes too long and makes squid to crash.
I've put my acl code here too.
Please help me ,wether fixing my own program or if you know of any other way that I could implement this restriction for squid users.


package IOAcl;



import java.sql.*;

public class AclIO {

   static String configFilePath="/var/log/squid/aclConfig.txt";

   static String dbUser="root";

   static String dbPassword="123456";

   static String dbUrl="jdbc:mysql://localhost:3308/proxy";

   static String dbDriver="com.mysql.jdbc.Driver";

   public static void main(String[] args) throws IOException {

           InputStreamReader isr = new InputStreamReader(;


               FileReader file = new FileReader(args[0]);

               BufferedReader fileInput = new BufferedReader(file);





               Connection conn=null;

               Class.forName (dbDriver).newInstance ();

               conn = DriverManager.getConnection (dbUrl, dbUser,dbPassword);

               char newLine = '\n';

               int c;

               String temp=new String("");

               while( (c = != -1 ) {

                  if((char)c == newLine) {

                     PreparedStatement pst=conn.prepareStatement("SELECT valid FROM "+

                     "users WHERE ident=?");

                     pst.setString(1, temp);

                     ResultSet rs=pst.executeQuery();

                     if(rs==null || !{



                        boolean valid=rs.getBoolean(1);

                        if(valid) System.out.println("OK");

                        else System.out.println("ERR");







           }catch(Exception e){