————-चेक ऐड स्टफ————–
I2PControl API दस्तावेज़
I2PControl एक JSON-RPC 2.0 API है जो I2P router के साथ बंडल आती है (संस्करण 0.9.39 से)। यह structured JSON अनुरोधों के माध्यम से router की प्रमाणित निगरानी और नियंत्रण सक्षम करता है।
डिफ़ॉल्ट पासवर्ड:
itoopie— यह फैक्ट्री डिफ़ॉल्ट है और सुरक्षा के लिए इसे तुरंत बदला जाना चाहिए।
1. अवलोकन और पहुँच
| Implementation | Default Endpoint | Protocol | Enabled by Default | Notes |
|---|---|---|---|---|
| Java I2P (2.10.0+) | http://127.0.0.1:7657/jsonrpc/ | HTTP | ❌ Must be enabled via WebApps (Router Console) | Bundled webapp |
| i2pd (C++ implementation) | https://127.0.0.1:7650/ | HTTPS | ✅ Enabled by default | Legacy plugin behavior |
2. JSON-RPC प्रारूप
सभी अनुरोध JSON-RPC 2.0 संरचना का पालन करते हैं:
{
"jsonrpc": "2.0",
"id": "1",
"method": "MethodName",
"params": {
/* named parameters */
}
}
एक सफल प्रतिक्रिया में result फील्ड शामिल होता है; असफलता पर, एक error ऑब्जेक्ट वापस किया जाता है:
{
"jsonrpc": "2.0",
"id": "1",
"result": { /* data */ }
}
या
{
"jsonrpc": "2.0",
"id": "1",
"error": {
"code": -32001,
"message": "Invalid password"
}
}
3. प्रमाणीकरण प्रवाह
अनुरोध (प्रमाणीकरण)
curl -s -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "Authenticate",
"params": {
"API": 1,
"Password": "itoopie"
}
}' \
http://127.0.0.1:7657/jsonrpc/
सफल प्रतिक्रिया
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"Token": "a1b2c3d4e5",
"API": 1
}
}
आपको उस Token को सभी बाद के requests में params में शामिल करना होगा।
4. विधियां और एंडपॉइंट्स
4.1 RouterInfo
router के बारे में मुख्य टेलीमेट्री जानकारी प्राप्त करता है।
अनुरोध उदाहरण
curl -s -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "2",
"method": "RouterInfo",
"params": {
"Token": "a1b2c3d4e5",
"i2p.router.version": "",
"i2p.router.status": "",
"i2p.router.net.status": "",
"i2p.router.net.tunnels.participating": "",
"i2p.router.net.bw.inbound.1s": "",
"i2p.router.net.bw.outbound.1s": ""
}
}' \
http://127.0.0.1:7657/jsonrpc/
Response Fields (result) आधिकारिक दस्तावेजों (GetI2P) के अनुसार: - i2p.router.status (String) — एक human-readable स्थिति - i2p.router.uptime (long) — milliseconds (या पुराने i2pd के लिए string) :contentReference[oaicite:0]{index=0} - i2p.router.version (String) — version string :contentReference[oaicite:1]{index=1} - i2p.router.net.bw.inbound.1s, i2p.router.net.bw.inbound.15s (double) — B/s में inbound bandwidth :contentReference[oaicite:2]{index=2} - i2p.router.net.bw.outbound.1s, i2p.router.net.bw.outbound.15s (double) — B/s में outbound bandwidth :contentReference[oaicite:3]{index=3} - i2p.router.net.status (long) — numeric स्थिति कोड (नीचे enum देखें) :contentReference[oaicite:4]{index=4} - i2p.router.net.tunnels.participating (long) — भाग लेने वाली tunnels की संख्या :contentReference[oaicite:5]{index=5} - i2p.router.netdb.activepeers, fastpeers, highcapacitypeers (long) — netDb peer stats :contentReference[oaicite:6]{index=6} - i2p.router.netdb.isreseeding (boolean) — क्या reseed सक्रिय है :contentReference[oaicite:7]{index=7} - i2p.router.netdb.knownpeers (long) — कुल ज्ञात peers :contentReference[oaicite:8]{index=8}
स्टेटस कोड Enum (i2p.router.net.status)
| Code | Meaning |
|---|---|
| 0 | OK |
| 1 | TESTING |
| 2 | FIREWALLED |
| 3 | HIDDEN |
| 4 | WARN_FIREWALLED_AND_FAST |
| 5 | WARN_FIREWALLED_AND_FLOODFILL |
| 6 | WARN_FIREWALLED_WITH_INBOUND_TCP |
| 7 | WARN_FIREWALLED_WITH_UDP_DISABLED |
| 8 | ERROR_I2CP |
| 9 | ERROR_CLOCK_SKEW |
| 10 | ERROR_PRIVATE_TCP_ADDRESS |
| 11 | ERROR_SYMMETRIC_NAT |
| 12 | ERROR_UDP_PORT_IN_USE |
| 13 | ERROR_NO_ACTIVE_PEERS_CHECK_CONNECTION_AND_FIREWALL |
| 14 | ERROR_UDP_DISABLED_AND_TCP_UNSET |
4.2 GetRate
दिए गए समय अवधि के दौरान दर मेट्रिक्स (जैसे बैंडविड्थ, tunnel सफलता) प्राप्त करने के लिए उपयोग किया जाता है।
अनुरोध उदाहरण
curl -s -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "3",
"method": "GetRate",
"params": {
"Token": "a1b2c3d4e5",
"Stat": "bw.combined",
"Period": 60000
}
}' \
http://127.0.0.1:7657/jsonrpc/
नमूना प्रतिक्रिया
{
"jsonrpc": "2.0",
"id": "3",
"result": {
"Rate": 12345.67
}
}
4.3 RouterManager
प्रशासनिक कार्य करें।
अनुमतित पैरामीटर / मेथड्स - Restart, RestartGraceful - Shutdown, ShutdownGraceful - Reseed, FindUpdates, Update :contentReference[oaicite:10]{index=10}
अनुरोध उदाहरण
curl -s -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "4",
"method": "RouterManager",
"params": {
"Token": "a1b2c3d4e5",
"Restart": true
}
}' \
http://127.0.0.1:7657/jsonrpc/
सफल प्रतिक्रिया
{
"jsonrpc": "2.0",
"id": "4",
"result": {
"Restart": null
}
}
4.4 NetworkSetting
नेटवर्क कॉन्फ़िगरेशन पैरामीटर प्राप्त करें या सेट करें (ports, upnp, bandwidth share, आदि)
अनुरोध उदाहरण (वर्तमान मान प्राप्त करें)
curl -s -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "5",
"method": "NetworkSetting",
"params": {
"Token": "a1b2c3d4e5",
"i2p.router.net.ntcp.port": null,
"i2p.router.net.ssu.port": null,
"i2p.router.net.bw.share": null,
"i2p.router.net.upnp": null
}
}' \
http://127.0.0.1:7657/jsonrpc/
नमूना प्रतिक्रिया
{
"jsonrpc": "2.0",
"id": "5",
"result": {
"i2p.router.net.ntcp.port": "1234",
"i2p.router.net.ssu.port": "5678",
"i2p.router.net.bw.share": "50",
"i2p.router.net.upnp": "true",
"SettingsSaved": true,
"RestartNeeded": false
}
}
नोट: 2.41 से पहले के i2pd versions स्ट्रिंग्स के बजाय numeric types वापस कर सकते हैं — clients को दोनों को handle करना चाहिए। :contentReference[oaicite:11]{index=11}
4.5 उन्नत सेटिंग्स
आंतरिक router पैरामीटर्स को संशोधित करने की अनुमति देता है।
अनुरोध उदाहरण
curl -s -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "6",
"method": "AdvancedSettings",
"params": {
"Token": "a1b2c3d4e5",
"Set": {
"router.sharePercentage": "75",
"i2np.flushInterval": "6000"
}
}
}' \
http://127.0.0.1:7657/jsonrpc/
प्रतिक्रिया उदाहरण
{
"jsonrpc": "2.0",
"id": "6",
"result": {
"Set": {
"router.sharePercentage": "75",
"i2np.flushInterval": "6000"
}
}
}
5. त्रुटि कोड
मानक JSON-RPC2 त्रुटि कोड
| Code | Meaning |
|---|---|
| -32700 | JSON parse error |
| -32600 | Invalid request |
| -32601 | Method not found |
| -32602 | Invalid parameters |
| -32603 | Internal error |
| Code | Meaning |
|---|---|
| -32001 | Invalid password provided |
| -32002 | No authentication token presented |
| -32003 | Authentication token doesn't exist |
| -32004 | The provided authentication token was expired and will be removed |
| -32005 | The version of the I2PControl API used wasn't specified, but is required to be specified |
| -32006 | The version of the I2PControl API specified is not supported by I2PControl |
6. उपयोग और सर्वोत्तम प्रथाएं
- हमेशा
Tokenparameter शामिल करें (प्रमाणीकरण के अलावा)। - पहले उपयोग पर डिफ़ॉल्ट password (
itoopie) बदलें। - Java I2P के लिए, WebApps के माध्यम से I2PControl webapp सक्षम होना सुनिश्चित करें।
- थोड़ी भिन्नता के लिए तैयार रहें: कुछ fields I2P version के आधार पर numbers या strings हो सकते हैं।
- display-friendly output के लिए लंबे status strings को wrap करें।