11
2+ using System . Collections . Generic ;
3+
24namespace Qiniu . Storage
35{
46 /// <summary>
@@ -13,6 +15,15 @@ public class Config
1315 /// 默认空间管理域名
1416 /// </summary>
1517 public static string DefaultUcHost = "uc.qbox.me" ;
18+ /// <summary>
19+ /// 默认备用空间管理域名
20+ /// </summary>
21+ public static List < string > DefaultBackupUcHosts = new List < string >
22+ {
23+ "kodo-config.qiniuapi.com" ,
24+ "api.qiniu.com"
25+ } ;
26+
1627 /// <summary>
1728 /// 默认高级资源管理域名
1829 /// </summary>
@@ -57,9 +68,12 @@ public class Config
5768
5869 private string _ucHost = DefaultUcHost ;
5970
71+ private List < string > _backupUcHosts = DefaultBackupUcHosts ;
72+
6073 public void SetUcHost ( string val )
6174 {
6275 _ucHost = val ;
76+ _backupUcHosts . Clear ( ) ;
6377 }
6478
6579 public string UcHost ( )
@@ -68,6 +82,16 @@ public string UcHost()
6882 return string . Format ( "{0}{1}" , scheme , _ucHost ) ;
6983 }
7084
85+ public void SetBackupUcHost ( List < string > val )
86+ {
87+ _backupUcHosts = val ;
88+ }
89+
90+ public List < string > BackupUcHost ( )
91+ {
92+ return _backupUcHosts ;
93+ }
94+
7195 /// <summary>
7296 /// 获取资源管理域名
7397 /// </summary>
@@ -80,7 +104,7 @@ public string RsHost(string ak, string bucket)
80104 Zone z = this . Zone ;
81105 if ( z == null )
82106 {
83- z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) ) ;
107+ z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) , BackupUcHost ( ) ) ;
84108 }
85109 return string . Format ( "{0}{1}" , scheme , z . RsHost ) ;
86110 }
@@ -97,7 +121,7 @@ public string RsfHost(string ak, string bucket)
97121 Zone z = this . Zone ;
98122 if ( z == null )
99123 {
100- z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) ) ;
124+ z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) , BackupUcHost ( ) ) ;
101125 }
102126 return string . Format ( "{0}{1}" , scheme , z . RsfHost ) ;
103127 }
@@ -114,7 +138,7 @@ public string ApiHost(string ak, string bucket)
114138 Zone z = this . Zone ;
115139 if ( z == null )
116140 {
117- z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) ) ;
141+ z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) , BackupUcHost ( ) ) ;
118142 }
119143 return string . Format ( "{0}{1}" , scheme , z . ApiHost ) ;
120144 }
@@ -131,7 +155,7 @@ public string IovipHost(string ak, string bucket)
131155 Zone z = this . Zone ;
132156 if ( z == null )
133157 {
134- z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) ) ;
158+ z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) , BackupUcHost ( ) ) ;
135159 }
136160 return string . Format ( "{0}{1}" , scheme , z . IovipHost ) ;
137161 }
@@ -148,7 +172,7 @@ public string UpHost(string ak, string bucket)
148172 Zone z = this . Zone ;
149173 if ( z == null )
150174 {
151- z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) ) ;
175+ z = ZoneHelper . QueryZone ( ak , bucket , UcHost ( ) , BackupUcHost ( ) ) ;
152176 }
153177 string upHost = z . SrcUpHosts [ 0 ] ;
154178 if ( this . UseCdnDomains )
0 commit comments