[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  |  Network Troublshooting  |  Linux Servers Support  |  Topic: trouble in writing my own external acl for Squid
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.
Pages: [1]
  Print  
Author Topic: trouble in writing my own external acl for Squid  (Read 217 times)
0 Members and 1 Guest are viewing this topic.
Farzaneh
New Member

Offline Offline

Posts: 1


View Profile
« 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){

              
           }

       }


   }




Logged
Linux Forums - Linux Help,Advice & support community:LinuxSolved.com
   

 Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Trouble with Squid startup Linux Servers Support segun1ng 2 5390 Last post September 28, 2004, 02:58:32 PM
by etomeo
Can't get the external PC speakers to work Linux Audio Support Steve_tan71 2 1031 Last post August 22, 2005, 03:21:27 AM
by Steve_tan71
External Modem Linux Application Mikal 0 756 Last post July 03, 2006, 12:40:37 AM
by Mikal
Linking External Networks General Networking Support in Linux allen875 1 331 Last post August 19, 2007, 02:50:59 PM
by Ricky
Bloacking all external access and allwoing few websites and few external ips General Networking Support in Linux maheshanw 1 163 Last post October 21, 2008, 11:41:20 PM
by aktiwari4u
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 01, 2008, 09:58:30 PM

Login with username, password and session length
Navigation
Recent Discussions
[November 29, 2008, 02:23:49 PM]

[November 29, 2008, 02:14:14 PM]

[November 29, 2008, 04:00:36 AM]

[November 28, 2008, 07:05:28 AM]

[November 28, 2008, 07:04:39 AM]

[November 28, 2008, 06:58:16 AM]

[November 28, 2008, 06:47:09 AM]

[November 26, 2008, 11:53:32 AM]

[November 26, 2008, 04:00:22 AM]

[November 25, 2008, 06:44:47 PM]
Members
Total Members: 6252
Latest: rash31
Stats
Total Posts: 8285
Total Topics: 2257
Online Today: 34
Online Ever: 111
(June 28, 2007, 06:47:29 AM)
Users Online
Users: 0
Guests: 9
Total: 9
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