コード例 #1
0
 public function testIsIpFormat()
 {
     $this->assertTrue(OssUtil::isIPFormat("10.101.160.147"));
     $this->assertTrue(OssUtil::isIPFormat("12.12.12.34"));
     $this->assertTrue(OssUtil::isIPFormat("12.12.12.12"));
     $this->assertTrue(OssUtil::isIPFormat("255.255.255.255"));
     $this->assertTrue(OssUtil::isIPFormat("0.1.1.1"));
     $this->assertFalse(OssUtil::isIPFormat("0.1.1.x"));
     $this->assertFalse(OssUtil::isIPFormat("0.1.1.256"));
     $this->assertFalse(OssUtil::isIPFormat("256.1.1.1"));
     $this->assertFalse(OssUtil::isIPFormat("0.1.1.0.1"));
     $this->assertTrue(OssUtil::isIPFormat("10.10.10.10:123"));
 }
コード例 #2
0
 /**
  * 检查endpoint的种类
  * 如有有协议头,剥去协议头
  * 并且根据参数 is_cname 和endpoint本身,判定域名类型,是ip,cname,还是专有域或者官网域名
  *
  * @param string $endpoint
  * @param boolean $isCName
  * @return string 剥掉协议头的域名
  */
 private function checkEndpoint($endpoint, $isCName)
 {
     $ret_endpoint = null;
     if (strpos($endpoint, 'http://') === 0) {
         $ret_endpoint = substr($endpoint, strlen('http://'));
     } elseif (strpos($endpoint, 'https://') === 0) {
         $ret_endpoint = substr($endpoint, strlen('https://'));
         $this->useSSL = true;
     } else {
         $ret_endpoint = $endpoint;
     }
     if ($isCName) {
         $this->hostType = self::OSS_HOST_TYPE_CNAME;
     } elseif (OssUtil::isIPFormat($ret_endpoint)) {
         $this->hostType = self::OSS_HOST_TYPE_IP;
     } else {
         $this->hostType = self::OSS_HOST_TYPE_NORMAL;
     }
     return $ret_endpoint;
 }