Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
smtpd Namespace Reference

Data Structures

class  Devnull
 
class  SMTPChannel
 
class  SMTPServer
 
class  DebuggingServer
 
class  PureProxy
 
class  MailmanProxy
 
class  Options
 

Functions

def usage
 
def parseargs
 

Variables

list __all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]
 
list program = sys.argv[0]
 
string __version__ = 'Python SMTP proxy version 0.2'
 
tuple DEBUGSTREAM = Devnull()
 
string NEWLINE = '\n'
 
string EMPTYSTRING = ''
 
string COMMASPACE = ', '
 
tuple options = parseargs()
 
tuple nobody = pwd.getpwnam('nobody')
 
tuple class_ = getattr(__main__, options.classname)
 
tuple proxy
 

Function Documentation

def smtpd.parseargs ( )

Definition at line 464 of file smtpd.py.

References getopt.getopt(), and usage().

465 def parseargs():
466  global DEBUGSTREAM
467  try:
468  opts, args = getopt.getopt(
469  sys.argv[1:], 'nVhc:d',
470  ['class=', 'nosetuid', 'version', 'help', 'debug'])
471  except getopt.error, e:
472  usage(1, e)
473 
474  options = Options()
475  for opt, arg in opts:
476  if opt in ('-h', '--help'):
477  usage(0)
478  elif opt in ('-V', '--version'):
479  print >> sys.stderr, __version__
480  sys.exit(0)
481  elif opt in ('-n', '--nosetuid'):
482  options.setuid = 0
483  elif opt in ('-c', '--class'):
484  options.classname = arg
485  elif opt in ('-d', '--debug'):
486  DEBUGSTREAM = sys.stderr
487 
488  # parse the rest of the arguments
489  if len(args) < 1:
490  localspec = 'localhost:8025'
491  remotespec = 'localhost:25'
492  elif len(args) < 2:
493  localspec = args[0]
494  remotespec = 'localhost:25'
495  elif len(args) < 3:
496  localspec = args[0]
497  remotespec = args[1]
498  else:
499  usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args))
500 
501  # split into host/port pairs
502  i = localspec.find(':')
503  if i < 0:
504  usage(1, 'Bad local spec: %s' % localspec)
505  options.localhost = localspec[:i]
506  try:
507  options.localport = int(localspec[i+1:])
508  except ValueError:
509  usage(1, 'Bad local port: %s' % localspec)
510  i = remotespec.find(':')
511  if i < 0:
512  usage(1, 'Bad remote spec: %s' % remotespec)
513  options.remotehost = remotespec[:i]
514  try:
515  options.remoteport = int(remotespec[i+1:])
516  except ValueError:
517  usage(1, 'Bad remote port: %s' % remotespec)
518  return options
519 
520 
def smtpd.usage (   code,
  msg = '' 
)

Definition at line 100 of file smtpd.py.

101 def usage(code, msg=''):
102  print >> sys.stderr, __doc__ % globals()
103  if msg:
104  print >> sys.stderr, msg
105  sys.exit(code)
106 
107 

Variable Documentation

list __all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]

Definition at line 82 of file smtpd.py.

string __version__ = 'Python SMTP proxy version 0.2'

Definition at line 85 of file smtpd.py.

tuple class_ = getattr(__main__, options.classname)

Definition at line 540 of file smtpd.py.

string COMMASPACE = ', '

Definition at line 96 of file smtpd.py.

tuple DEBUGSTREAM = Devnull()

Definition at line 93 of file smtpd.py.

string EMPTYSTRING = ''

Definition at line 95 of file smtpd.py.

string NEWLINE = '\n'

Definition at line 94 of file smtpd.py.

tuple nobody = pwd.getpwnam('nobody')

Definition at line 531 of file smtpd.py.

tuple options = parseargs()

Definition at line 522 of file smtpd.py.

list program = sys.argv[0]

Definition at line 84 of file smtpd.py.

tuple proxy
Initial value:
1 = class_((options.localhost, options.localport),
2  (options.remotehost, options.remoteport))

Definition at line 541 of file smtpd.py.