diff --git a/UnionPatcher/Communication/FTP.cs b/UnionPatcher/Communication/FTP.cs index 8ae313a..d96cee8 100644 --- a/UnionPatcher/Communication/FTP.cs +++ b/UnionPatcher/Communication/FTP.cs @@ -5,13 +5,15 @@ using System.IO; using System.Linq; using System.Net; -namespace LBPUnion.UnionPatcher.Communication; +#pragma warning disable SYSLIB0014 // the FtpWebRequest is needed in this case +namespace LBPUnion.UnionPatcher.Communication; public static class FTP { public static bool FileExists(string url, string user, string pass) { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url); + request.Credentials = new NetworkCredential(user, pass); request.Method = WebRequestMethods.Ftp.GetDateTimestamp; @@ -36,6 +38,7 @@ public static class FTP public static string[] ListDirectory(string url, string user, string pass) { + FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url); request.Credentials = new NetworkCredential(user, pass); request.Method = WebRequestMethods.Ftp.ListDirectory; @@ -53,7 +56,7 @@ public static class FTP .Where(dir => !string.IsNullOrWhiteSpace(dir) && dir != "." && dir != "..") .ToList(); - foreach(string dir in dirs.ToArray()) + foreach (string dir in dirs.ToArray()) { Console.WriteLine($"/{dir}"); } @@ -128,7 +131,7 @@ public static class FTP FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); - + using StreamReader reader = new(responseStream); return reader.ReadToEnd(); diff --git a/UnionPatcher/Communication/PS3MAPI.cs b/UnionPatcher/Communication/PS3MAPI.cs index f99a96a..67b2416 100644 --- a/UnionPatcher/Communication/PS3MAPI.cs +++ b/UnionPatcher/Communication/PS3MAPI.cs @@ -12,7 +12,7 @@ using System.Net.Sockets; using System.Text; using System.Text.RegularExpressions; -namespace LBPUnion.UnionPatcher.Communication; +namespace LBPUnion.UnionPatcher.Communication; public class PS3MAPI { @@ -102,7 +102,7 @@ public class PS3MAPI Double = 2, Triple = 3, } - + /// Ring PS3 Buzzer. /// Simple, Double, Continuous public void RingBuzzer(BuzzerMode mode) @@ -234,7 +234,7 @@ public class PS3MAPI } } main_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - main_ipEndPoint = new IPEndPoint(Dns.GetHostByName(sServerIP).AddressList[0], Port); + main_ipEndPoint = new IPEndPoint(Dns.GetHostAddresses(sServerIP)[0], Port); try { main_sock.Connect(main_ipEndPoint); @@ -781,12 +781,12 @@ public class PS3MAPI SetBinaryMode(false); } } - catch (Exception e) + catch { CloseDataSocket(); ReadResponse(); SetBinaryMode(false); - throw e; + throw; } } } @@ -847,12 +847,12 @@ public class PS3MAPI SetBinaryMode(false); } } - catch (Exception e) + catch { CloseDataSocket(); ReadResponse(); SetBinaryMode(false); - throw e; + throw; } } } @@ -1094,7 +1094,7 @@ public class PS3MAPI { CloseDataSocket(); data_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - data_ipEndPoint = new IPEndPoint(Dns.GetHostByName(sServerIP).AddressList[0], iPort); + data_ipEndPoint = new IPEndPoint(Dns.GetHostAddresses(sServerIP)[0], iPort); data_sock.Connect(data_ipEndPoint); } catch (Exception e)