Initial commit

This commit is contained in:
Flare Microsystems
2024-11-08 09:01:36 -08:00
commit 71d118f160
43 changed files with 1100 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
package com.flaremicro.crossjeeves;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.flaremicro.util.Util;
public class CrossJeevesMain {
public static void main(String[] args) {
Map<String, String> parsedArgs = Util.parseArgs(args, true, true);
if (parsedArgs.containsKey("host"))
{
try
{
int port = Integer.parseInt(parsedArgs.get("host"));
CrossJeevesHost host = new CrossJeevesHost(port);
host.startHosting();
}
catch (NumberFormatException ex)
{
System.out.println("Invalid port specified: " + parsedArgs.get("host"));
System.exit(1);
}
}
else if (parsedArgs.containsKey("agent"))
{
if(!parsedArgs.containsKey("script"))
{
System.out.println("'script' argument must be specified for agent.");
System.exit(1);
}
String[] agents = parsedArgs.get("agent").split("\\s");
List<AgentInfo> agentList = new ArrayList<AgentInfo>();
for(String agent : agents)
{
String agentArgs[] = agent.split("\\+");
if(agentArgs.length == 0)
{
System.out.println("IP must be specified");
System.exit(1);
}
String ipStr = args[0];
String portStr = "10801";
if(args.length >= 2)
portStr = args[1];
try
{
int port = Integer.parseInt(portStr);
InetAddress inetAddress = InetAddress.getByName(ipStr);
agentList.add(new AgentInfo(inetAddress, port));
}
catch (NumberFormatException ex)
{
System.out.println("Invalid port specified: " + portStr);
System.exit(1);
}
catch (UnknownHostException e)
{
System.out.println("Unknown host: " + ipStr);
System.exit(1);
}
}
CrossJeevesClient client = new CrossJeevesClient(agentList, parsedArgs.get("script"));
client.beginJob();
}
else
{
System.out.println("Argument 'host' or 'agent' must be specified.");
System.exit(1);
}
}
}