// TODO: Secure this better (using host address is probably sufficient, but then we need a full
// network map to know which IP to use)
// Command sendCommand = Command.build("socat -u OPEN:{0},rdonly TCP4-LISTEN:{1},range={2}",
// srcImageFile, port, targetAddress.getHostAddress() + "/32");
Command pushCommand = Command.build("socat -u OPEN:{0},rdonly {1}", srcFile,
toSocatPush(channel.dest, listenPort));
return src.executeCommand(pushCommand.setTimeout(TimeSpan.TEN_MINUTES));
}
};
Callable<ProcessExecution> listenFile = new Callable<ProcessExecution>() {
@Override
public ProcessExecution call() throws Exception {
// TODO: This is actually _really_ problematic because pkill kills proceses in guests also...
// TODO: Check no concurrent socats?? Move to a better system??
Command killExistingSocats = Command.build("pkill socat || true");
dest.executeCommand(killExistingSocats);
try {
Command listenCommand = Command.build("socat -u {0} CREATE:{1}",
toSocatListen(channel.src, listenPort), tempDest);
return dest.executeCommand(listenCommand.setTimeout(TimeSpan.TEN_MINUTES));
} catch (ProcessExecutionException e) {
log.warn("Error running listen process for P2P copy: " + channel, e);
throw new OpsException("Error running listen process", e);
}
}