File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 11using Directory2Rss . Library ;
22using Swan ;
33using System ;
4+ using System . Collections . Generic ;
45using System . IO ;
56using System . Threading . Tasks ;
67
@@ -24,8 +25,29 @@ static void setOption(ref string input, string option)
2425 static async Task Main ( string [ ] args )
2526 {
2627 PodcastConfig config = new PodcastConfig ( ) ;
28+ List < string > ipAddressList = PodcastConfig . GetLocalIpAddresses ( ) ;
29+ string response = "" ;
30+ int option = - 1 ;
31+
32+ Console . WriteLine ( "Select IP address to bind: " , config . DirectoryToServe ) ;
33+ for ( int i = 0 ; i < ipAddressList . Count ; i ++ )
34+ {
35+ Console . WriteLine ( "{0}: {1}" , i , ipAddressList [ i ] ) ;
36+ }
37+ response = Console . ReadLine ( ) ;
38+ Int32 . TryParse ( response , out option ) ;
39+ if ( option < ipAddressList . Count )
40+ {
41+ config . IPAddress = ipAddressList [ option ] ;
42+ }
43+ else
44+ {
45+ Console . WriteLine ( "Invalid option, exiting..." ) ;
46+ return ;
47+ }
48+
2749 Console . WriteLine ( "Enter directory to serve [{0}]: " , config . DirectoryToServe ) ;
28- string response = Console . ReadLine ( ) ;
50+ response = Console . ReadLine ( ) ;
2951 if ( response . Length > 0 )
3052 {
3153 if ( Directory . Exists ( response ) )
Original file line number Diff line number Diff line change @@ -29,6 +29,20 @@ public PodcastConfig()
2929 PodcastCategory = "Music" ;
3030 }
3131
32+ public static List < string > GetLocalIpAddresses ( )
33+ {
34+ List < string > result = new List < string > ( ) ;
35+ var host = Dns . GetHostEntry ( Dns . GetHostName ( ) ) ;
36+ foreach ( var ip in host . AddressList )
37+ {
38+ if ( ip . AddressFamily == AddressFamily . InterNetwork )
39+ {
40+ result . Add ( ip . ToString ( ) ) ;
41+ }
42+ }
43+ return result ;
44+ }
45+
3246 public static string GetLocalIPAddress ( )
3347 {
3448 var host = Dns . GetHostEntry ( Dns . GetHostName ( ) ) ;
You can’t perform that action at this time.
0 commit comments