{"id":20226129,"url":"https://github.com/getdnsapi/getdns-ruby-bindings","last_synced_at":"2025-03-03T12:46:42.660Z","repository":{"id":34509937,"uuid":"38451332","full_name":"getdnsapi/getdns-ruby-bindings","owner":"getdnsapi","description":"Ruby bindings for getdns","archived":false,"fork":false,"pushed_at":"2015-07-20T18:35:59.000Z","size":224,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-01-13T23:32:21.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getdnsapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-02T19:00:25.000Z","updated_at":"2015-12-23T12:18:27.000Z","dependencies_parsed_at":"2022-09-06T04:12:12.099Z","dependency_job_id":null,"html_url":"https://github.com/getdnsapi/getdns-ruby-bindings","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getdnsapi%2Fgetdns-ruby-bindings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getdnsapi%2Fgetdns-ruby-bindings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getdnsapi%2Fgetdns-ruby-bindings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getdnsapi%2Fgetdns-ruby-bindings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getdnsapi","download_url":"https://codeload.github.com/getdnsapi/getdns-ruby-bindings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241670132,"owners_count":20000326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T07:16:25.695Z","updated_at":"2025-03-03T12:46:42.514Z","avatar_url":"https://github.com/getdnsapi.png","language":"Ruby","readme":"\n# getdns-ruby-bindings  #\n\nThis document explains how to make Getdns extension for Ruby\n\n\n## Installation and requirements\n\n * An installation of getdns 0.1.1 or later is required. Please see the https://github.com/getdnsapi/getdns GitHub.\n * Install Ruby\n * Then install bundler gem using command \"gem install bundler\". Bundler manages application dependencies and install into the gem library in your environment.\n\n Note: Please checkout Ruby Version Manager (RVM) https://rvm.io/\n\n\n## Basic Knowledge \n\nIn C, variables have types and data do not have types. Ruby is exactly opposite,\nRuby variables do not have a static type but data themselves have types, so data will need to converted between languages.\n\nData in Ruby are represented by the C type `VALUE'.  Each VALUE data\nhas its data-type.\n\nTo retrieve C data from a VALUE, you need to:\n   *    Identify the VALUE's data type\n   *    Convert the VALUE into C data\n\nEncapsulate a C struct as a Ruby object. There are two macros to do this wrapping, and one to retrieve your structure back out again.\n *   Data_Wrap_Struct: Take a C level pointer and shoves into a VALUE. Data_Wrap_Struct() returns a created DATA object.\n *   Data_Get_Struct:  To retrieve the C pointer from the Data object, use the macro Data_Get_Struct(). Unwrap the ruby object as a data_type, and set data* to point to it.\n\n#####Argument Checking\n *   rb_scan_args : It takes argc, argv, the number of required and optional arguments and pointers to the VALUE objects.\n\n    It will raise a Ruby exception when argument count is not as expected.\n    -   VALUE foo;\n    -    VALUE optional;\n    -    rb_scan_args(argc, argv, \"11\", \u0026foo, \u0026optional);\n    -    \"11\" tell rb_scan_args expect one required, one optional\n\n   *rb_scan_args(argc, argv, \"01\", \u0026optional);*\n    - \"10\" tell rb_scan_args expect one optional\n\n## getdns ruby binding project structure \n\n```\ngetdns-ruby-bindings/  \n    getdns.gemspec  \n    Rakefile  \n    ext/ \n        getdns/ \n            extconf.rb \n            *.cpp \n    lib/  \n        getdns/  \n            *.rb  \n    test/\n        tc_*.rb\n```\n\n##Ruby binding for getdns\n####getdns configuration\n\n * Install all of the required gems using command - \"bundle install\"\n\n```\n$ rake build_ext\n    /usr/bin/ruby extconf.rb\n    checking for main() in -lgetdns... yes\n    checking for main() in -lunbound... yes\n    checking for main() in -lidn... yes\n    checking for main() in -lldns... yes\n    creating Makefile\n    make\n    linking shared-object getdns/getdns.so\n    cp ext/getdns/getdns.bundle lib/\n```\n  * You can also execute \"bundle install\" after \"rake build_ext\"\n\n\n#####From here on we can call getdns methods two ways\n 1.\n  - After command 'rake build_ext'. cd /ext/getdns. To run all sync functions, async functions, options and extensions implementations:\n\n    ```\n    ruby getdns.rb\n\n    ```\n\n  - Run all sync functions, options and extensions tests:\n\n    ```\n    rake test\n    or\n    ruby ts_getdns.rb\n\n    ```\n\n - Run particular sync functions, async function, options/extensions implementations:(Require library before executing the script)\n\n   ```\n   ruby -r \"./dns_transport_module.rb\" -e \"Dns_transport_module.dns_transport 'verisign.com'\"\n\n   ```\n\n - Run particular option/extensions Test:\n\n    ```\n    ruby -r \"./tc_getdns_transport.rb\" -e \"Getdns_transport_option.new.test_getdns_transport_status 'verisign.com'\"\n\n    ```\n\n steps to add this extension as gem.\n\n```\n$ gem build getdns.gemspec\n    Successfully built RubyGem\n    Name: getdns-ruby\n    Version: 0.0.1\n    File: getdns-ruby-0.0.1.gem\n```\n\n```\n$ sudo gem install ./getdns-ruby-0.0.1.gem\n    Successfully installed getdns-ruby-0.0.1\n    Parsing documentation for getdns-ruby-0.0.1\n    Installing ri documentation for getdns-ruby-0.0.1\n    Done installing documentation for getdns-ruby after 0 seconds\n    1 gem installed\n```\n####Test gem and use:\nCheck if getdns_ruby gem is installed properly\n\n```\n$ irb \n    \u003e\u003e require 'getdns_ruby' \n    =\u003e true \n    \u003e\u003e ctx = Getdns::Context.new() \n    =\u003e #\u003cGetdns::Context:0x00000001a9d700\u003e \n    \u003e\u003e ctx.lookup(\"verisign.com\") \n```\n\nOR load gem directly using following command\n\n```\nirb -Ilib -rgetdns_ruby\n```\n\n\n#### Test some sample code\nNote: Load the ruby shell(irb) from directory lib/getdns for running sample code.\nThere are couple of ways to play around with getdns-ruby gem.\n\n1.\n - After gem installation testing  load any file for test. For example load 'dns_transport_module.rb'\n - Then invoke a method on a Ruby module\n\n```\n$ irb\n    \u003e\u003e load './dns_transport_module.rb'\n    =\u003e true\n    \u003e\u003e  Dns_transport_module.dns_transport('any domain name')\n```\n\n2.\n- Test code from .rb file\n\n```\n$ irb\n    \u003e\u003e require_relative '../../ext/getdns/getdns'\n    =\u003e true\n    \u003e\u003e require_relative 'getdns_constants'\n    =\u003e true\n    \u003e\u003e options = {\n             \"timeout\" =\u003e 10000,\n             \"return_dnssec_status\" =\u003e true,\n             \"dns_transport\" =\u003e GetdnsConstants::TRANSPORT_TCP_ONLY,\n             \"stub\" =\u003e true,\n             \"upstreams\" =\u003e [\"8.8.8.8\"],\n           }\n    =\u003e {\"timeout\"=\u003e10000, \"return_dnssec_status\"=\u003etrue, \"dns_transport\"=\u003e542, \"stub\"=\u003etrue, \"upstreams\"=\u003e[\"8.8.8.8\"]}\n    \u003e\u003e ctx = Getdns::Context.new(options)\n    =\u003e #\u003cGetdns::Context:0x007ff4a9080e30\u003e\n    \u003e\u003e  x = ctx.lookup('verisign.com')\n    =\u003e {\"answer_type\"=\u003e800, \"canonical_name\"=\u003e\"verisign.com.\", \"just_address_answers\"=\u003e[\"69.58.181.89\"], \"replies_full\"=\u003e[[140688806169888], [140688806169968]],\n       \"replies_tree\"=\u003e[{\"additional\"=\u003e[], \"answer\"=\u003e[{\"class\"=\u003e1, \"name\"=\u003e\"verisign.com.\", \"rdata\"=\u003e{\"ipv4_address\"=\u003e\"E:\\xB5Y\", \"rdata_raw\"=\u003e\"E:\\xB5Y\"}, \"ttl\"=\u003e17,\n        \"type\"=\u003e1}], \"answer_type\"=\u003e800, \"authority\"=\u003e[], \"canonical_name\"=\u003e\"verisign.com.\", \"dnssec_status\"=\u003e403, \"header\"=\u003e{\"aa\"=\u003e0, \"ad\"=\u003e0, \"ancount\"=\u003e1,\n         \"arcount\"=\u003e0, \"cd\"=\u003e0, \"id\"=\u003e27467, \"nscount\"=\u003e0, \"opcode\"=\u003e0, \"qdcount\"=\u003e1, \"qr\"=\u003e1, \"ra\"=\u003e1, \"rcode\"=\u003e0, \"rd\"=\u003e1, \"tc\"=\u003e0, \"z\"=\u003e0},\n         \"question\"=\u003e{\"qclass\"=\u003e1, \"qname\"=\u003e\"verisign.com.\", \"qtype\"=\u003e1}}, {\"additional\"=\u003e[], \"answer\"=\u003e[],\n         \"answer_type\"=\u003e800, \"authority\"=\u003e[{\"class\"=\u003e1, \"name\"=\u003e\"verisign.com.\", \"rdata\"=\u003e{\"expire\"=\u003e3600, \"mname\"=\u003e\"a2.nstld.com.\",\n         \"rdata_raw\"=\u003e[140688806166784], \"refresh\"=\u003e3600, \"retry\"=\u003e1209600, \"rname\"=\u003e\"vshostmaster.verisign.com.\", \"serial\"=\u003e2011041162}, \"ttl\"=\u003e738, \"type\"=\u003e6}],\n         \"canonical_name\"=\u003e\"verisign.com.\", \"dnssec_status\"=\u003e403, \"header\"=\u003e{\"aa\"=\u003e0, \"ad\"=\u003e0, \"ancount\"=\u003e0, \"arcount\"=\u003e0, \"cd\"=\u003e0, \"id\"=\u003e26773, \"nscount\"=\u003e1,\n         \"opcode\"=\u003e0, \"qdcount\"=\u003e1, \"qr\"=\u003e1, \"ra\"=\u003e1, \"rcode\"=\u003e0, \"rd\"=\u003e1, \"tc\"=\u003e0, \"z\"=\u003e0}, \"question\"=\u003e{\"qclass\"=\u003e1, \"qname\"=\u003e\"verisign.com.\", \"qtype\"=\u003e28}}],\n          \"status\"=\u003e900}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetdnsapi%2Fgetdns-ruby-bindings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetdnsapi%2Fgetdns-ruby-bindings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetdnsapi%2Fgetdns-ruby-bindings/lists"}