use of io.kamax.mxisd.config.MxisdConfig in project mxisd by kamax-io.
the class MxisdStandaloneExec method main.
public static void main(String[] args) {
String logLevel = System.getenv("MXISD_LOG_LEVEL");
if (StringUtils.isNotBlank(logLevel)) {
System.setProperty("org.slf4j.simpleLogger.log.io.kamax.mxisd", logLevel);
}
try {
MxisdConfig cfg = null;
Iterator<String> argsIt = Arrays.asList(args).iterator();
while (argsIt.hasNext()) {
String arg = argsIt.next();
if (StringUtils.equalsAny(arg, "-h", "--help", "-?", "--usage")) {
System.out.println("Available arguments:" + System.lineSeparator());
System.out.println(" -h, --help Show this help message");
System.out.println(" --version Print the version then exit");
System.out.println(" -c, --config Set the configuration file location");
System.out.println(" -v Increase log level (log more info)");
System.out.println(" -vv Further increase log level");
System.out.println(" ");
System.exit(0);
} else if (StringUtils.equals(arg, "-v")) {
System.setProperty("org.slf4j.simpleLogger.log.io.kamax.mxisd", "debug");
} else if (StringUtils.equals(arg, "-vv")) {
System.setProperty("org.slf4j.simpleLogger.log.io.kamax.mxisd", "trace");
} else if (StringUtils.equalsAny(arg, "-c", "--config")) {
String cfgFile = argsIt.next();
cfg = YamlConfigLoader.loadFromFile(cfgFile);
} else if (StringUtils.equals("--version", arg)) {
System.out.println(Mxisd.Version);
System.exit(0);
} else {
System.err.println("Invalid argument: " + arg);
System.err.println("Try '--help' for available arguments");
System.exit(1);
}
}
if (Objects.isNull(cfg)) {
cfg = YamlConfigLoader.tryLoadFromFile("mxisd.yaml").orElseGet(MxisdConfig::new);
}
log.info("mxisd starting");
log.info("Version: {}", Mxisd.Version);
HttpMxisd mxisd = new HttpMxisd(cfg);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
mxisd.stop();
log.info("mxisd stopped");
}));
mxisd.start();
log.info("mxisd started");
} catch (ConfigurationException e) {
log.error(e.getDetailedMessage());
log.error(e.getMessage());
System.exit(2);
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
}
use of io.kamax.mxisd.config.MxisdConfig in project mxisd by kamax-io.
the class AuthManagerTest method beforeClass.
// FIXME we should be able to easily build the class ourselves
// FIXME use constants
@BeforeClass
public static void beforeClass() {
MxisdConfig cfg = new MxisdConfig();
cfg.getMatrix().setDomain("localhost");
cfg.getKey().setPath(":memory:");
cfg.getStorage().getProvider().getSqlite().setDatabase(":memory:");
MemoryThreePid mem3pid = new MemoryThreePid();
mem3pid.setMedium("email");
mem3pid.setAddress("john@localhost");
MemoryIdentityConfig validCfg = new MemoryIdentityConfig();
validCfg.setUsername("john");
validCfg.setPassword("doe");
validCfg.getThreepids().add(mem3pid);
MemoryIdentityConfig illegalUser = new MemoryIdentityConfig();
illegalUser.setUsername("JANE");
illegalUser.setPassword("doe");
cfg.getMemory().setEnabled(true);
cfg.getMemory().getIdentities().add(validCfg);
cfg.getMemory().getIdentities().add(illegalUser);
Mxisd m = new Mxisd(cfg);
m.start();
mgr = m.getAuth();
}
use of io.kamax.mxisd.config.MxisdConfig in project mxisd by kamax-io.
the class MxisdTest method before.
@Before
public void before() {
MxisdConfig cfg = MxisdConfig.forDomain("localhost").inMemory();
MemoryThreePid mem3pid = new MemoryThreePid();
mem3pid.setMedium("email");
mem3pid.setAddress("john@localhost");
MemoryIdentityConfig memCfg = new MemoryIdentityConfig();
memCfg.setUsername("john");
memCfg.getThreepids().add(mem3pid);
cfg.getMemory().setEnabled(true);
cfg.getMemory().getIdentities().add(memCfg);
m = new Mxisd(cfg);
m.start();
}
use of io.kamax.mxisd.config.MxisdConfig in project mxisd by kamax-io.
the class HomeserverFederationResolverTest method beforeClass.
@BeforeClass
public static void beforeClass() {
CloseableHttpClient client = HttpClients.custom().setUserAgent(Mxisd.Agent).setMaxConnPerRoute(Integer.MAX_VALUE).setMaxConnTotal(Integer.MAX_VALUE).build();
FederationDnsOverwrite fedDns = new FederationDnsOverwrite(new MxisdConfig().getDns().getOverwrite());
resolver = new HomeserverFederationResolver(fedDns, client);
}
use of io.kamax.mxisd.config.MxisdConfig in project mxisd by kamax-io.
the class EmailNotificationTest method before.
@Before
public void before() {
EmailSmtpConfig smtpCfg = new EmailSmtpConfig();
smtpCfg.setPort(3025);
smtpCfg.setLogin(user);
smtpCfg.setPassword(user);
EmailConfig eCfg = new EmailConfig();
eCfg.setConnector(EmailSmtpConnector.ID);
eCfg.getIdentity().setFrom(sender);
eCfg.getIdentity().setName(senderName);
eCfg.getConnectors().put(EmailSmtpConnector.ID, GsonUtil.makeObj(smtpCfg));
MxisdConfig cfg = new MxisdConfig();
cfg.getMatrix().setDomain(domain);
cfg.getKey().setPath(":memory:");
cfg.getStorage().getProvider().getSqlite().setDatabase(":memory:");
cfg.getThreepid().getMedium().put(ThreePidMedium.Email.getId(), GsonUtil.makeObj(eCfg));
m = new Mxisd(cfg);
m.start();
gm = new GreenMail(ServerSetupTest.SMTP_IMAP);
gm.start();
}
Aggregations