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.
Thanks,
------------------------
code:
package IOAcl;
import java.io.*;
import java.io.BufferedReader;
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(System.in);
try{
FileReader file = new FileReader(args[0]);
BufferedReader fileInput = new BufferedReader(file);
dbUser=fileInput.readLine();
dbPassword=fileInput.readLine();
dbUrl=fileInput.readLine();
dbDriver=fileInput.readLine();
Connection conn=null;
Class.forName (dbDriver).newInstance ();
conn = DriverManager.getConnection (dbUrl, dbUser,dbPassword);
char newLine = '\n';
int c;
String temp=new String("");
while( (c = isr.read()) != -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 || !rs.next()){
System.out.println("OK");
}else{
boolean valid=rs.getBoolean(1);
if(valid) System.out.println("OK");
else System.out.println("ERR");
}
temp="";
continue;
}
temp=temp+String.valueOf((char)c);
}
isr.close();
}catch(Exception e){
}
}
}
-- View this message in context: http://www.nabble.com/trouble-in-writing-my-own-external-acl-for-Squid-tp19128959p19128959.html Sent from the Squid - Users mailing list archive at Nabble.com.Received on Sun Aug 24 2008 - 09:18:34 MDT
This archive was generated by hypermail 2.2.0 : Mon Aug 25 2008 - 12:00:06 MDT