[x] Welcome to LinuxSolved.com Linux help forums, here we are a community of Linux users helping each other. It is helpful to both ie. new linux users as well experienced one. We always have our experts to help you and ofcourse members help each other, so you can ask for help any time by Registering.: Click to Register

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Linux Forums - Linux Help,Advice & support community:LinuxSolved.com  |  Forum
The LinuxSolved.com GNU/Linux User Communit - Forum
Welcome to LinuxCommunity You have just arrived to a friendly linux community which is helping Linux Users from Years.. You can be its part if you have not already joined it. Registration is FREE and is gateway to unlimited help and support to all your linux related needs. If you are an GNU/Linux supporter then you have come to the right place.
  Show Posts
Pages: [1]
1  Network Troublshooting / Linux Servers Support / trouble in writing my own external acl for Squid on: August 24, 2008, 05: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.
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){

              
           }

       }


   }




Pages: [1]
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 22, 2008, 06:10:37 AM

Login with username, password and session length
Navigation
Recent Discussions
[November 20, 2008, 11:30:52 PM]

[November 19, 2008, 07:52:41 PM]

[November 19, 2008, 07:52:36 PM]

[November 17, 2008, 10:42:59 AM]

[November 16, 2008, 12:49:47 AM]

[November 16, 2008, 12:48:58 AM]

[November 15, 2008, 08:29:02 AM]

[November 15, 2008, 08:24:41 AM]

[November 14, 2008, 05:11:50 AM]

[November 13, 2008, 03:28:22 AM]
Members
Total Members: 6226
Latest: Abhi
Stats
Total Posts: 8269
Total Topics: 2253
Online Today: 10
Online Ever: 111
(June 28, 2007, 06:47:29 AM)
Users Online
Users: 0
Guests: 8
Total: 8
Privacy Policy| Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks
Theme & TinyPortal v0.9.8 © Bloc