|
@@ -2278,6 +2278,55 @@ bool CFileSprayEx::onReplicate(IEspContext &context, IEspReplicate &req, IEspRep
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const char* CFileSprayEx::getDropZoneDirByIP(const char* ip, StringBuffer& dir)
|
|
|
|
+{
|
|
|
|
+ if (!ip || !*ip)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
|
|
|
|
+ Owned<IConstEnvironment> env = factory->openEnvironment();
|
|
|
|
+ if (!env)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ Owned<IPropertyTree> root = &env->getPTree();
|
|
|
|
+ VStringBuffer xPath("Hardware/Computer[@netAddress='%s']/@name", ip);
|
|
|
|
+ const char* computer = root->queryProp(xPath.str());
|
|
|
|
+ if (!computer || !*computer)
|
|
|
|
+ {
|
|
|
|
+ StringBuffer localHostIP;
|
|
|
|
+ queryHostIP().getIpText(localHostIP);
|
|
|
|
+ if (!strieq(".", ip) && !strieq("localhost", ip) && !strieq("127.0.0.1", ip) && !strieq(ip, localHostIP.str()))
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ StringArray possibleIPs;
|
|
|
|
+ if (!strieq(".", ip))
|
|
|
|
+ possibleIPs.append(".");
|
|
|
|
+ if (!strieq("localhost", ip))
|
|
|
|
+ possibleIPs.append("localhost");
|
|
|
|
+ if (!strieq("127.0.0.1", ip))
|
|
|
|
+ possibleIPs.append("127.0.0.1");
|
|
|
|
+ if (!strieq(localHostIP.str(), ip))
|
|
|
|
+ possibleIPs.append(localHostIP.str());
|
|
|
|
+
|
|
|
|
+ ForEachItemIn(i, possibleIPs)
|
|
|
|
+ {
|
|
|
|
+ xPath.setf("Hardware/Computer[@netAddress='%s']/@name", possibleIPs.item(i));
|
|
|
|
+ computer = root->queryProp(xPath.str());
|
|
|
|
+ if (computer && *computer)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (!computer || !*computer)
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ xPath.setf("Software/DropZone[@computer='%s']/@directory", computer);
|
|
|
|
+ const char* path = root->queryProp(xPath.str());
|
|
|
|
+ if (!path || !*path)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ return dir.append(path).str();
|
|
|
|
+}
|
|
|
|
+
|
|
bool CFileSprayEx::onDespray(IEspContext &context, IEspDespray &req, IEspDesprayResponse &resp)
|
|
bool CFileSprayEx::onDespray(IEspContext &context, IEspDespray &req, IEspDesprayResponse &resp)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -2325,7 +2374,16 @@ bool CFileSprayEx::onDespray(IEspContext &context, IEspDespray &req, IEspDespray
|
|
{
|
|
{
|
|
RemoteFilename rfn;
|
|
RemoteFilename rfn;
|
|
SocketEndpoint ep(destip);
|
|
SocketEndpoint ep(destip);
|
|
- rfn.setPath(ep, destfile);
|
|
|
|
|
|
+ if (isAbsolutePath(destfile))
|
|
|
|
+ rfn.setPath(ep, destfile);
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ StringBuffer buf;
|
|
|
|
+ getDropZoneDirByIP(destip, buf);
|
|
|
|
+ if (buf.length() && buf.charAt(buf.length()-1) != PATHSEPCHAR)
|
|
|
|
+ buf.append(PATHSEPCHAR);
|
|
|
|
+ rfn.setPath(ep, buf.append(destfile).str());
|
|
|
|
+ }
|
|
destination->setSingleFilename(rfn);
|
|
destination->setSingleFilename(rfn);
|
|
}
|
|
}
|
|
else
|
|
else
|