Results 1 to 5 of 5
  1. #1
    Master Untangler
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    140

    Question Untangle REST API

    Hi all,
    I'm not sure where to ask this -- poissibly move it to the correct forum section...

    I try to read out the configuration of our Untangle via REST API.
    When reading NetworkConfiguration, only the first entry of each List is properly filled, the following are nor really usable:
    Code:
    NetworkSettings.bypassRules={
      "list": [
        {
          "javaClass": "com.untangle.uvm.network.BypassRule",
          "ruleId": 1,
          "enabled": false,
          "bypass": false,
          "description": "[DONT BYPASS FRANKVPN]",
          "conditions": {
            "list": [
              {
                "javaClass": "com.untangle.uvm.network.BypassRuleCondition",
                "invert": false,
                "conditionType": "SRC_ADDR",
                "value": "172.16.137.14"
              },
              {
                "javaClass": "com.untangle.uvm.network.BypassRuleCondition",
                "invert": false,
                "conditionType": "DST_ADDR",
                "value": "10.10.109.6,10.10.9.9"
              }
            ]
          }
        },
        {
          "javaClass": "com.untangle.uvm.network.BypassRule",
          "ruleId": 2,
          "enabled": false,
          "bypass": true,
          "description": "TEST",
          "conditions": {
            "list": [
              {
                "javaClass": "com.untangle.uvm.network.BypassRuleCondition",
                "invert": false,
                "conditionType": "",
                "value": "95.90.184.171"
              },
              {
                "javaClass": "com.untangle.uvm.network.BypassRuleCondition",
                "invert": false,
                "conditionType": "",
                "value": "10.10.109.23"
              }
            ]
          }
        },
    As you can see the field "conditionType" is left empty. The same in Interfaces, where the type is left empty.

    Code:
    NetworkSettings.interfaces={
      "list": [
        {
          "interfaceId": 1,
          "physicalDev": "eth1",
          "systemDev": "eth1",
          "symbolicDev": "eth1",
          "configType": "ADDRESSED",
          "imqDev": "imq0",
          "bridgedTo": 0,
          "isWan": true,
          "downloadBandwidthKbps": 0,
          "name": "External",
          "isVirtualInterface": false,
          "supportedConfigTypes": "",
          "isVlanInterface": false,
          "vlanTag": 0,
          "vlanParent": 0,
          "v4ConfigType": "STATIC",
          "v4StaticAddress": "1.1.3.162",
          "v4StaticNetmask": "255.255.255.252",
          "v4StaticPrefix": 30,
          "v4StaticGateway": "1.1.3.161",
          "v4StaticDns1": "1.1.9.150",
          "v4StaticDns2": "1.1.9.151",
    (...left out for better visibility...)
        },
        {
          "interfaceId": 2,
          "physicalDev": "eth2",
          "systemDev": "eth2",
          "symbolicDev": "eth2",
          "configType": "",
          "imqDev": "",
          "bridgedTo": 1,
          "isWan": false,
          "downloadBandwidthKbps": 0,
          "name": "Internal",
          "isVirtualInterface": false,
          "supportedConfigTypes": "",
          "isVlanInterface": false,
          "vlanTag": 0,
          "vlanParent": 0,
          "v4ConfigType": "",
          "v4StaticAddress": "1.1.109.126",
          "v4StaticNetmask": "255.255.255.128",
          "v4StaticPrefix": 25,
          "v4StaticGateway": "1.1.109.126",
          "v4StaticDns1": "1.1.9.150",
          "v4StaticDns2": "",
          "v4Aliases": {
            "list": [
    (...left out for better visibility...)
        },
    here I would expect "configType" to be ADDRESSED too as in the first interface and v4ConfigType to be also STATIC.

    (IP addresses anonymised)

    Does anybody have a hint what I am doing wrong?

    Thanks in advance,
    Frank

  2. #2
    Master Untangler
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    140

    Default

    Nobody an idea? Here the code to check for the problem:

    Code:
    curl --location --request POST 'https://my.untangle.org/auth/login' \
    --cookie-jar coo.jar \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'username=admin' \
    --data-urlencode 'password=longpassword'
    
    TOKEN=$(curl --location --request POST 'https://my.untangle.org/admin/JSON-RPC' \
    --header 'Content-Type: application/json' \
    --cookie coo.jar \
    --cookie-jar coo.jar \
    --data-raw '{
            "id":297,
            "nonce":"",
            "method":"system.getNonce",
            "params":[]
    }' | cut -d: -f2|cut -d'"' -f2)
    
    
    
    curl --location --request POST 'https://my.untangle.org/admin/JSON-RPC' \
    --header 'Content-Type: application/json' \
    --cookie coo.jar \
    --cookie-jar coo.jar \
    --data-raw '{
            "id":297,
            "nonce":'$TOKEN',
            "method":"UvmContext.getWebuiStartupInfo",
            "params":[]
    }'
    The flat json string is a bit hard to read, but its the same result as the json.MarshalIndent(webuiinfo,""," ") in <I>go</I>.
    Last edited by frust; 06-15-2021 at 03:14 AM.

  3. #3
    Untangle Ninja
    WebFooL's Avatar
    Join Date
    Jan 2009
    Location
    Sweden (Eskilstuna)
    Posts
    5,243

    Default

    I normally tend to do my changes in Chrome and then use "F12" network module and right click on the JSON-RPC post/get sent and there use "Copy as cRUL" to get some hints :-)

  4. #4
    Untangler jcoffin's Avatar
    Join Date
    Aug 2008
    Location
    Sunnyvale, CA
    Posts
    9,665
    Attention: Support and help on the Untangle Forums is provided by
    volunteers and community members like yourself.
    If you need Untangle support please call or email support@untangle.com

  5. #5
    Master Untangler
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    140

    Exclamation solution

    Meanwhile I found out the reason for the missing entries.
    (by reading the developer source code)

    It comes from the jabsorb/Serializer class which wants to save space by not sending duplicate simple values and circular references. See https://github.com/Servoy/jabsorb/tr...orb/serializer

    Code:
    /**
       * Convert this FixUp to a JSONArray for transmission over JSON-RPC. The
       * JSONArray will contain two sub JSONArrays, the first one representing the
       * fixup location and the 2nd one representing the original location.
       *
    and appending this as "Fixup". In my opinion this does not really save space for this short strings but makes it nearly impossible in go and other languages to restore the original contents.

    Sadly this is never mentioned in the documentation of https://apidocs.untangle.com/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO 3.6.0 PL2