add
This commit is contained in:
8
Assets/CoolapeFrame/3rd/ssh.net/Editor.meta
Normal file
8
Assets/CoolapeFrame/3rd/ssh.net/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8724193f22000446e9fe9f8448b6a432
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
164
Assets/CoolapeFrame/3rd/ssh.net/Editor/RenciSFTPHelper.cs
Normal file
164
Assets/CoolapeFrame/3rd/ssh.net/Editor/RenciSFTPHelper.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
using Renci.SshNet.Messages.Authentication;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
using Renci.SshNet.Messages.Transport;
|
||||
using Renci.SshNet;
|
||||
using System.IO;
|
||||
using Coolape;
|
||||
|
||||
public class RenciSFTPHelper
|
||||
{
|
||||
public SftpClient client;
|
||||
public RenciSFTPHelper(string host, int port, string user, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(host)
|
||||
|| string.IsNullOrEmpty(user)
|
||||
|| string.IsNullOrEmpty(password))
|
||||
{
|
||||
Debug.LogError("some params is empty!!" + "host==" + host + ",user ==" + user + ",password==" + password);
|
||||
}
|
||||
client = new SftpClient(host, port, user, password);
|
||||
}
|
||||
public bool connect()
|
||||
{
|
||||
//var connectionInfo = new ConnectionInfo(host,
|
||||
//"guest",
|
||||
//new PasswordAuthenticationMethod("guest", "pwd")
|
||||
//,new PrivateKeyAuthenticationMethod("rsa.key")
|
||||
//);
|
||||
try
|
||||
{
|
||||
if (!client.IsConnected)
|
||||
{
|
||||
client.Connect();
|
||||
}
|
||||
return client.IsConnected;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void disConnect()
|
||||
{
|
||||
client.Disconnect();
|
||||
client.Dispose();
|
||||
client = null;
|
||||
}
|
||||
|
||||
public bool mkdir(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!client.Exists(path))
|
||||
{
|
||||
client.CreateDirectory(path);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool put(string localPath, string remotePath, Callback finishCallback)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileStream fs = new FileStream(localPath, FileMode.Open, FileAccess.Read);
|
||||
client.UploadFile(fs, remotePath, true, (len) =>
|
||||
{
|
||||
Utl.doCallback(finishCallback, true, len);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
Utl.doCallback(finishCallback, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool putDir(string localDir, string remoteDir, Callback onProgressCallback, Callback onFinishCallback)
|
||||
{
|
||||
bool ret = false;
|
||||
if (!Directory.Exists(localDir))
|
||||
{
|
||||
Debug.LogError("There is no directory exist!");
|
||||
Utl.doCallback(onFinishCallback, false);
|
||||
return false;
|
||||
}
|
||||
mkdir(remoteDir);
|
||||
string[] files = Directory.GetFiles(localDir);
|
||||
string file = "";
|
||||
string[] dirs = Directory.GetDirectories(localDir);
|
||||
if (files != null)
|
||||
{
|
||||
int finishCount = 0;
|
||||
for (int i = 0; i < files.Length; i++)
|
||||
{
|
||||
file = files[i];
|
||||
Debug.Log(file);
|
||||
string remoteFile = Path.Combine(remoteDir, Path.GetFileName(file));
|
||||
ret = put(file, remoteFile,
|
||||
(Callback)((objs) =>
|
||||
{
|
||||
finishCount++;
|
||||
Utl.doCallback(onProgressCallback, (float)finishCount / files.Length);
|
||||
})
|
||||
);
|
||||
if (!ret)
|
||||
{
|
||||
Utl.doCallback(onFinishCallback, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dirs != null)
|
||||
{
|
||||
for (int i = 0; i < dirs.Length; i++)
|
||||
{
|
||||
// Debug.Log (PStr.b ().a (remotePath).a ("/").a (Path.GetFileName (dirs [i])).e ());
|
||||
ret = putDir(dirs[i], PStr.b().a(remoteDir).a("/").a(Path.GetFileName(dirs[i])).e(), onProgressCallback, null);
|
||||
if (!ret)
|
||||
{
|
||||
Utl.doCallback(onFinishCallback, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Utl.doCallback(onFinishCallback, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool get(string remotePath, string localPath, Callback finishCallback)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileStream fs = new FileStream(localPath, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
client.DownloadFile(remotePath, fs, (len) =>
|
||||
{
|
||||
Utl.doCallback(finishCallback, true, len);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
Utl.doCallback(finishCallback, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d671b58a8e80e4d87a94a588b1b7a3de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/CoolapeFrame/3rd/ssh.net/net35.meta
Normal file
8
Assets/CoolapeFrame/3rd/ssh.net/net35.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a81ce2db155a4e4580b56234092d093
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/CoolapeFrame/3rd/ssh.net/net35/Renci.SshNet.dll
Executable file
BIN
Assets/CoolapeFrame/3rd/ssh.net/net35/Renci.SshNet.dll
Executable file
Binary file not shown.
102
Assets/CoolapeFrame/3rd/ssh.net/net35/Renci.SshNet.dll.meta
Normal file
102
Assets/CoolapeFrame/3rd/ssh.net/net35/Renci.SshNet.dll.meta
Normal file
@@ -0,0 +1,102 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 413d89c84d60f4304aa6e7a00afb86cb
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 0
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 0
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19524
Assets/CoolapeFrame/3rd/ssh.net/net35/Renci.SshNet.xml
Executable file
19524
Assets/CoolapeFrame/3rd/ssh.net/net35/Renci.SshNet.xml
Executable file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1ad3acc36c1f491d9c300762b2e182f
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/CoolapeFrame/3rd/ssh.net/net40.meta
Normal file
8
Assets/CoolapeFrame/3rd/ssh.net/net40.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6987f629d6654b3ea6c7dc7b74b4645
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/CoolapeFrame/3rd/ssh.net/net40/Renci.SshNet.dll
Executable file
BIN
Assets/CoolapeFrame/3rd/ssh.net/net40/Renci.SshNet.dll
Executable file
Binary file not shown.
103
Assets/CoolapeFrame/3rd/ssh.net/net40/Renci.SshNet.dll.meta
Normal file
103
Assets/CoolapeFrame/3rd/ssh.net/net40/Renci.SshNet.dll.meta
Normal file
@@ -0,0 +1,103 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99e076cc294794a1380fc9d07f1c973a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 0
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19415
Assets/CoolapeFrame/3rd/ssh.net/net40/Renci.SshNet.xml
Executable file
19415
Assets/CoolapeFrame/3rd/ssh.net/net40/Renci.SshNet.xml
Executable file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0b5139be0cd64f7eb7ba5004ce2065c
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user