@@ -78,6 +78,27 @@ public class GlobalConfiguration
78
78
public static string config_password = "" ;
79
79
}
80
80
81
+ [ Serializable ( ) ]
82
+ class ConfigurationException : System . Exception
83
+ {
84
+ public ConfigurationException ( ) : base ( ) { }
85
+ public ConfigurationException ( string message ) : base ( message ) { }
86
+ public ConfigurationException ( string message , System . Exception inner ) : base ( message , inner ) { }
87
+ protected ConfigurationException ( System . Runtime . Serialization . SerializationInfo info ,
88
+ System . Runtime . Serialization . StreamingContext context )
89
+ { }
90
+ }
91
+ [ Serializable ( ) ]
92
+ class ConfigurationWarning : System . Exception
93
+ {
94
+ public ConfigurationWarning ( ) : base ( ) { }
95
+ public ConfigurationWarning ( string message ) : base ( message ) { }
96
+ public ConfigurationWarning ( string message , System . Exception inner ) : base ( message , inner ) { }
97
+ protected ConfigurationWarning ( System . Runtime . Serialization . SerializationInfo info ,
98
+ System . Runtime . Serialization . StreamingContext context )
99
+ { }
100
+ }
101
+
81
102
[ Serializable ]
82
103
public class Configuration
83
104
{
@@ -219,7 +240,7 @@ public Server GetCurrentServer(int localPort, ServerSelectStrategy.FilterFunc fi
219
240
if ( selServer != null )
220
241
return selServer . group == server . group ;
221
242
return false ;
222
- } , true ) ;
243
+ } , true ) ;
223
244
}
224
245
else
225
246
{
@@ -370,7 +391,15 @@ public static void CheckServer(Server server)
370
391
CheckPort ( server . server_port ) ;
371
392
if ( server . server_udp_port != 0 )
372
393
CheckPort ( server . server_udp_port ) ;
373
- CheckPassword ( server . password ) ;
394
+ try
395
+ {
396
+ CheckPassword ( server . password ) ;
397
+ }
398
+ catch ( ConfigurationWarning cw )
399
+ {
400
+ server . password = "" ;
401
+ MessageBox . Show ( cw . Message , cw . Message , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
402
+ }
374
403
CheckServer ( server . server ) ;
375
404
}
376
405
@@ -619,23 +648,24 @@ public static void CheckPort(int port)
619
648
{
620
649
if ( port <= 0 || port > 65535 )
621
650
{
622
- throw new ArgumentException ( I18N . GetString ( "Port out of range" ) ) ;
651
+ throw new ConfigurationException ( I18N . GetString ( "Port out of range" ) ) ;
623
652
}
624
653
}
625
654
626
655
private static void CheckPassword ( string password )
627
656
{
628
657
if ( string . IsNullOrEmpty ( password ) )
629
658
{
630
- throw new ArgumentException ( I18N . GetString ( "Password can not be blank" ) ) ;
659
+ throw new ConfigurationWarning ( I18N . GetString ( "Password are blank" ) ) ;
660
+ //throw new ConfigurationException(I18N.GetString("Password can not be blank"));
631
661
}
632
662
}
633
663
634
664
private static void CheckServer ( string server )
635
665
{
636
666
if ( string . IsNullOrEmpty ( server ) )
637
667
{
638
- throw new ArgumentException ( I18N . GetString ( "Server IP can not be blank" ) ) ;
668
+ throw new ConfigurationException ( I18N . GetString ( "Server IP can not be blank" ) ) ;
639
669
}
640
670
}
641
671
@@ -777,7 +807,7 @@ public void AddUpload(string server, Int64 size)
777
807
if ( -- saveCounter <= 0 )
778
808
{
779
809
saveCounter = 256 ;
780
- if ( ( DateTime . Now - saveTime ) . TotalMinutes > 10 )
810
+ if ( ( DateTime . Now - saveTime ) . TotalMinutes > 10 )
781
811
{
782
812
lock ( servers )
783
813
{
@@ -798,7 +828,7 @@ public void AddDownload(string server, Int64 size)
798
828
if ( -- saveCounter <= 0 )
799
829
{
800
830
saveCounter = 256 ;
801
- if ( ( DateTime . Now - saveTime ) . TotalMinutes > 10 )
831
+ if ( ( DateTime . Now - saveTime ) . TotalMinutes > 10 )
802
832
{
803
833
lock ( servers )
804
834
{
0 commit comments