use of net.sourceforge.myvd.server.ServerCore in project OpenUnison by TremoloSecurity.
the class MyVDServer method main.
public static void main(String[] args) throws Exception {
ListenerConfig config = null;
logger.info("Starting MyVirtualDirectory " + net.sourceforge.myvd.server.Server.VERSION);
if (args.length == 0) {
logger.error("One argument required, path to yaml or json config");
System.exit(1);
} else if (args[0].endsWith(".yaml")) {
logger.info("Parsing YAML : '" + args[0] + "'");
Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(new FileInputStream(args[0]));
JSONObject jsonObject = new JSONObject(map);
String json = jsonObject.toJSONString();
config = gson.fromJson(json, ListenerConfig.class);
} else {
logger.info("Parsing JSON : '" + args[0] + "'");
config = gson.fromJson(new InputStreamReader(new FileInputStream(args[0])), ListenerConfig.class);
}
final ListenerConfig fconfig = config;
logger.info("Config Open Port : '" + config.getOpenPort() + "'");
logger.info("Config Secure Port : '" + config.getSecurePort() + "'");
logger.info("Config TLS Client Auth Mode : '" + config.getClientAuth() + "'");
logger.info("Config TLS Allowed Client Subjects : '" + config.getAllowedClientNames() + "'");
logger.info("Config TLS Protocols : '" + config.getAllowedTlsProtocols() + "'");
logger.info("Config TLS Ciphers : '" + config.getCiphers() + "'");
logger.info("Config Path to Deployment : '" + config.getPathToDeployment() + "'");
logger.info("Config Path to Environment File : '" + config.getPathToEnvFile() + "'");
logger.info("Support socket shutdown : " + config.isSocketShutdownListener());
if (config.isSocketShutdownListener()) {
logger.info("Socket shutdown host : '" + config.getSocketShutdownHost() + "'");
logger.info("Socket shutdown port : '" + config.getSocketShutdownPort() + "'");
logger.info("Socket shutdown command : '" + config.getSocketShutdownCommand() + "'");
}
String environmentsFile = config.getPathToEnvFile() + "/myvd.env";
String configFile = config.getPathToDeployment() + "/myvd.conf";
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(environmentsFile)));
String line = null;
while ((line = in.readLine()) != null) {
if (line.indexOf('=') == 1) {
continue;
} else {
String name = line.substring(0, line.indexOf('='));
String value = line.substring(line.indexOf('=') + 1);
logger.info("Adding variable : '" + name + "'");
System.setProperty(name, value);
}
}
String mergedConfig = OpenUnisonConfigLoader.generateOpenUnisonConfig(configFile);
props = new Properties();
props.load(new ByteArrayInputStream(mergedConfig.getBytes()));
myvdServerCore = new ServerCore(props);
myvdServerCore.startService();
globalChain = myvdServerCore.getGlobalChain();
router = myvdServerCore.getRouter();
startMyVDListener(fconfig);
}
use of net.sourceforge.myvd.server.ServerCore in project OpenUnison by TremoloSecurity.
the class ForRemoval method loadMyVD.
@Override
public void loadMyVD(String path, String myVdPath) throws Exception {
String myvdConfigPath = unisonConfig.getMyvdConfig();
if (myvdConfigPath != null) {
Properties props = new Properties();
InputStream in;
if (myvdConfigPath.startsWith("WEB-INF")) {
in = new ByteArrayInputStream(OpenUnisonConfigLoader.generateOpenUnisonConfig(ctx.getRealPath("/" + myvdConfigPath)).getBytes("UTF-8"));
} else {
in = new ByteArrayInputStream(OpenUnisonConfigLoader.generateOpenUnisonConfig(myvdConfigPath).getBytes("UTF-8"));
}
props.load(in);
this.myvd = new ServerCore(props);
this.myvd.startService();
this.con = new MyVDConnection(this.myvd);
}
}
Aggregations