############################################################################
##
## Copyright (c) 2000 BalaBit IT Ltd, Budapest, Hungary
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Id: Finger.py,v 1.4.2.1.2.2 2001/09/19 19:28:47 bazsi Exp $
##
## Author  : Bazsi
## Auditor : 
## Last version: 1.10
## Notes:
##
############################################################################

"""Module defining interface to the Finger proxy.

This module defines the interface to the Finger proxy as implemented by
the Finger Zorp module.
"""

from Zorp import *
from Proxy import Proxy

class FingerProxy(Proxy):
	"""Wrapper class for the Finger protocol proxy implemented by Zorp.
	
	This proxy implements the finger protocol as specified in rfc1288.
	
	Usage
	
	  You can limit username length and response length by setting
	  various attributes. Finger proxy also has the capability
	  of limiting the number of hosts in a request, like:
	  
	    finger bazsi@balabit@tudor
	    
	  which normally results in fingering bazsi@tudor performed by
	  the host balabit. By default this proxy strips off everything
	  after and including the first '@' character, you can change
	  this behaviour by setting max_hop_count to a nonzero value.
	  
	Attributes
	
	  timeout -- I/O timeout
	  
	  max_line_length -- the maximum number of characters in a single line

	  max_hop_count -- the maximum number of '@' characters in the request
	  
	  request_username -- contains the username (can be changed during fingerRequest)

	  max_username_length -- the maximum length of the username part in the request
	  	  
	  strict_username_check -- if enabled usernames are checked strictly [a-zA-Z0-9_]
	  
	  requst_detailed -- indicates that the request was prefixed with /W requesting 
	                  long response (the -l parameter to the finger client)
	                  can be changed during the fingerRequest event
	  
	  response_header -- prepend this string to each finger response
	  
	  response_footer -- append this string to each finger response
	  
	  request_hostnames --

	"""
	def __init__(self, session, type):
		"""Constructor to initialize a FingerProxy instance.

		This constructor creates and set up a FingerProxy instance.

		Arguments

		  self -- this instance
		  
		  session -- session this instance belongs to
		
		"""
		Proxy.__init__(self, "finger", session, type)

	def fingerRequest(self, username, hostname):
		"""Function to process a given finger request.
		
		This function is called by the finger proxy to process a 
		request. It has a chance to change request specific
		attributes.
		
		Arguments
		
		  self -- this instance
		  
		  username -- the username to be fingered
		  
		  hostname -- The hosts where finger will go trough.
		"""
		return Z_ACCEPT

	def config(self):
		pass