Search in sources :

Example 1 with ServerCore

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);
}
Also used : JSONObject(org.json.simple.JSONObject) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) ServerCore(net.sourceforge.myvd.server.ServerCore) BufferedReader(java.io.BufferedReader) JSONObject(org.json.simple.JSONObject) Properties(java.util.Properties) Map(java.util.Map) Yaml(org.yaml.snakeyaml.Yaml) FileInputStream(java.io.FileInputStream)

Example 2 with ServerCore

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ServerCore(net.sourceforge.myvd.server.ServerCore) Properties(java.util.Properties) MyVDConnection(com.tremolosecurity.proxy.myvd.MyVDConnection)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileInputStream (java.io.FileInputStream)2 Properties (java.util.Properties)2 ServerCore (net.sourceforge.myvd.server.ServerCore)2 MyVDConnection (com.tremolosecurity.proxy.myvd.MyVDConnection)1 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Map (java.util.Map)1 JSONObject (org.json.simple.JSONObject)1 Yaml (org.yaml.snakeyaml.Yaml)1