Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smtpclient-standalone #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/src/main/scripts/mta.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
:: Copyright 2010-2018 Yusef Badri - All rights reserved.
:: Copyright 2010-2024 Yusef Badri - All rights reserved.
:: Mailismus is distributed under the terms of the GNU Affero General Public License, Version 3 (AGPLv3).

@ECHO OFF
set CMD=%1
set MTAJAR=mailismus-server-${project.version}.jar
set NAFCFG=conf\naf.xml
set JVM="%JAVA_HOME%"\bin\java
set GREYNAF_BASEPORT=13000

if "%JAVA_HOME%" == "" (
set JVM=java
Expand Down
3 changes: 2 additions & 1 deletion pkg/src/main/scripts/mta.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/sh
# Copyright 2010-2018 Yusef Badri - All rights reserved.
# Copyright 2010-2024 Yusef Badri - All rights reserved.
# Mailismus is distributed under the terms of the GNU Affero General Public License, Version 3 (AGPLv3).

cd `dirname $0`/..
CMD=$1
MTAJAR=mailismus-server-${project.version}.jar
NAFCFG=conf/naf.xml
export GREYNAF_BASEPORT=13000

JVM="$JAVA_HOME"/bin/java
if [ ! -x "$JVM" ]; then JVM=java; fi
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/com/grey/mailismus/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public static AppConfig get(String cfgpath, Dispatcher d) {
private AppConfig(String cfgpath, Dispatcher dsptch) throws java.io.IOException
{
hostName = java.net.InetAddress.getLocalHost().getCanonicalHostName();
configRoot = (cfgpath.isEmpty() ? XmlConfig.BLANKCFG : XmlConfig.getSection(cfgpath, "mailserver"));
configRoot = (cfgpath == null || cfgpath.isEmpty() ? XmlConfig.BLANKCFG : XmlConfig.getSection(cfgpath, "mailserver"));

XmlConfig cfg = configRoot.getSection("application");
productName = cfg.getValue("prodname", true, "Mailismus");
announceHost = getAnnounceHost(cfg, hostName);

XmlConfig dbcfg = cfg.getSection("database"+XmlConfig.XPATH_ENABLED);
dbType = (dbcfg.exists() ? new DBHandle.Type(dbcfg, dsptch.getApplicationContext().getConfig(), dsptch.getLogger()) : null);
dbType = (dbcfg.exists() ? new DBHandle.Type(dbcfg, dsptch.getApplicationContext().getNafConfig(), dsptch.getLogger()) : null);
}

public XmlConfig getConfigQueue(String name)
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/com/grey/mailismus/DBHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public DBHandle(String name, Type dbtype, ApplicationContextNAF appctx, XmlConfi
this.name = name;
this.dbtype = dbtype;
this.log = log;
nafcfg = appctx.getConfig();
nafcfg = appctx.getNafConfig();
connurl_base = dbtype.connurl.replace(TOKEN_CONNSTR_NAME, name);
liveconns = appctx.getNamedItem(getClass().getName()+"-liveconns", () -> new HashedSet<>());

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/com/grey/mailismus/IPlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private IPlist(String name, DBHandle.Type dbtype, XmlConfig cfg, ApplicationCont
listname = name;
log = logger;

srcpath = appctx.getConfig().getURL(cfg, "sourcefile", null, true, null, getClass());
srcpath = appctx.getNafConfig().getURL(cfg, "sourcefile", null, true, null, getClass());
memlimit = cfg.getInt("mem_threshold", false, 0);
loadfactor = cfg.getInt("hashfactor", false, 10);
allow_hostnames = cfg.getBool("hostnames", true);
Expand Down
5 changes: 2 additions & 3 deletions server/src/main/java/com/grey/mailismus/MailismusApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.grey.naf.ApplicationContextNAF;
import com.grey.naf.Launcher;
import com.grey.mailismus.directory.DirectoryImpl;
import com.grey.logging.Logger;

public class MailismusApp
extends Launcher
Expand All @@ -30,13 +29,13 @@ public MailismusApp(String[] args) {
}

@Override
protected void appExecute(ApplicationContextNAF appctx, int param1, Logger bootlog) throws Exception {
protected void appExecute(ApplicationContextNAF appctx, int param1) throws Exception {
if (options.plaintxt != null) {
ByteChars plain = new ByteChars(options.plaintxt);
char[] digest = DirectoryImpl.passwordHash(plain);
System.out.println("Hashed to ["+new String(digest)+"]");
} else {
super.appExecute(appctx, param1, bootlog);
super.appExecute(appctx, param1);
}
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/com/grey/mailismus/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Task(String name, Dispatcher d, XmlConfig cfg, DirectoryFactory df, Messa
super(name, d, cfg);
Logger logger = d.getLogger();
dnsResolver = (dns == null ? null: dns);
NAFConfig nafcfg = d.getApplicationContext().getConfig();
NAFConfig nafcfg = d.getApplicationContext().getNafConfig();

String cfgfile = nafcfg.getPath(cfg, "configfile", null, false, null, null);
if (cfgfile != null) {
Expand Down Expand Up @@ -135,7 +135,7 @@ public CharSequence handleNAFManCommand(NafManCommand cmd) throws java.io.IOExce

public static ResolverDNS createResolverDNS(Dispatcher d) throws UnknownHostException {
ResolverConfig rcfg = new ResolverConfig.Builder()
.withXmlConfig(d.getApplicationContext().getConfig().getNode("dnsresolver"))
.withXmlConfig(d.getApplicationContext().getNafConfig().getNode("dnsresolver"))
.build();
return ResolverDNS.create(d, rcfg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static synchronized CachedFiles get(com.grey.naf.reactor.Dispatcher d, co
private CachedFiles(com.grey.naf.reactor.Dispatcher d, com.grey.base.config.XmlConfig cfg) throws java.io.IOException
{
dsptch = d;
NAFConfig nafcfg = dsptch.getApplicationContext().getConfig();
NAFConfig nafcfg = dsptch.getApplicationContext().getNafConfig();
String pthnam = nafcfg.getPath(cfg, "users", null, false, null, getClass());
fh_users = (pthnam == null ? null : new java.io.File(pthnam));
pthnam = nafcfg.getPath(cfg, "domains", null, false, null, getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class IMAP4Task
public IMAP4Task(String name, Dispatcher d, XmlConfig cfg) throws java.io.IOException {
super(name, d, cfg, DFLT_FACT_DTORY, DFLT_FACT_MS, null);
String grpname = "IMAP4Task="+getName();
ConcurrentListenerConfig[] lcfg = ConcurrentListenerConfig.buildMultiConfig(grpname, d.getApplicationContext().getConfig(), "listeners/listener", taskConfig(),
ConcurrentListenerConfig[] lcfg = ConcurrentListenerConfig.buildMultiConfig(grpname, d.getApplicationContext().getNafConfig(), "listeners/listener", taskConfig(),
IMAP4Protocol.TCP_PORT, IMAP4Protocol.TCP_SSLPORT, IMAP4Server.Factory.class, null);
listeners = new ListenerSet(grpname, getDispatcher(), this, this, lcfg);
if (listeners.configured() != 0) registerDirectoryOps(com.grey.mailismus.nafman.Loader.PREF_DTORY_IMAP4S);
Expand All @@ -41,10 +41,10 @@ protected boolean stopNaflet() {
}

@Override
public void eventIndication(Object obj, String eventId)
public void eventIndication(String eventId, Object evtsrc, Object data)
{
if (!(obj instanceof ListenerSet) || !EventListenerNAF.EVENTID_ENTITY_STOPPED.equals(eventId)) {
getDispatcher().getLogger().info("IMAP4Task="+getName()+" discarding unexpected event="+obj.getClass().getName()+"/"+eventId);
if (!(evtsrc instanceof ListenerSet) || !EventListenerNAF.EVENTID_ENTITY_STOPPED.equals(eventId)) {
getDispatcher().getLogger().info("IMAP4Task="+getName()+" discarding unexpected event="+eventId+"/"+evtsrc.getClass().getName()+"/"+data);
return;
}
nafletStopped();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2018 Yusef Badri - All rights reserved.
* Copyright 2013-2024 Yusef Badri - All rights reserved.
* Mailismus is distributed under the terms of the GNU Affero General Public License, Version 3 (AGPLv3).
*/
package com.grey.mailismus.imap.server;
Expand All @@ -9,6 +9,7 @@
import com.grey.mailismus.imap.IMAP4Protocol;
import com.grey.mailismus.imap.server.Defs.EnvelopeHeader;
import com.grey.mailismus.imap.server.Defs.FetchOpDef;
import com.grey.naf.BufferGenerator;
import com.grey.mailismus.imap.server.Defs.FetchOp;

/*
Expand Down Expand Up @@ -114,7 +115,7 @@ public SharedFields(com.grey.base.config.XmlConfig cfg, com.grey.naf.reactor.Dis
capa_idle = cfg.getBool("capa_idle", true);
delay_chanclose = cfg.getTime("delay_close", 0);
maximapbuf = cfg.getInt("maxtransmitbuf", true, 8 * 1024);
bufspec = new com.grey.naf.BufferGenerator(cfg, "niobuffers", 16 * 1024, 16 * 1024);
bufspec = BufferGenerator.create(cfg, "niobuffers", 16 * 1024, 16 * 1024);
transcript = com.grey.mailismus.Transcript.create(dsptch, cfg, "transcript");
full_transcript = cfg.getBool("transcript/@full", false);

Expand All @@ -131,7 +132,7 @@ public SharedFields(com.grey.base.config.XmlConfig cfg, com.grey.naf.reactor.Dis
long timeval = cfg.getTime("newmailfreq", TimeOps.parseMilliTime("20s"));
interval_newmail = Math.max(timeval, minval);

String pthnam_msgflags = cfg.getValue("keywords_map", true, dsptch.getApplicationContext().getConfig().getPathVar()+"/imap/imapkeywords");
String pthnam_msgflags = cfg.getValue("keywords_map", true, dsptch.getApplicationContext().getNafConfig().getPathVar()+"/imap/imapkeywords");
boolean dynkwords = cfg.getBool("keywords_dyn", true);
msgFlags = new MessageFlags(pthnam_msgflags, dynkwords);

Expand Down Expand Up @@ -211,7 +212,7 @@ public SharedFields(com.grey.base.config.XmlConfig cfg, com.grey.naf.reactor.Dis
imap4rsp_bye_timeout = com.grey.mailismus.Task.constBuffer(IMAP4Protocol.STATUS_UNTAGGED+IMAP4Protocol.STATUS_BYE+" idle timeout"+IMAP4Protocol.EOL);
imap4rsp_contd_ready = com.grey.mailismus.Task.constBuffer(IMAP4Protocol.STATUS_CONTD+"Ready"+IMAP4Protocol.EOL);

String pthnam = dsptch.getApplicationContext().getConfig().getPathTemp()+"/imap4server";
String pthnam = dsptch.getApplicationContext().getNafConfig().getPathTemp()+"/imap4server";
stagingDir = new java.io.File(pthnam);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public MaildirStore(com.grey.naf.reactor.Dispatcher d, com.grey.base.config.XmlC
char dflt_colon = (SysProps.isWindows ? '+' : ':');
String hostname = java.net.InetAddress.getLocalHost().getCanonicalHostName();

path_users = dsptch.getApplicationContext().getConfig().getPath(cfg, "userpath", null, true, null, getClass());
path_users = dsptch.getApplicationContext().getNafConfig().getPath(cfg, "userpath", null, true, null, getClass());
path_maildir = cfg.getValue("mailpath", true, "Maildir");
dotstuffing = cfg.getBool("dotstuffing", false);
mailismus_delivery = cfg.getBool("exclusive", false);
Expand All @@ -108,8 +108,8 @@ public MaildirStore(com.grey.naf.reactor.Dispatcher d, com.grey.base.config.XmlC
if (!virtual_users) dsptch.getLogger().info("MS-Maildir: chmod tree ["+chmod_tree+"] - msgfile="+chmod_msgfile);

//make sure the Maildir suffix chars are acceptable for this platform
FileOps.ensureDirExists(d.getApplicationContext().getConfig().getPathTemp());
java.io.File fh1 = new java.io.File(d.getApplicationContext().getConfig().getPathTemp()+"/ms_"+Thread.currentThread().getId()+".test"+FLAGS_MARKER+"x");
FileOps.ensureDirExists(d.getApplicationContext().getNafConfig().getPathTemp());
java.io.File fh1 = new java.io.File(d.getApplicationContext().getNafConfig().getPathTemp()+"/ms_"+Thread.currentThread().getId()+".test"+FLAGS_MARKER+"x");
java.io.File fh2 = new java.io.File(fh1.getParentFile(), fh1.getName()+"y");
FileOps.deleteFile(fh1);
FileOps.deleteFile(fh2);
Expand Down
Loading