定制 hypernic/nawala 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hypernic/nawala

最新稳定版本:v1.0.2

Composer 安装命令:

composer require hypernic/nawala

包简介

Hypernic Nawala is a PHP library to check whether a website or domain is blocked in Indonesia.

README 文档

README

A PHP library to check whether a website or domain is blocked in Indonesia.

Requirements

  • PHP >= 8.0
  • curl, json
  • intl optional for IDN domains

Installation

composer require hypernic/nawala

Quick Start

index.php:

<?php
declare(strict_types=1);

header('Content-Type: application/json');
require __DIR__ . '/vendor/autoload.php';

use Hypernic\Nawala;

$nawala = new Nawala([
    'timeout' => 10,          // seconds
    'connect_timeout' => 5,   // seconds
    'retries' => 1,           // light retry for transient errors
    'cache' => [
        'enabled' => true
    ]
]);

$result = $nawala->check('example.com');
echo json_encode($result, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

Example output (success, not blocked):

{
  "status": true,
  "data": {
    "domain": "example.com",
    "blocked": false
  }
}

Example output (success, blocked):

{
  "status": true,
  "data": {
    "domain": "pornhub.com",
    "blocked": true
  }
}

Example output (invalid input):

{ "status": false, "error": "domain is not valid" }

API

Class: Hypernic\Nawala

__construct(array $config = [])

Config options:

  • timeout (int, default 15): request timeout.
  • connect_timeout (int, default 10): connection timeout.
  • retries (int, default 1): retry count for transient errors (408, 429, 5xx).

check(string $domain): array

  • Normalizes the domain (lowercase, strips scheme, trims trailing dot).

  • Supports IDN via intl when available.

  • Calls the Komdigi endpoint and maps result:

    • blocked = true when Status === "Ada".

How It Works

  • Data source: https://trustpositif.komdigi.go.id.

  • Flow:

    1. Normalize domain + IDN handling.
    2. POST to the public endpoint.
    3. Pick the most relevant row and determine blocked.

Note: The upstream service may change without notice. Handle network failures and schema changes in your application.

Testing

This project includes PHPUnit tests.

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/test.php

Notes

  • Subject to Komdigi availability and rate limits.
  • Upstream HTML/token/endpoint changes may require library updates.
  • Results reflect the status at query time only.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-11