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
84bd61aa
Commit
84bd61aa
authored
16 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Wrap @noreply callbacks to return NOREPLY only when so negotiated.
parent
372fad6a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Milter/__init__.py
+10
-4
10 additions, 4 deletions
Milter/__init__.py
with
10 additions
and
4 deletions
Milter/__init__.py
+
10
−
4
View file @
84bd61aa
...
@@ -46,11 +46,15 @@ def nocallback(func):
...
@@ -46,11 +46,15 @@ def nocallback(func):
def
noreply
(
func
):
def
noreply
(
func
):
try
:
try
:
func
.
milter_protocol
=
OPTIONAL_CALLBACKS
[
func
.
__name__
][
0
]
nr_mask
=
func
.
milter_protocol
=
OPTIONAL_CALLBACKS
[
func
.
__name__
][
0
]
except
KeyErro
:
except
KeyErro
:
raise
ValueError
(
raise
ValueError
(
'
@noreply applied to non-optional method:
'
+
func
.
__name__
)
'
@noreply applied to non-optional method:
'
+
func
.
__name__
)
return
func
def
wrapper
(
self
,
*
args
):
rc
=
func
(
self
,
*
args
)
if
self
.
_protocol
&
nr_mask
:
return
NOREPLY
return
rc
return
wrapper
class
DisabledAction
(
RuntimeError
):
class
DisabledAction
(
RuntimeError
):
pass
pass
...
@@ -64,6 +68,7 @@ class Base(object):
...
@@ -64,6 +68,7 @@ class Base(object):
def
_setctx
(
self
,
ctx
):
def
_setctx
(
self
,
ctx
):
self
.
_ctx
=
ctx
self
.
_ctx
=
ctx
self
.
_actions
=
CURR_ACTS
# all actions enabled by default
self
.
_actions
=
CURR_ACTS
# all actions enabled by default
self
.
_protocol
=
0
# no protocol options by default
if
ctx
:
if
ctx
:
ctx
.
setpriv
(
self
)
ctx
.
setpriv
(
self
)
def
log
(
self
,
*
msg
):
pass
def
log
(
self
,
*
msg
):
pass
...
@@ -89,7 +94,7 @@ class Base(object):
...
@@ -89,7 +94,7 @@ class Base(object):
def
abort
(
self
):
return
CONTINUE
def
abort
(
self
):
return
CONTINUE
def
close
(
self
):
return
CONTINUE
def
close
(
self
):
return
CONTINUE
# Return mask of SMFIP_N.. protocol bits to clear for this class
# Return mask of SMFIP_N.. protocol
option
bits to clear for this class
@classmethod
@classmethod
def
protocol_mask
(
klass
):
def
protocol_mask
(
klass
):
try
:
try
:
...
@@ -109,7 +114,8 @@ class Base(object):
...
@@ -109,7 +114,8 @@ class Base(object):
def
negotiate
(
self
,
opts
):
def
negotiate
(
self
,
opts
):
try
:
try
:
self
.
_actions
,
p
,
f1
,
f2
=
opts
self
.
_actions
,
p
,
f1
,
f2
=
opts
opts
[
1
]
=
p
&
~
self
.
protocol_mask
()
&
~
P_RCPT_REJ
&
~
P_HDR_LEADSPC
opts
[
1
]
=
self
.
_protocol
=
\
p
&
~
self
.
protocol_mask
()
&
~
P_RCPT_REJ
&
~
P_HDR_LEADSPC
opts
[
2
]
=
0
opts
[
2
]
=
0
opts
[
3
]
=
0
opts
[
3
]
=
0
self
.
log
(
"
Negotiated:
"
,
opts
)
self
.
log
(
"
Negotiated:
"
,
opts
)
...
...
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