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
cd336cc8
Commit
cd336cc8
authored
4 years ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Support filelists (+filename) and checking/capping of disk usage.
parent
d6102579
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/emailfiles.js
+76
-32
76 additions, 32 deletions
exec/emailfiles.js
with
76 additions
and
32 deletions
exec/emailfiles.js
+
76
−
32
View file @
cd336cc8
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
// Mnemonic (Command Key) E
// Mnemonic (Command Key) E
// Protocol Name E-mail Attachment
// Protocol Name E-mail Attachment
// Download Command Line ?emailfiles %f
// Download Command Line ?emailfiles %f
// Batch Download Command Line ?emailfiles
%s
// Batch Download Command Line ?emailfiles
+%f
// Native Executable/Script Yes
// Native Executable/Script Yes
// Supports DSZLOG Yes
// Supports DSZLOG Yes
// Socket I/O No
// Socket I/O No
...
@@ -19,6 +19,16 @@
...
@@ -19,6 +19,16 @@
// Your Synchronet Mail Server (SendMail thread) must be operational for this
// Your Synchronet Mail Server (SendMail thread) must be operational for this
// module to work as expected.
// module to work as expected.
// ctrl/modopts.ini settings:
// [emailfiles]
// maxfiles = 10
// maxfilesize = 10M
// maxpending = 100M
// prompt
// badaddr
// msgbody
// success
require
(
"
sbbsdefs.js
"
,
"
K_EDIT
"
);
require
(
"
sbbsdefs.js
"
,
"
K_EDIT
"
);
require
(
'
smbdefs.js
'
,
'
NET_INTERNET
'
);
require
(
'
smbdefs.js
'
,
'
NET_INTERNET
'
);
require
(
"
text.js
"
,
"
InvalidNetMailAddr
"
);
require
(
"
text.js
"
,
"
InvalidNetMailAddr
"
);
...
@@ -33,8 +43,12 @@ if(argc < 1) {
...
@@ -33,8 +43,12 @@ if(argc < 1) {
var
options
=
load
({},
"
modopts.js
"
,
"
emailfiles
"
);
var
options
=
load
({},
"
modopts.js
"
,
"
emailfiles
"
);
if
(
!
options
)
if
(
!
options
)
options
=
{};
options
=
{};
if
(
!
options
.
maxsize
)
if
(
!
options
.
maxfiles
)
options
.
maxsize
=
10
*
1024
*
1024
;
options
.
maxfiles
=
10
;
if
(
!
options
.
maxfilesize
)
options
.
maxfilesize
=
10
*
1024
*
1024
;
if
(
!
options
.
maxpending
)
options
.
maxpending
=
100
*
1024
*
1024
;
if
(
argv
[
0
]
===
'
-install
'
)
{
if
(
argv
[
0
]
===
'
-install
'
)
{
var
cnflib
=
load
({},
"
cnflib.js
"
);
var
cnflib
=
load
({},
"
cnflib.js
"
);
...
@@ -47,7 +61,7 @@ if(argv[0] === '-install') {
...
@@ -47,7 +61,7 @@ if(argv[0] === '-install') {
key
:
'
E
'
key
:
'
E
'
,
name
:
'
E-mail Attachment
'
,
name
:
'
E-mail Attachment
'
,
dlcmd
:
'
?emailfiles %f
'
,
dlcmd
:
'
?emailfiles %f
'
,
batdlcmd
:
'
?emailfiles
%s
'
,
batdlcmd
:
'
?emailfiles
+%f
'
,
ars
:
'
REST NOT M
'
,
ars
:
'
REST NOT M
'
,
settings
:
PROT_NATIVE
|
PROT_DSZLOG
,
settings
:
PROT_NATIVE
|
PROT_DSZLOG
});
});
...
@@ -61,56 +75,86 @@ if(argv[0] === '-install') {
...
@@ -61,56 +75,86 @@ if(argv[0] === '-install') {
function
sendfiles
()
function
sendfiles
()
{
{
var
dir
=
system
.
data_dir
+
format
(
"
file/%04u.out/
"
,
user
.
number
);
if
(
!
mkpath
(
dir
))
{
alert
(
"
Error
"
+
errno_str
+
"
making directory:
"
+
dir
);
return
errno
||
1
;
}
var
logfile
=
new
File
(
system
.
node_dir
+
"
PROTOCOL.LOG
"
);
var
logfile
=
new
File
(
system
.
node_dir
+
"
PROTOCOL.LOG
"
);
if
(
!
logfile
.
open
(
"
w
"
))
{
if
(
!
logfile
.
open
(
"
w
"
))
{
alert
(
"
Error
"
+
logfile
.
error
+
"
opening
"
+
f
.
name
);
alert
(
"
Error
"
+
logfile
.
error
+
"
opening
"
+
logfile
.
name
);
return
1
;
return
errno
||
1
;
}
}
var
msgbase
=
new
MsgBase
(
'
mail
'
);
var
msgbase
=
new
MsgBase
(
'
mail
'
);
if
(
!
msgbase
.
open
())
{
if
(
!
msgbase
.
open
())
{
alert
(
"
Error
"
+
msgbase
.
error
+
"
opening mail base
"
);
alert
(
"
Error
"
+
msgbase
.
error
+
"
opening mail base
"
);
return
1
;
return
msgbase
.
status
||
1
;
}
}
var
diskusage
=
load
({},
"
diskusage.js
"
);
var
files_sen
t
=
0
;
var
lis
t
=
[]
;
for
(
var
i
=
0
;
i
<
argc
;
i
++
)
{
for
(
var
i
=
0
;
i
<
argc
;
i
++
)
{
var
fpath
=
argv
[
i
];
if
(
argv
[
i
][
0
]
==
'
+
'
)
{
var
f
=
new
File
(
argv
[
i
].
slice
(
1
));
if
(
f
.
open
(
"
r
"
))
{
list
=
list
.
concat
(
f
.
readAll
());
f
.
close
();
}
else
alert
(
"
Error
"
+
f
.
error
+
"
opening
"
+
f
.
name
);
}
else
list
.
push
(
argv
[
i
]);
}
var
files_sent
=
0
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
if
(
!
user
.
is_sysop
&&
files_sent
>=
options
.
maxfiles
)
{
alert
(
format
(
"
Maximum files (%u) sent
"
,
options
.
maxfiles
));
break
;
}
var
fpath
=
list
[
i
];
var
fname
=
file_getname
(
fpath
);
var
fname
=
file_getname
(
fpath
);
if
(
!
file_exists
(
fpath
))
{
if
(
!
file_exists
(
fpath
))
{
alert
(
format
(
"
File (%s) does not exist
"
,
fname
));
alert
(
format
(
"
File (%s) does not exist
"
,
fname
));
continue
;
continue
;
}
}
var
size
=
file_size
(
fpath
);
var
size
=
file_size
(
fpath
);
if
(
!
user
.
is_sysop
&&
size
>
options
.
maxsize
)
{
if
(
!
user
.
is_sysop
)
{
alert
(
format
(
"
File (%s) size (%u) larger than maximum: %u bytes
"
if
(
size
>
options
.
maxfilesize
)
{
,
fname
alert
(
format
(
"
File (%s) size (%u) is larger than maximum: %u bytes
"
,
size
,
fname
,
options
.
maxsize
));
,
size
,
options
.
maxfilesize
));
continue
;
}
var
pending
=
diskusage
.
get
(
dir
+
'
*
'
);
if
(
pending
+
size
>
options
.
maxpending
)
{
alert
(
format
(
"
Bytes pending (%u) at maximum: %u bytes
"
,
pending
,
options
.
maxpending
));
continue
;
}
}
if
(
!
file_copy
(
fpath
,
dir
+
fname
))
{
alert
(
"
Error
"
+
errno_str
+
"
copying file:
"
+
fname
);
continue
;
continue
;
}
}
var
hdr
=
{
subject
:
fname
var
hdr
=
{
subject
:
fname
,
from
:
user
.
alias
,
from
:
user
.
alias
,
from_ext
:
user
.
number
,
from_net_addr
:
user
.
email
,
to
:
user
.
name
,
from_ext
:
user
.
number
,
to_net_type
:
NET_INTERNET
,
to
:
user
.
name
,
to_net_addr
:
address
,
to_net_type
:
NET_INTERNET
,
auxattr
:
MSG_FILEATTACH
|
MSG_KILLFILE
,
to_net_addr
:
address
,
attr
:
MSG_NOREPLY
// Suppress bounce messages
,
netattr
:
MSG_KILLSENT
,
auxattr
:
MSG_FILEATTACH
};
};
if
(
!
msgbase
.
save_msg
(
hdr
,
options
.
msg
||
"
Your requested file is attached.
"
))
{
if
(
!
msgbase
.
save_msg
(
hdr
,
format
(
options
.
msgbody
||
"
Your requested file (%u of %u) is attached.
"
,
i
+
1
,
list
.
length
)))
{
alert
(
"
Error
"
+
msgbase
.
error
+
"
saving msg
"
);
alert
(
"
Error
"
+
msgbase
.
error
+
"
saving msg
"
);
continue
;
continue
;
}
}
var
dir
=
system
.
data_dir
+
format
(
"
file/%04u.out/
"
,
user
.
number
);
console
.
print
(
format
(
options
.
success
||
"
Successfully attached: %s
"
,
fname
));
if
(
!
mkpath
(
dir
))
{
alert
(
"
Error
"
+
errno_str
+
"
making directory:
"
+
dir
);
continue
;
}
if
(
!
file_copy
(
fpath
,
dir
+
fname
))
{
alert
(
"
Error copying file:
"
+
fname
);
continue
;
}
console
.
print
(
format
(
options
.
success
||
"
Successfully sent: %s
"
,
fname
));
console
.
crlf
();
console
.
crlf
();
logfile
.
writeln
(
format
(
"
S %u infinite infinite 0 cps 0 errors 0 infinite %s -1
"
logfile
.
writeln
(
format
(
"
S %u infinite infinite 0 cps 0 errors 0 infinite %s -1
"
,
size
,
fpath
));
,
size
,
fpath
));
...
...
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