along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Send email via NNCP
+// Send execution command via NNCP
package main
import (
func usage() {
fmt.Fprintf(os.Stderr, nncp.UsageHeader())
- fmt.Fprintf(os.Stderr, "nncp-mail -- send email\n\n")
- fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE USER ...\nOptions:\n", os.Args[0])
+ fmt.Fprintf(os.Stderr, "nncp-exec -- send execution command\n\n")
+ fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE HANDLE [ARG0 ARG1 ...]\nOptions:\n", os.Args[0])
flag.PrintDefaults()
}
func main() {
var (
- cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
- niceRaw = flag.Int("nice", nncp.DefaultNiceMail, "Outbound packet niceness")
- minSize = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB")
- viaOverride = flag.String("via", "", "Override Via path to destination node")
- spoolPath = flag.String("spool", "", "Override path to spool")
- logPath = flag.String("log", "", "Override path to logfile")
- quiet = flag.Bool("quiet", false, "Print only errors")
- debug = flag.Bool("debug", false, "Print debug messages")
- version = flag.Bool("version", false, "Print version information")
- warranty = flag.Bool("warranty", false, "Print warranty information")
+ cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
+ niceRaw = flag.Int("nice", nncp.DefaultNiceExec, "Outbound packet niceness")
+ replyNiceRaw = flag.Int("replynice", nncp.DefaultNiceFile, "Possible reply packet niceness")
+ minSize = flag.Uint64("minsize", 0, "Minimal required resulting packet size, in KiB")
+ viaOverride = flag.String("via", "", "Override Via path to destination node")
+ spoolPath = flag.String("spool", "", "Override path to spool")
+ logPath = flag.String("log", "", "Override path to logfile")
+ quiet = flag.Bool("quiet", false, "Print only errors")
+ debug = flag.Bool("debug", false, "Print debug messages")
+ version = flag.Bool("version", false, "Print version information")
+ warranty = flag.Bool("warranty", false, "Print warranty information")
)
flag.Usage = usage
flag.Parse()
log.Fatalln("-nice must be between 1 and 255")
}
nice := uint8(*niceRaw)
+ if *replyNiceRaw < 1 || *replyNiceRaw > 255 {
+ log.Fatalln("-replynice must be between 1 and 255")
+ }
+ replyNice := uint8(*replyNiceRaw)
ctx, err := nncp.CtxFromCmdline(*cfgPath, *spoolPath, *logPath, *quiet, *debug)
if err != nil {
body, err := ioutil.ReadAll(bufio.NewReader(os.Stdin))
if err != nil {
- log.Fatalln("Can not read mail body from stdin:", err)
+ log.Fatalln("Can not read body from stdin:", err)
}
- if err = ctx.TxMail(
+ if err = ctx.TxExec(
node,
nice,
- strings.Join(flag.Args()[1:], " "),
+ replyNice,
+ flag.Args()[1],
+ flag.Args()[2:],
body,
int64(*minSize)*1024,
); err != nil {