ローダー向けドキュメント
Lua 5.1相当のexecutor向け検証API契約と、調整用の最小サンプルです。利用環境での動作は保証しません。
キーと端末を検証する
認証不要の公開APIです。HTTPSでJSONをPOSTします。キーや生HWIDをログ・公開コードに含めないでください。
POST /api/v1/validate
Content-Type: application/json
{"key":"[YOUR_KEY]","hwid":"[YOUR_DEVICE_ID]"}初回検証でHWIDを紐付けます。保存されるのはSHA-256ハッシュで、生HWIDは保存しません。
成功とスクリプト取得
200 OK
{"url":"/api/v1/script/[token]",
"expires_at":"[RFC3339 UTC]"}urlは同一オリジンの相対パスです。有効期間は5分で、期限内は再取得できます。GET /api/v1/script/:token は200 text/plainで本文を返します。取得時もキー・配信状態を確認し、期限切れ・失効・キル停止後は404になります。トークンは公開しないでください。
失敗コード
403では {error:{code}} を返します。不正なJSONは400 invalid_json、レート制限は429 rate_limited と Retry-Afterヘッダーを返します。
invalid_key- キーが存在しない
revoked- キーが失効している
expired- 期限切れ(期限日はUTC当日を含む)
killed- プロジェクトが配信停止中
hwid_mismatch- 紐付いた端末と一致しない
rate_limited- Retry-Afterの秒数を待ってから再試行
判定順はレート制限、キー存在、失効、期限、配信停止、HWIDです。キーとIP単位で30回/分相当(burst 30、2秒に1枠補充)、IP全体で120回/分相当のトークンバケット制限があります。固定窓の回数保証ではありません。自動連打は避けてください。
サンプルLua
http.post / http.requestの引数・応答形状、JSONモジュール、HWID取得方法はexecutorごとに調整が必要です。JSONを含む環境差の吸収や再試行は実装していません。信頼できる配信元・許可されたコードにのみ使用してください。
-- Lua 5.1 / executor向けの最小サンプル。利用環境での動作保証はありません。
-- executorのhttp.post/http.request、JSON、loadstringの対応は環境ごとに確認してください。
-- 許可されたスクリプトにのみ使用し、キーやHWIDをログへ出力しないでください。
local BASE_URL = "https://fizex.net"
local KEY = "[YOUR_KEY]"
local HWID = "[YOUR_DEVICE_ID]" -- 利用環境の安定した識別子に置き換える
local json = require("json") -- executor提供のJSON encode/decodeに合わせて置き換える
local messages = {
expired = "キーの有効期限が切れています。",
revoked = "キーは失効しています。",
hwid_mismatch = "端末が一致しません。作成者へ確認してください。",
killed = "作成者が配信を停止しています。",
rate_limited = "リクエストが多すぎます。Retry-Afterの時間を待ってください。",
invalid_key = "キーが見つかりません。"
}
-- この例ではhttp.post(url, body, headers)が{StatusCode, Body, Headers}を返す想定。
-- executorのAPI仕様が異なる場合は、この呼び出しと応答フィールドを調整してください。
local ok, response = pcall(function()
return http.post(BASE_URL .. "/api/v1/validate",
json.encode({key = KEY, hwid = HWID}),
{["Content-Type"] = "application/json"})
end)
if not ok or type(response) ~= "table" then
print("検証APIに接続できませんでした。")
return
end
local decoded, result = pcall(json.decode, response.Body or "")
if not decoded or type(result) ~= "table" then
print("検証APIの応答を読み取れませんでした。")
return
end
if response.StatusCode ~= 200 then
local code = type(result.error) == "table" and result.error.code or "unknown_error"
print(messages[code] or ("検証失敗: " .. tostring(code)))
return
end
-- 成功契約: {url, expires_at}。expires_atはRFC3339 UTC、URLは5分で失効。
if type(result.url) ~= "string" or type(result.expires_at) ~= "string" then
print("配信URLがありません。")
return
end
-- 現行APIの相対URLだけを許可し、意図しないホストからの実行を防ぐ。
if not string.match(result.url, "^/api/v1/script/[%w_-]+$") then
print("想定外の配信URLです。")
return
end
local fetched, script_response = pcall(function()
return http.request({Url = BASE_URL .. result.url, Method = "GET"})
end)
if not fetched or type(script_response) ~= "table" or script_response.StatusCode ~= 200 then
print("スクリプトを取得できません。期限・失効・配信停止を確認してください。")
return
end
local source = script_response.Body
if type(source) ~= "string" then
print("スクリプト本文がありません。")
return
end
local chunk, compile_error = loadstring(source)
if not chunk then
print("Luaを読み込めません: " .. tostring(compile_error))
return
end
local executed, runtime_error = pcall(chunk)
if not executed then print("実行エラー: " .. tostring(runtime_error)) end