Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
4c659c7f
Commit
4c659c7f
authored
20 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Acknowlege that current env callback protocol is entrenched.
parent
3e479524
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Milter/__init__.py
+22
-11
22 additions, 11 deletions
Milter/__init__.py
with
22 additions
and
11 deletions
Milter/__init__.py
+
22
−
11
View file @
4c659c7f
...
@@ -141,16 +141,28 @@ def closecallback(ctx):
...
@@ -141,16 +141,28 @@ def closecallback(ctx):
m
.
_setctx
(
None
)
# release milterContext
m
.
_setctx
(
None
)
# release milterContext
return
rc
return
rc
def
dictfromlist
(
args
):
"
Convert ESMTP parm list to keyword dictionary.
"
kw
=
{}
for
s
in
args
:
pos
=
s
.
find
(
'
=
'
)
if
pos
>
0
:
kw
[
s
[:
pos
].
upper
()]
=
s
[
pos
+
1
:]
return
kw
def
envcallback
(
c
,
args
):
def
envcallback
(
c
,
args
):
"""
C
onvert
ESMTP parms to keyword parameters.
"""
C
all function c with
ESMTP parms
converted
to keyword parameters.
Can be used in the envfrom and/or envrcpt callbacks to process
Can be used in the envfrom and/or envrcpt callbacks to process
ESMTP parameters as python keyword parameters.
"""
ESMTP parameters as python keyword parameters.
"""
kw
=
{}
kw
=
{}
pargs
=
[
args
[
0
]]
for
s
in
args
[
1
:]:
for
s
in
args
[
1
:]:
pos
=
s
.
find
(
'
=
'
)
pos
=
s
.
find
(
'
=
'
)
if
pos
>
0
:
if
pos
>
0
:
kw
[
s
[:
pos
]]
=
s
[
pos
+
1
:]
kw
[
s
[:
pos
].
upper
()]
=
s
[
pos
+
1
:]
return
apply
(
c
,
args
,
kw
)
else
:
pargs
.
append
(
s
)
return
c
(
*
pargs
,
**
kw
)
def
runmilter
(
name
,
socketname
,
timeout
=
0
):
def
runmilter
(
name
,
socketname
,
timeout
=
0
):
# This bit is here on the assumption that you will be starting this filter
# This bit is here on the assumption that you will be starting this filter
...
@@ -177,14 +189,13 @@ def runmilter(name,socketname,timeout = 0):
...
@@ -177,14 +189,13 @@ def runmilter(name,socketname,timeout = 0):
# milter.set_flags(milter.ADDHDRS)
# milter.set_flags(milter.ADDHDRS)
milter
.
set_connect_callback
(
connectcallback
)
milter
.
set_connect_callback
(
connectcallback
)
milter
.
set_helo_callback
(
lambda
ctx
,
host
:
ctx
.
getpriv
().
hello
(
host
))
milter
.
set_helo_callback
(
lambda
ctx
,
host
:
ctx
.
getpriv
().
hello
(
host
))
milter
.
set_envfrom_callback
(
lambda
ctx
,
*
str
:
# For envfrom and envrcpt, we would like to convert ESMTP parms to keyword
ctx
.
getpriv
().
envfrom
(
*
str
))
# parms, but then all existing users would have to include **kw to accept
# envcallback(ctx.getpriv().envfrom,str))
# arbitrary keywords without crashing. We do provide envcallback and
milter
.
set_envrcpt_callback
(
lambda
ctx
,
*
str
:
# dictfromlist to make parsing the ESMTP args convenient.
ctx
.
getpriv
().
envrcpt
(
*
str
))
milter
.
set_envfrom_callback
(
lambda
ctx
,
*
str
:
ctx
.
getpriv
().
envfrom
(
*
str
))
# envcallback(ctx.getpriv().envrcpt,str))
milter
.
set_envrcpt_callback
(
lambda
ctx
,
*
str
:
ctx
.
getpriv
().
envrcpt
(
*
str
))
milter
.
set_header_callback
(
lambda
ctx
,
fld
,
val
:
milter
.
set_header_callback
(
lambda
ctx
,
fld
,
val
:
ctx
.
getpriv
().
header
(
fld
,
val
))
ctx
.
getpriv
().
header
(
fld
,
val
))
milter
.
set_eoh_callback
(
lambda
ctx
:
ctx
.
getpriv
().
eoh
())
milter
.
set_eoh_callback
(
lambda
ctx
:
ctx
.
getpriv
().
eoh
())
milter
.
set_body_callback
(
lambda
ctx
,
chunk
:
ctx
.
getpriv
().
body
(
chunk
))
milter
.
set_body_callback
(
lambda
ctx
,
chunk
:
ctx
.
getpriv
().
body
(
chunk
))
milter
.
set_eom_callback
(
lambda
ctx
:
ctx
.
getpriv
().
eom
())
milter
.
set_eom_callback
(
lambda
ctx
:
ctx
.
getpriv
().
eom
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment