File tree 5 files changed +25
-29
lines changed
5 files changed +25
-29
lines changed Original file line number Diff line number Diff line change 12
12
<VerticalStackLayout >
13
13
14
14
<Grid
15
+ RowDefinitions =" 1*,1*,100*"
15
16
ColumnDefinitions =" .20*,.80*"
16
17
Margin =" 10" >
17
18
18
19
<Button Text =" start"
19
20
Grid.Column=" 0"
21
+ Grid.Row=" 1"
20
22
Command =" {Binding GetValidIPsCommand}"
21
23
HorizontalOptions =" FillAndExpand"
22
24
VerticalOptions =" FillAndExpand" >
23
25
</Button >
24
26
25
27
<Entry
26
28
Grid.Column=" 1"
29
+ Grid.Row=" 1"
27
30
BackgroundColor =" DimGray"
28
31
Margin =" 10"
29
32
Placeholder =" enter max of ping defalt is 5000"
30
33
PlaceholderColor =" White"
31
34
Text =" {Binding MaxPingOfIP}" />
32
-
33
35
</Grid >
34
36
35
37
<CollectionView ItemsSource =" {Binding ValidIPs}"
43
45
<HorizontalStackLayout
44
46
Padding =" 15"
45
47
>
46
- <Label Text =" {Binding IP}" ></Label >
47
- <Label Text =" ping : " ></Label >
48
- <Label Text =" {Binding Ping}" ></Label >
48
+ <Label Text =" {Binding IP}"
49
+ TextColor =" White" ></Label >
50
+ <Label Text =" ping : "
51
+ TextColor =" White" ></Label >
52
+ <Label Text =" {Binding Ping}"
53
+ TextColor =" White" ></Label >
49
54
</HorizontalStackLayout >
50
55
</DataTemplate >
51
56
</CollectionView .ItemTemplate>
Original file line number Diff line number Diff line change @@ -10,6 +10,5 @@ public class IPModel
10
10
{
11
11
public string IP { get ; set ; }
12
12
public int Ping { get ; set ; }
13
- public bool IsValid { get ; set ; }
14
13
}
15
14
}
Original file line number Diff line number Diff line change @@ -31,12 +31,13 @@ public async Task<List<IPModel>> GetIpValid(int maxPing)
31
31
IpAddresses . Add ( line ) ;
32
32
}
33
33
}
34
+
34
35
SocketsHttpHandler SocketsHandler = new SocketsHttpHandler ( ) ;
35
36
HttpClient Client = new HttpClient ( SocketsHandler )
36
37
{
37
38
Timeout = TimeSpan . FromSeconds ( maxPing ) ,
38
39
} ;
39
- var tasks = new Task [ 20 ] ;
40
+
40
41
var validIp = new List < IPModel > ( ) ;
41
42
for ( int i = 0 ; i < 20 ; i ++ )
42
43
{
@@ -50,22 +51,14 @@ public async Task<List<IPModel>> GetIpValid(int maxPing)
50
51
stopwatch . Start ( ) ;
51
52
result = await Client . GetAsync ( $ "http://{ ipAddresse } ") ;
52
53
stopwatch . Stop ( ) ;
53
-
54
-
55
- //var request = (HttpWebRequest)WebRequest.Create($"http://{ipAddresse}");
56
- //request.Timeout = 5000;
57
- //var response = (HttpWebResponse)request.GetResponse();
58
- //var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
59
-
60
-
61
54
var ping = Convert . ToInt32 ( stopwatch . Elapsed . TotalMilliseconds ) ;
55
+
62
56
lock ( validIp )
63
57
{
64
58
validIp . Add ( new IPModel
65
59
{
66
60
IP = ipAddresse ,
67
61
Ping = ping ,
68
- IsValid = true
69
62
} ) ;
70
63
}
71
64
}
@@ -74,16 +67,13 @@ public async Task<List<IPModel>> GetIpValid(int maxPing)
74
67
stopwatch . Reset ( ) ;
75
68
}
76
69
} ) ;
77
- tasks [ i ] = t ;
78
70
t . Start ( ) ;
79
71
}
80
72
await Task . Delay ( maxPing ) ;
81
- //Thread.Sleep(5000);
82
73
return validIp ;
83
74
}
84
75
string GetRandomIp ( )
85
76
{
86
- // var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"IPAddresses.txt");
87
77
Random random = new Random ( ) ;
88
78
return IpAddresses [ random . Next ( IpAddresses . Count ) ] ;
89
79
}
Original file line number Diff line number Diff line change 1
- using System . ComponentModel . DataAnnotations ;
2
- using System . Linq ;
3
-
1
+
4
2
namespace fast_cf_ip_scanner . ViewModels
5
3
{
6
4
public partial class MainPageViewModel : BaseViewModel
@@ -10,6 +8,7 @@ public partial class MainPageViewModel : BaseViewModel
10
8
11
9
[ ObservableProperty ]
12
10
string maxPingOfIP ;
11
+
13
12
14
13
readonly IPServices _iPServices ;
15
14
@@ -57,10 +56,14 @@ int ConvertMaxPingOfIPToInt(string maxPing)
57
56
}
58
57
59
58
[ RelayCommand ]
60
- async Task CopySelectedIPAsync ( IPModel iPModel )
59
+ async Task CopySelectedIPAsync ( IPModel ipModel )
61
60
{
62
- await Clipboard . SetTextAsync ( iPModel . IP ) ;
63
- await App . Current . MainPage . DisplayAlert ( "Copied" , $ "the { iPModel . IP } is copied", "OK" ) ;
61
+ if ( ipModel != null )
62
+ {
63
+ await Clipboard . SetTextAsync ( ipModel . IP ) ;
64
+ await App . Current . MainPage . DisplayAlert ( "Copied" , $ "the { ipModel . IP } is copied", "OK" ) ;
65
+ }
66
+
64
67
}
65
68
}
66
69
}
Original file line number Diff line number Diff line change 15
15
<ApplicationTitle >fast cf ip scanner</ApplicationTitle >
16
16
17
17
<!-- App Identifier -->
18
- <ApplicationId >com.companyname .fast_cf_ip_scanner</ApplicationId >
18
+ <ApplicationId >com.Ali1707 .fast_cf_ip_scanner</ApplicationId >
19
19
<ApplicationIdGuid >4fb46e13-cf0a-419b-99f7-22b80a864ae4</ApplicationIdGuid >
20
20
21
21
<!-- Versions -->
32
32
33
33
<ItemGroup >
34
34
<!-- App Icon -->
35
- <MauiIcon Include =" Resources\AppIcon\appicon.svg" ForegroundFile =" Resources\AppIcon\appiconfg.svg" Color =" #512BD4" />
36
-
35
+ <MauiIcon Include =" Resources\AppIcon\appicon.svg" ForegroundFile =" Resources\AppIcon\appiconfg.svg" />
37
36
<!-- Splash Screen -->
38
37
<MauiSplashScreen Include =" Resources\Splash\splash.svg" Color =" #512BD4" BaseSize =" 128,128" />
39
38
40
39
<!-- Images -->
41
40
<MauiImage Include =" Resources\Images\*" />
42
41
<MauiImage Update =" Resources\Images\dotnet_bot.svg" BaseSize =" 168,208" />
43
-
42
+
44
43
<!-- Custom Fonts -->
45
44
<MauiFont Include =" Resources\Fonts\*" />
46
45
47
46
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
48
47
<MauiAsset Include =" Resources\Raw\**" LogicalName =" %(RecursiveDir)%(Filename)%(Extension)" />
49
- < MauiAsset Include = " Resources\Raw\IPAddresses.txt " />
48
+
50
49
</ItemGroup >
51
50
52
51
<ItemGroup >
You can’t perform that action at this time.
0 commit comments