Skip to content

Commit 856cb7f

Browse files
author
Jens Kießling
committed
Updated Github API access
1 parent 7393462 commit 856cb7f

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

APC_Source/Arduino Pedelec Configurator/Arduino Pedelec Configurator/Arduino Pedelec Configurator.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<Reference Include="System.Core">
6565
<Private>False</Private>
6666
</Reference>
67+
<Reference Include="System.Net.Http" />
6768
<Reference Include="System.Windows.Forms.DataVisualization">
6869
<Private>False</Private>
6970
</Reference>

APC_Source/Arduino Pedelec Configurator/Arduino Pedelec Configurator/Form1.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ private void cb_brake_CheckedChanged(object sender, EventArgs e)
178178

179179
private void Form1_Load(object sender, EventArgs e)
180180
{
181+
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; //disable TLS 1.0
182+
181183
cbts_disp1short.ComboBox.BindingContext = this.BindingContext;
182184
cbts_disp1short.ComboBox.DataSource = new BindingSource(ACTIONS, null);
183185
cbts_disp1long.ComboBox.BindingContext = this.BindingContext;
@@ -273,10 +275,10 @@ private string get_githubversion()
273275
string line = "";
274276
updatetext = "";
275277
WebClient webClient = new WebClient();
276-
277278
tb_console.AppendText("\r\nchecking for version");
278279
try
279280
{
281+
webClient.Headers.Add("user-agent", "foo");
280282
webClient.DownloadFile("https://raw.githubusercontent.com/jenkie/Arduino-Pedelec-Configurator/master/version.txt", appPath + @"\version.txt");
281283
webClient.Dispose();
282284
if (System.IO.File.Exists(appPath + @"\version.txt"))
@@ -303,8 +305,8 @@ private void download_newapc()
303305
tb_console.AppendText("\r\ndowloading new APC from github");
304306
try
305307
{
306-
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
307-
webClient.DownloadFile("https://codeload.github.com/jenkie/Arduino-Pedelec-Configurator/legacy.zip/master", appPath + @"\updated_apc.zip");
308+
webClient.Headers.Add("user-agent", "foo");
309+
webClient.DownloadFile("https://api.github.com/repos/jenkie/Arduino-Pedelec-Configurator/zipball/master", appPath + @"\updated_apc.zip");
308310
webClient.Dispose();
309311
MessageBox.Show("I will quit now. Extract everything from updated_apc.zip to the application directory and restart this Software.");
310312
System.Diagnostics.Process.Start(appPath + @"\updated_apc.zip");
@@ -680,17 +682,17 @@ private void bt_delete_Click(object sender, EventArgs e)
680682
private void download_github_sources()
681683
{
682684
WebClient webClient = new WebClient();
683-
684-
tb_console.AppendText("\r\ncleaning up sources");
685-
foreach (string directory in System.IO.Directory.EnumerateDirectories(sourcePath_online))
686-
{
687-
System.IO.Directory.Delete(directory,true);
688-
}
689-
System.IO.Directory.CreateDirectory(sourcePath_online);
690-
tb_console.AppendText("...done\r\ndownloading sources");
691-
try{
692-
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
693-
webClient.DownloadFile("https://codeload.github.com/jenkie/Arduino-Pedelec-Controller/legacy.zip/apc" + appVersion, sourcePath_online + @"\git_down.zip");
685+
tb_console.AppendText("\r\ncleaning up sources");
686+
foreach (string directory in System.IO.Directory.EnumerateDirectories(sourcePath_online))
687+
{
688+
System.IO.Directory.Delete(directory,true);
689+
}
690+
System.IO.Directory.CreateDirectory(sourcePath_online);
691+
tb_console.AppendText("...done\r\ndownloading sources");
692+
try
693+
{
694+
webClient.Headers.Add("user-agent", "foo");
695+
webClient.DownloadFile("https://api.github.com/repos/jenkie/Arduino-Pedelec-Controller/zipball/apc" + appVersion, sourcePath_online + @"\git_down.zip");
694696
}
695697
catch (Exception ex)
696698
{

Arduino Pedelec Configurator.exe

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)