wiki:i2pcontrol

Version 4 (modified by tuna, 4 years ago) (diff)

This page will outline the API2 for i2pcontrol

Developer headsup!

  • All RPC paramters will now be lower case. This *will* break backwards compatibility with API1 implementations. The reasons for this is to provide users of ≥API2 with simplest most coherent possible API.

API 2

{
  "id": **id**,
  "method": **method_name**,
  "params": {
    "token": "**auth_token**"
    "method_param": **method_parameter_value**,

  },
  "jsonrpc": "2.0"
}

{
  "id": **id**,
  "result": **result_value**,
  "jsonrpc": "2.0"
}
  • id - The id number or the request, it's used to identify which reply was spawn by which request
  • method_name - The method name is the name of the RPC that is being invoked
  • auth_token - This is the session authentication token, it needs to be supplied with every RPC except for the 'authenticate' call
  • method_parameter_value - This is the method parameter. It is used to offer a different flavors of a method. Like 'get', 'set' and flavors like that.
  • result_value - This is the value that RPC returns. Its type and contents depends on the method and which method

Prefixes

The naming for will be done similar to how it's done in CSS, with vendor prefixes for the different API implementations (i2p, kovri, i2pd).

XXX.YYY.ZZZ
i2p.XXX.YYY.ZZZ
i2pd.XXX.YYY.ZZZ
kovri.XXX.YYY.ZZZ

The overall idea with vendor specific prefixes to allow for some wiggle room and let vendors innovate without having to wait for every other implementation to catch up. If is implemented by all implementations it can be moved under the umbrella of the next API version

Method reading guide

  • rpc.method
    • parameter [type of parameter]: [null], [nubmer], [string], [boolean], [array] or [object]. [object] being a {key:value} map.
      "return_value" [string] // This is the value returned by the RPC call
      

Methods

  • authenticate - Given that a correct password is provided, this method provides you with a token for further access and a list of supported API levels.
    • password [string]: The password for this i2pcontrol implementation
      [object]
      {
        "token" : [string], // The token to be used be supplied with all other RPC methods
        "api" : [[int],[int], ...]  // A list of supported API levels.
      }
      
  • i2pcontrol. - Configure i2pcontrol
    • i2pcontrol.address - Get/Set? the ip address that i2pcontrol listens to.
      • get [null]: This parameter does not need to be set.
        "0.0.0.0" [string]
        
      • set [string]: This will be an ip address like "0.0.0.0" or "192.168.0.1"
        [nil]
        
    • i2pcontrol.password - Change the i2pcontrol password.
      • set [string]: Set the new password to this string
        [nil]
        
    • i2pcontrol.port - Get/Set? the port that i2pcontrol listens to.
      • get [null]: This parameter does not need to be set.
        7650 [number]
        
      • set [number]: Change the port that i2pcontrol listens to to this port
        [nil]
        
  • settings. - Get/Set? i2p instance settings
    • settings.ntcp.port - NTCP port
      • get [null]: This parameter does not need to be set.
        0 [number]
        
      • set [number]: Set new NTCP port.
        [nil]
        
    • settings.ntcp.hostname - Get NTCP hostname
      • get [null]: This parameter does not need to be set.
        "0.0.0.0" [string]
        
      • set [string]: Set new hostname
        [nil]
        
    • settings.ntcp.autoip - Get IP auto detection setting for NTCP
      • get [null]: This parameter does not need to be set.
        true [boolean]
        
      • set [boolean]: Set NTCP IP auto detection
        [nil]
        
    • settings.ssu.port - SSU port
      • get [null]: This parameter does not need to be set.
        0 [number]
        
      • set [number]: Set new SSU port.
        [nil]
        
    • settings.ssu.hostname - Get SSU hostname
      • get [null]: This parameter does not need to be set.
        "0.0.0.0" [string]
        
      • set [string]: Set new SSU hostname
        [nil]
        
    • settings.ssu.autoip - Get IP auto detection setting for SSU
      • get [nil]: This parameter does not need to be set.
        true [boolean]
        
      • set [boolean]: Set SSU IP auto detection
        [nil]
        
    • settings.upnp - Enable or disable UPNP
      • get [nil]: This parameter does not need to be set.
        true [boolean]
        
      • set [boolean]: Set SSU IP auto detection
        [nil]
        
    • settings.bandwidth.in - Inbound bandwidth settings
    • settings.bandwidth.out - Outbound bandwidth settings
      • get [nil]: This parameter does not need to be set.
        0 [number]
        
      • set [number]: Set the bandwidth limit
        [nil]
        
  • stats. - Get stats from the i2p instance
    • stats.advanced - This method provides access to all stats kept within the instance.
      • get [string]: Name of the advanced stat to be provided
      • Optional: period [number]: The period for the requested stat
    • stats.knownpeers - Returns the number of known peers
    • stats.uptime - Returns the time in ms since the router started
    • stats.bandwidth.in - Returns the inbound bandwidth (ideally for the last second)
    • stats.bandwidth.out - Returns the outbound bandwidth (ideally for the last second)'
    • stats.tunnels.participating - Returns the number of tunnels participated in currently
    • stats.netdb.peers.active - Returns the number of peers we've recently communicated with
    • stats.netdb.peers.fast - Returns the number of 'fast' peers
    • stats.netdb.peers.highcapacity - Returns the number of 'high capacity' peers
    • stats.netdb.peers.known - Returns the number of known peers
      • get [null]: This parameter does not need to be set.
        0.0 [number]
        
  • status. - Get i2p instance status
    • status.router - Get router status
      • get [null]: This parameter does not need to be set.
        "status" [string]
        
    • status.net - Get router network status
      • get [null]: This parameter does not need to be set.
        0 [number]
        /**
         *    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
         */
        
    • status.isfloodfill - Is the i2p instance currently a floodfill
      • get [null]: This parameter does not need to be set.
        true [boolean]
        
    • status.isreseeding - Is the i2p instance currently reseeding
      • get [null]: This parameter does not need to be set.
        true [boolean]
        
    • status.ip - Public IP detected of this i2p instance
      • get [null]: This parameter does not need to be set.
        "0.0.0.0" [string]