————-확인 추가 사항————–
I2PControl API 문서
I2PControl은 I2P router와 함께 번들로 제공되는 JSON-RPC 2.0 API입니다 (버전 0.9.39부터). 구조화된 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을 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/
응답 필드 (result) 공식 문서(GetI2P)에 따르면: - i2p.router.status (String) — 사람이 읽을 수 있는 상태 - i2p.router.uptime (long) — 밀리초 (또는 이전 i2pd의 경우 문자열) :contentReference[oaicite:0]{index=0} - i2p.router.version (String) — 버전 문자열 :contentReference[oaicite:1]{index=1} - i2p.router.net.bw.inbound.1s, i2p.router.net.bw.inbound.15s (double) — B/s 단위의 인바운드 대역폭 :contentReference[oaicite:2]{index=2} - i2p.router.net.bw.outbound.1s, i2p.router.net.bw.outbound.15s (double) — B/s 단위의 아웃바운드 대역폭 :contentReference[oaicite:3]{index=3} - i2p.router.net.status (long) — 숫자 상태 코드 (아래 enum 참조) :contentReference[oaicite:4]{index=4} - i2p.router.net.tunnels.participating (long) — 참여 중인 tunnel 수 :contentReference[oaicite:5]{index=5} - i2p.router.netdb.activepeers, fastpeers, highcapacitypeers (long) — netDB 피어 통계 :contentReference[oaicite:6]{index=6} - i2p.router.netdb.isreseeding (boolean) — reseed가 활성화되어 있는지 여부 :contentReference[oaicite:7]{index=7} - i2p.router.netdb.knownpeers (long) — 알려진 총 피어 수 :contentReference[oaicite:8]{index=8}
상태 코드 열거형 (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
네트워크 구성 매개변수(포트, upnp, 대역폭 공유 등)를 가져오거나 설정합니다
요청 예시 (현재 값 가져오기)
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는 문자열 대신 숫자 타입을 반환할 수 있습니다 — 클라이언트는 두 가지 모두를 처리해야 합니다. :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. 사용법 및 모범 사례
- 인증 시를 제외하고 항상
Token매개변수를 포함하세요. - 첫 사용 시 기본 비밀번호(
itoopie)를 변경하세요. - Java I2P의 경우, WebApps를 통해 I2PControl webapp이 활성화되어 있는지 확인하세요.
- 약간의 차이에 대비하세요: I2P 버전에 따라 일부 필드가 숫자 또는 문자열일 수 있습니다.
- 표시 친화적 출력을 위해 긴 상태 문자열을 줄바꿈하세요.