Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
f328b974
Commit
f328b974
authored
16 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Support all the different spamc/spamd commands, plus an extra "process if below
threshold" optional feature (with '-T').
parent
6a67610f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/spamc.js
+48
-10
48 additions, 10 deletions
exec/spamc.js
with
48 additions
and
10 deletions
exec/spamc.js
+
48
−
10
View file @
f328b974
// spamc.js
// SpamAssasin client for Synchronet
// For use as mailproc.ini script to check messages with spamd
// For use as mailproc.ini script to check messages against a running/listening spamd
// Example mailproc.ini entries:
// [spamc.js -c]
// $Id$
load
(
'
sockdefs.js
'
);
load
(
'
salib.js
'
);
var
spamd_address
=
'
127.0.0.1
'
;
var
spamd_tcp_port
=
783
;
function
main
()
{
var
address
=
'
127.0.0.1
'
;
var
tcp_port
=
783
;
var
user
;
var
cmd
=
'
PROCESS
'
;
// Default: process
var
threshold
;
// Process arguments:
for
(
i
in
argv
)
{
if
(
argv
[
i
]
==
'
-d
'
||
argv
[
i
]
==
'
--dest
'
)
spamd_
address
=
argv
[
++
i
];
if
(
argv
[
i
]
==
'
-d
'
||
argv
[
i
]
==
'
--dest
'
)
address
=
argv
[
++
i
];
// Note: only one address supported (unlike spamc)
else
if
(
argv
[
i
]
==
'
-p
'
||
argv
[
i
]
==
'
--port
'
)
spamd_tcp_port
=
Number
(
argv
[
++
i
]);
tcp_port
=
Number
(
argv
[
++
i
]);
else
if
(
argv
[
i
]
==
'
-u
'
||
argv
[
i
]
==
'
--username
'
)
user
=
argv
[
++
i
];
else
if
(
argv
[
i
]
==
'
-T
'
||
argv
[
i
]
==
'
--threshold
'
)
threshold
=
parseFloat
(
argv
[
++
i
]);
else
if
(
argv
[
i
]
==
'
-c
'
||
argv
[
i
]
==
'
--check
'
)
cmd
=
'
CHECK
'
;
else
if
(
argv
[
i
]
==
'
-y
'
||
argv
[
i
]
==
'
--tests
'
)
cmd
=
'
SYMBOLS
'
;
else
if
(
argv
[
i
]
==
'
-R
'
||
argv
[
i
]
==
'
--full
'
)
cmd
=
'
REPORT
'
;
else
if
(
argv
[
i
]
==
'
-r
'
||
argv
[
i
]
==
'
--fullspam
'
)
cmd
=
'
REPORT_IFSPAM
'
;
}
var
msg
=
new
SPAMC_Message
(
message_text_filename
,
spamd_
address
,
spamd_
tcp_port
);
var
msg
=
new
SPAMC_Message
(
message_text_filename
,
address
,
tcp_port
,
user
);
if
(
msg
===
false
)
return
;
var
ret
=
msg
.
check
();
msg
.
debug
=
true
;
log
(
LOG_INFO
,
"
spamc: Executing command:
"
+
cmd
);
var
ret
=
msg
.
DoCommand
(
cmd
);
if
(
ret
===
false
)
return
;
if
(
ret
.
score
!=
undefined
)
{
log
(
LOG_INFO
,
"
spamc: Score:
"
+
ret
.
score
+
'
/
'
+
ret
.
threshold
);
if
(
threshold
&&
ret
.
score
<
threshold
)
var
ret
=
msg
.
DoCommand
(
cmd
=
'
PROCESS
'
);
}
if
(
cmd
==
'
PROCESS
'
)
{
var
msg_file
=
new
File
(
message_text_filename
);
if
(
!
msg_file
.
open
(
"
w
"
))
{
log
(
LOG_ERR
,
format
(
"
spamc: !ERROR %d opening message text file: %s
"
,
msg_file
.
error
,
message_text_filename
));
return
;
}
msg_file
.
write
(
ret
.
message
);
msg_file
.
close
();
return
;
}
if
(
!
ret
.
isSpam
)
return
;
var
error_file
=
new
File
(
processing_error_filename
);
...
...
@@ -35,7 +72,8 @@ function main()
,
error_file
.
error
,
processing_error_filename
));
return
;
}
error_file
.
writeln
(
"
SpamAssassin rejected your mail:
"
+
ret
.
score
+
'
/
'
+
ret
.
threshold
);
error_file
.
writeln
(
"
SpamAssassin rejected your mail:
"
+
ret
.
score
+
'
/
'
+
ret
.
threshold
+
'
'
+
ret
.
symbols
);
error_file
.
close
();
}
...
...
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