Skip to content

Commit

Permalink
- Support tls1.2
Browse files Browse the repository at this point in the history
- Fix built-in server
  • Loading branch information
Jeric-X committed Aug 26, 2020
1 parent 8444fb3 commit 14d7543
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 34 deletions.
4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.0.6
- Support tls1.2
- Fix built-in server

v1.0.5
- Fix start with boot

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
## 功能
一个简单的剪切板同步工具,C/S架构
## Server
理论支持任何支持WebDAV协议的网盘、web服务器
> 测试过的服务器:
> - [x] NextCloud
~~~理论支持任何支持WebDAV协议的网盘、web服务器~~~
测试过的服务器:
- [x] NextCloud
## Client-Windows
下载最新的[Release](https://github.com/Jeric-X/SyncClipboard/releases/),自备梯子
Expand Down
44 changes: 18 additions & 26 deletions SyncClipboard/HttpWebResponseUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public static HttpWebResponse CreateGetHttpResponse(string url, int? timeout, st
{
throw new ArgumentNullException("url");
}

SetSecurityProtocol(url);
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;

request.Method = "GET";
request.UserAgent = DefaultUserAgent;
if (!string.IsNullOrEmpty(userAgent))
Expand Down Expand Up @@ -71,18 +74,11 @@ public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary<str
{
throw new ArgumentNullException("requestEncoding");
}
HttpWebRequest request = null;
//如果是发送HTTPS请求
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
}
else
{
request = WebRequest.Create(url) as HttpWebRequest;
}

SetSecurityProtocol(url);

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;

request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

Expand Down Expand Up @@ -149,18 +145,10 @@ public static HttpWebResponse CreatePutHttpResponse(string url, string parameter
{
throw new ArgumentNullException("requestEncoding");
}
HttpWebRequest request = null;
//如果是发送HTTPS请求
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
}
else
{
request = WebRequest.Create(url) as HttpWebRequest;
}

SetSecurityProtocol(url);

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "PUT";
request.ContentType = "text/plain";
if (!string.IsNullOrEmpty(userAgent))
Expand Down Expand Up @@ -203,9 +191,13 @@ public static HttpWebResponse CreatePutHttpResponse(string url, string parameter

return request.GetResponse() as HttpWebResponse;
}
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)

public static void SetSecurityProtocol(string url)
{
return true; //总是接受
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
}
}
}
2 changes: 1 addition & 1 deletion SyncClipboard/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace SyncClipboard
static class Program
{
public static String SoftName = "SyncClipboard";
public static String DefaultServer = "https://cloud.jericx.xyz/remote.php/dav/files/Clipboard/Clipboard/";
public static String DefaultServer = "https://file.jericx.xyz/remote.php/dav/files/Clipboard/Clipboard/";
public static String DefaultUser = "Clipboard";
public static String DefaultPassword = "Clipboard";
public static MainController mainController;
Expand Down
2 changes: 1 addition & 1 deletion SyncClipboard/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SyncClipboard/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Profiles />
<Settings>
<Setting Name="URL" Type="System.String" Scope="User">
<Value Profile="(Default)">https://cloud.jericx.xyz/remote.php/dav/files/JericX/Clipboard/SyncClipboard.json</Value>
<Value Profile="(Default)">https://file.jericx.xyz/remote.php/dav/files/JericX/Clipboard/SyncClipboard.json</Value>
</Setting>
<Setting Name="USERNAME" Type="System.String" Scope="User">
<Value Profile="(Default)" />
Expand Down
2 changes: 1 addition & 1 deletion SyncClipboard/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace SyncClipboard
{
class UpdateChecker
{
public const string Version = "1.0.5";
public const string Version = "1.0.6";
public const string UpdateUrl = "https://api.github.com/repos/Jeric-X/SyncClipboard/releases/latest";
public const string ReleaseUrl = "https://github.com/Jeric-X/SyncClipboard/releases/latest";

Expand Down
2 changes: 1 addition & 1 deletion SyncClipboard/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<userSettings>
<SyncClipboard.Properties.Settings>
<setting name="URL" serializeAs="String">
<value>https://cloud.jericx.xyz/remote.php/dav/files/JericX/Clipboard/SyncClipboard.json</value>
<value>https://file.jericx.xyz/remote.php/dav/files/JericX/Clipboard/SyncClipboard.json</value>
</setting>
<setting name="USERNAME" serializeAs="String">
<value />
Expand Down

0 comments on commit 14d7543

Please sign in to comment.