File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 66using System . Net . NetworkInformation ;
77using System . Net . WebSockets ;
88using System . Reflection ;
9+ using System . Resources ;
910
1011namespace fast_cf_ip_scanner . Services
1112{
1213 public class IPServices
1314 {
15+ List < string > ipAddresses = new List < string > ( ) ;
1416 public IPServices ( )
1517 {
18+
1619 }
20+
21+
1722 public async Task < List < IPModel > > GetIpValid ( int maxPing )
1823 {
24+ if ( ipAddresses . Count == 0 )
25+ {
26+ using var stream = await FileSystem . OpenAppPackageFileAsync ( "IPAddresses.txt" ) ;
27+ using var reader = new StreamReader ( stream ) ;
28+ string line ;
29+ while ( ( line = await reader . ReadLineAsync ( ) ) != null )
30+ {
31+ ipAddresses . Add ( line ) ;
32+ }
33+ }
1934 SocketsHttpHandler SocketsHandler = new SocketsHttpHandler ( ) ;
2035 HttpClient Client = new HttpClient ( SocketsHandler )
2136 {
@@ -68,10 +83,9 @@ public async Task<List<IPModel>> GetIpValid(int maxPing)
6883 }
6984 string GetRandomIp ( )
7085 {
71- var path = Path . Combine ( Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) , @"IPAddresses.txt" ) ;
72- var ipAddresses = File . ReadAllLines ( path ) ;
86+ // var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"IPAddresses.txt");
7387 Random random = new Random ( ) ;
74- return ipAddresses [ random . Next ( ipAddresses . Length ) ] ;
88+ return ipAddresses [ random . Next ( ipAddresses . Count ) ] ;
7589 }
7690 }
7791}
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ int ConvertMaxPingOfIPToInt(string maxPing)
5555 }
5656
5757 }
58+
5859 [ RelayCommand ]
5960 async Task CopySelectedIPAsync ( IPModel iPModel )
6061 {
Original file line number Diff line number Diff line change 4646
4747 <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
4848 <MauiAsset Include =" Resources\Raw\**" LogicalName =" %(RecursiveDir)%(Filename)%(Extension)" />
49+ <MauiAsset Include =" Resources\Raw\IPAddresses.txt" />
4950 </ItemGroup >
5051
5152 <ItemGroup >
You can’t perform that action at this time.
0 commit comments