@@ -53,6 +53,27 @@ public function getUpHost($accessKey, $bucket)
5353 return $ scheme . $ host ;
5454 }
5555
56+ public function getUpHostV2 ($ accessKey , $ bucket )
57+ {
58+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
59+ if ($ err != null ) {
60+ return array (null , $ err );
61+ }
62+
63+ if ($ this ->useHTTPS === true ) {
64+ $ scheme = "https:// " ;
65+ } else {
66+ $ scheme = "http:// " ;
67+ }
68+
69+ $ host = $ region ->srcUpHosts [0 ];
70+ if ($ this ->useCdnDomains === true ) {
71+ $ host = $ region ->cdnUpHosts [0 ];
72+ }
73+
74+ return array ($ scheme . $ host , null );
75+ }
76+
5677 public function getUpBackupHost ($ accessKey , $ bucket )
5778 {
5879 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -70,6 +91,27 @@ public function getUpBackupHost($accessKey, $bucket)
7091 return $ scheme . $ host ;
7192 }
7293
94+ public function getUpBackupHostV2 ($ accessKey , $ bucket )
95+ {
96+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
97+ if ($ err != null ) {
98+ return array (null , $ err );
99+ }
100+
101+ if ($ this ->useHTTPS === true ) {
102+ $ scheme = "https:// " ;
103+ } else {
104+ $ scheme = "http:// " ;
105+ }
106+
107+ $ host = $ region ->cdnUpHosts [0 ];
108+ if ($ this ->useCdnDomains === true ) {
109+ $ host = $ region ->srcUpHosts [0 ];
110+ }
111+
112+ return array ($ scheme . $ host , null );
113+ }
114+
73115 public function getRsHost ($ accessKey , $ bucket )
74116 {
75117 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -83,6 +125,22 @@ public function getRsHost($accessKey, $bucket)
83125 return $ scheme . $ region ->rsHost ;
84126 }
85127
128+ public function getRsHostV2 ($ accessKey , $ bucket )
129+ {
130+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
131+ if ($ err != null ) {
132+ return array (null , $ err );
133+ }
134+
135+ if ($ this ->useHTTPS === true ) {
136+ $ scheme = "https:// " ;
137+ } else {
138+ $ scheme = "http:// " ;
139+ }
140+
141+ return array ($ scheme . $ region ->rsHost , null );
142+ }
143+
86144 public function getRsfHost ($ accessKey , $ bucket )
87145 {
88146 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -96,6 +154,22 @@ public function getRsfHost($accessKey, $bucket)
96154 return $ scheme . $ region ->rsfHost ;
97155 }
98156
157+ public function getRsfHostV2 ($ accessKey , $ bucket )
158+ {
159+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
160+ if ($ err != null ) {
161+ return array (null , $ err );
162+ }
163+
164+ if ($ this ->useHTTPS === true ) {
165+ $ scheme = "https:// " ;
166+ } else {
167+ $ scheme = "http:// " ;
168+ }
169+
170+ return array ($ scheme . $ region ->rsfHost , null );
171+ }
172+
99173 public function getIovipHost ($ accessKey , $ bucket )
100174 {
101175 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -109,6 +183,22 @@ public function getIovipHost($accessKey, $bucket)
109183 return $ scheme . $ region ->iovipHost ;
110184 }
111185
186+ public function getIovipHostV2 ($ accessKey , $ bucket )
187+ {
188+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
189+ if ($ err != null ) {
190+ return array (null , $ err );
191+ }
192+
193+ if ($ this ->useHTTPS === true ) {
194+ $ scheme = "https:// " ;
195+ } else {
196+ $ scheme = "http:// " ;
197+ }
198+
199+ return array ($ scheme . $ region ->iovipHost , null );
200+ }
201+
112202 public function getApiHost ($ accessKey , $ bucket )
113203 {
114204 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -122,6 +212,22 @@ public function getApiHost($accessKey, $bucket)
122212 return $ scheme . $ region ->apiHost ;
123213 }
124214
215+ public function getApiHostV2 ($ accessKey , $ bucket )
216+ {
217+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
218+ if ($ err != null ) {
219+ return array (null , $ err );
220+ }
221+
222+ if ($ this ->useHTTPS === true ) {
223+ $ scheme = "https:// " ;
224+ } else {
225+ $ scheme = "http:// " ;
226+ }
227+
228+ return array ($ scheme . $ region ->apiHost , null );
229+ }
230+
125231 private function getRegion ($ accessKey , $ bucket )
126232 {
127233 $ cacheId = "$ accessKey: $ bucket " ;
@@ -143,4 +249,25 @@ private function getRegion($accessKey, $bucket)
143249 }
144250 return $ region ;
145251 }
252+
253+ private function getRegionV2 ($ accessKey , $ bucket )
254+ {
255+ $ cacheId = "$ accessKey: $ bucket " ;
256+
257+ if (isset ($ this ->regionCache [$ cacheId ])) {
258+ $ region = $ this ->regionCache [$ cacheId ];
259+ } elseif (isset ($ this ->zone )) {
260+ $ region = $ this ->zone ;
261+ $ this ->regionCache [$ cacheId ] = $ region ;
262+ } else {
263+ $ region = Zone::queryZone ($ accessKey , $ bucket );
264+ if (is_array ($ region )) {
265+ list ($ region , $ err ) = $ region ;
266+ return array ($ region , $ err );
267+ }
268+ $ this ->regionCache [$ cacheId ] = $ region ;
269+ }
270+
271+ return array ($ region , null );
272+ }
146273}
0 commit comments