Changeset 765 for trunk


Ignore:
Timestamp:
06/23/17 13:01:18 (8 years ago)
Author:
Kris Deugau
Message:

/trunk

Commit long-pending POD addition to dns-rpc.cgi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns-rpc.cgi

    r749 r765  
    134134exit;
    135135
     136
     137=head1 dns-rpc.cgi
     138
     139The RPC API for DeepNet DNS Administrator.
     140
     141=head2 Common required arguments
     142
     143A few arguments for primitive authorization are required on all calls.
     144
     145=over 4
     146
     147=item rpcuser
     148
     149A string identifying the remote user in some way.  Used to generate a hidden local user for logging.
     150
     151=item rpcsystem
     152
     153A string identifying the remote system doing the RPC call.  This is checked against a list of IPs allowed to
     154claim this system identifier.
     155
     156=back
     157
     158=cut
     159
    136160##
    137161## Subs below here
     
    214238## Shims for DNSDB core subs
    215239##
     240
     241
     242=head2 Exposed RPC subs
     243
     244=cut
     245#over 4
     246
    216247
    217248#sub connectDB {
     
    225256#sub _log {
    226257
     258
     259=head3 addDomain
     260
     261Add a domain.  Note that while this should accept a formal .arpa reverse zone name, doing so will disrupt
     262several features that ease management of bulk reverse records.  Use C<addRDNS> to add reverse zones.
     263
     264=over 4
     265
     266=item domain
     267
     268The domain to add.
     269
     270=item group
     271
     272The group ID to add the domain to.  Group ID 1 is expected to exist;  otherwise a list of groups should be
     273retrieved with C<getGroupList> for selection.  The group defines which template records will be used to create
     274the initial record set in the domain.
     275
     276=item state
     277
     278Active/inactive flag.  Send C<active>, C<on>, or C<1> for domains that should be published;  C<inactive>,
     279C<off>, or C<0> for domains that should be added but not currently published.
     280
     281=item defloc
     282
     283Optional argument for the default location/view the domain's records should be published in.  Leave blank, or a
     284list of locations can be retrieved with C<getLocList> or C<getLocDropdown> for selection.
     285
     286=back
     287
     288Returns the ID of the domain.
     289
     290=cut
    227291sub addDomain {
    228292  my %args = @_;
     
    235299}
    236300
     301
     302=head3 delZone
     303
     304Delete a domain or reverse zone
     305
     306=over 4
     307
     308=item zone
     309
     310The domain name, domain ID, .arpa zone name, or logical CIDR range to remove
     311
     312=item revrec
     313
     314Flag to indicate whether to go looking for a domain or a reverse zone to delete.  Accepts "y" or "n".
     315
     316=back
     317
     318Returns an informational confirmation message on success.
     319
     320=cut
    237321sub delZone {
    238322  my %args = @_;
     
    258342} # delZone()
    259343
     344
    260345#sub domainName {}
    261346#sub revName {}
    262347
     348
     349=head3 domainID
     350
     351Retrieve the ID for a domain
     352
     353=over 4
     354
     355=item domain
     356
     357The domain name to find the ID for
     358
     359=back
     360
     361Returns the integer ID of the domain if found.
     362
     363=cut
    263364sub domainID {
    264365  my %args = @_;
     
    273374#sub revID {}
    274375
     376
     377=head3 addRDNS
     378
     379Add a reverse zone
     380
     381=over 4
     382
     383=item revzone
     384
     385The logical reverse zone to be added.  Can be specified as either formal .arpa notation or a valid CIDR
     386netblock.  Using a CIDR netblock allows logical aggregation of related records even if the CIDR range covers
     387multiple formal .arpa zone boundaries.  For example, the logical zone 192.168.4.0/22 covers
     3884.168.192.in-addr.arpa, 5.168.192.in-addr.arpa, 6.168.192.in-addr.arpa, and 7.168.192.in-addr.arpa, and will be
     389correctly published as such.
     390
     391=item revpatt
     392
     393A string representing the pattern to use for an initial template record.
     394
     395=item group
     396
     397The group ID to add the zone to.
     398
     399=item state
     400
     401Active/inactive flag.  Send C<active>, C<on>, or 1 for zones that should be published;  C<inactive>,
     402C<off>, or C<0> for zones that should be added but not currently published.
     403
     404=item defloc
     405
     406Optional argument for the default location/view the zone's records should be published in.  Leave blank, or a
     407list of locations can be retrieved with C<getLocList> or C<getLocDropdown> for selection.
     408
     409=back
     410
     411Returns the zone ID on success.
     412
     413=cut
    275414sub addRDNS {
    276415  my %args = @_;
     
    287426#sub getZoneLocation {}
    288427
     428
     429=head3 addGroup
     430
     431Add a group
     432
     433=over 4
     434
     435=item groupname
     436
     437The name for the new group
     438
     439=item parent_id
     440
     441The ID of the group to put the new group in
     442
     443=back
     444
     445Note that the RPC API does not currently expose the full DNSDB::addGroup interface;  the permissions hashref is
     446substituted with a reasonable standard default user permissions allowing users to add/edit/delete zones and
     447records.
     448
     449Returns literal 'OK' on success.
     450
     451=cut
    289452sub addGroup {
    290453  my %args = @_;
     
    305468}
    306469
     470
     471=head3 delGroup
     472
     473Delete a group.  The group must be empty of users, zones, or subgroups.
     474
     475=over 4
     476
     477=item group
     478
     479The group name or group ID to delete
     480
     481=back
     482
     483Returns an informational message on success.
     484
     485=cut
    307486sub delGroup {
    308487  my %args = @_;
     
    330509#sub groupID {}
    331510
     511
     512=head3 addUser
     513
     514Add a user.
     515
     516=over 4
     517
     518=item username
     519
     520The username to add
     521
     522=item group
     523
     524The group ID to add the user in.  Users in subgroups only have access to data in that group and its subgroups.
     525
     526=item pass
     527
     528The password for the account
     529
     530=item state
     531
     532Flag to indicate if the account should be active on creation or set to inactive.  Accepts the same values as
     533domains and reverse zones - C<active>, C<on>, or C<1> for an active user, C<inactive>, C<off>, or C<0> for an
     534inactive one.
     535
     536=back
     537
     538B<Optional arguments>
     539
     540=over 4
     541
     542=item type
     543
     544Type of user account to add.  Current types are C<u> (normal user) and C<s> (superuser).  Defaults to C<u>.
     545
     546=item permstring
     547
     548A string encoding the permissions a normal user receives.  By default this is set to C<i> indicating
     549permissions are inherited from the group.
     550
     551C<c:[digits]> clones permissions from user with id [digits]
     552
     553C<C:,[string]> sets the exact permissions indicated by [string].  It is currently up to the caller to ensure
     554that related/cascading permissions are set correctly;  see C<%DNSDB::permchains> for the current set.  Current
     555valid permission identifiers match
     556C<(group|user|domain|record|location|self)_(edit|create|delete|locchg|view)>, however see C<@DNSDB::permtypes>
     557for the exact list.
     558
     559The comma after the colon is not a typo.
     560
     561=item fname
     562
     563First name
     564
     565=item lname
     566
     567Last name
     568
     569=item phone
     570
     571Phone number
     572
     573=back
     574
     575Note that some user properties originate in DNS Administrator's inspiration, VegaDNS.
     576
     577=cut
    332578sub addUser {
    333579  my %args = @_;
     
    355601#sub checkUser {}
    356602
     603
     604=head3 updateUser
     605
     606Update a user's username, password, state, type, first/last names, and/or phone number
     607
     608Most arguments are the same as for addUser.
     609
     610=over 4
     611
     612=item uid
     613
     614The ID of the user record
     615
     616=item username
     617
     618The username
     619
     620=item group
     621
     622The group ID the user is in (for logging).  Users cannot currently be moved to a different group.
     623
     624=item pass
     625
     626An updated password, if provided.  Leave blank to keep the existing password.
     627
     628=item state
     629
     630The account state (active/inactive).  Takes the same values as addUser.
     631
     632=item type
     633
     634The account type (user [C<u>] or superuser [C<S>])
     635
     636=item fname
     637
     638First name (optional)
     639
     640=item lname
     641
     642Last name (optional)
     643
     644=item phone
     645
     646Phone contact (optional)
     647
     648=back
     649
     650=cut
    357651sub updateUser {
    358652  my %args = @_;
     
    376670}
    377671
     672
     673=head3 delUser
     674
     675Delete a user
     676
     677=over 4
     678
     679=item uid
     680
     681The ID of the user record to delete
     682
     683=back
     684
     685=cut
    378686sub delUser {
    379687  my %args = @_;
     
    398706#sub getLocList {}
    399707
     708
     709=head3 getLocDropdown
     710
     711Retrieve a list of locations for display in a dropdown.
     712
     713=over 4
     714
     715=item group
     716
     717The group ID to select locations from
     718
     719=item defloc
     720
     721Optional argument to flag the "default" location in the list
     722
     723=back
     724
     725Returns an arrayref to a list of hashrefs with elements C<locname>, C<loc> and C<selected>.  C<selected> will
     726be 0 for all entries unless the C<loc> value matches C<defloc>, where it will be set to 1.
     727
     728=cut
    400729sub getLocDropdown {
    401730  my %args = @_;
     
    408737}
    409738
     739
     740=head3 getSOA
     741
     742Retrieve the SOA record for a zone
     743
     744=over 4
     745
     746=item defrec
     747
     748Default/live records flag.  Accepts C<y> and C<n>.
     749
     750=item revrec
     751
     752Forward/reverse flag.  Accepts C<y> and C<n>.
     753
     754=item id
     755
     756The zone ID (if C<defrec> is C<y>) or the group ID (if C<defrec> is C<n>) to retrieve the SOA from
     757
     758=back
     759
     760=cut
    410761sub getSOA {
    411762  my %args = @_;
     
    428779#sub updateSOA {}
    429780
     781
     782=head3 getRecLine
     783
     784Retrieve all fields for a specific record
     785
     786=over 4
     787
     788=item defrec
     789
     790Default/live records flag.  Accepts C<y> and C<n>.
     791
     792=item revrec
     793
     794Forward/reverse flag.  Accepts C<y> and C<n>.  Mildly abused to determine whether to include C<distance>,
     795C<weight>, and C<port> fields, since MX and SRV records don't make much sense in reverse zones.
     796
     797=item id
     798
     799The record ID (if C<defrec> is C<y>) or default record ID (if C<defrec> is C<n>) to retrieve
     800
     801=back
     802
     803=cut
    430804sub getRecLine {
    431805  my %args = @_;
     
    442816}
    443817
     818
     819=head3 getRecList
     820
     821Retrieve a list of records for a zone.
     822
     823=over 4
     824
     825=item id
     826
     827The zone ID (if C<defrec> is C<n>) or group ID (if C<defrec> is C<y>) to retrieve records from
     828
     829=item defrec
     830
     831Default/live records flag.  Accepts C<y> and C<n>.
     832
     833=item revrec
     834
     835Forward/reverse flag.  Accepts C<y> and C<n>.
     836
     837=back
     838
     839Optional arguments
     840
     841=over 4
     842
     843=item offset
     844
     845Offset from the start of the raw record list.  Mainly for pagination.  Defaults 0.
     846
     847=item nrecs
     848
     849Number of records to return.  Defaults to C<$DNSDB::perpage>
     850
     851=item sortby
     852
     853Sort field.  Defaults to host for domain zones, val for reverse zones.  Supports multifield sorts;  pass the
     854fields in order separated by commas.
     855
     856=item sortorder
     857
     858SQL sort order.  Defaults to C<ASC>.
     859
     860=item filter
     861
     862Return only records whose host or val fields match this string.
     863
     864=item type, distance, weight, port, ttl, description
     865
     866If these arguments are present, use the value to filter on that field.
     867
     868=back
     869
     870=cut
    444871sub getRecList {
    445872  my %args = @_;
     
    486913}
    487914
     915
     916=head3 getRecCount
     917
     918Return count of non-SOA records in zone (or default records in a group).
     919
     920Uses the same arguments as getRecList, except for C<offset>, C<nrecs>, C<sortby>, and C<sortorder>.
     921
     922=cut
    488923sub getRecCount {
    489924  my %args = @_;
     
    525960} # getRecCount()
    526961
     962
     963=head3 addRec
     964
     965Add a record to a zone or add a default record to a group.
     966
     967Note that the name, type, and address arguments may be modified for normalization or to match available zones
     968for A+PTR and related metatypes.
     969
     970=over 4
     971
     972=item defrec
     973
     974Default/live records flag. Accepts C<y> and C<n>.
     975
     976=item revrec
     977
     978Forward/reverse flag. Accepts C<y> and C<n>.
     979
     980=item parent_id
     981
     982The ID of the parent zone or group.
     983
     984=item name
     985
     986The fully-qualified hostname for the record.  Trailing periods will automatically be stripped for storage, and
     987added on export as needed.  Note that for reverse zone records, this is the nominal record target.
     988
     989=item type
     990
     991The record type.  Both the nominal text identifiers and the bare integer types are accepted.
     992
     993=item address
     994
     995The record data or target.  Note that for reverse zones this is the nominal .arpa name for the record.
     996
     997=item ttl
     998
     999The record TTL.
     1000
     1001=item location
     1002
     1003The location identifier for the record.
     1004
     1005=item expires
     1006
     1007Flag to indicate the record will either expire at a certain time or become active at a certain time.
     1008
     1009=item stamp
     1010
     1011The timestamp a record will expire or become active at.  Note that depending on the DNS system in use this may
     1012not result in an exact expiry or activation time.
     1013
     1014=back
     1015
     1016B<Optional arguments>
     1017
     1018=over 4
     1019
     1020=item distance
     1021
     1022MX and SRV distance or priority
     1023
     1024=item weight
     1025
     1026SRV weight
     1027
     1028=item port
     1029
     1030SRV port number
     1031
     1032=back
     1033
     1034=cut
    5271035# The core sub uses references for some arguments to allow limited modification for
    5281036# normalization or type+zone matching/mapping/availability.
     
    5561064} # rpc_addRec
    5571065
     1066
     1067=head3 updateRec
     1068
     1069Update a record.
     1070
     1071Takes the same arguments as C<addRec> except that C<id> is the record to update, not the primary parent zone ID.
     1072
     1073If C<stamp> is blank or undefined, any timestamp will be removed.
     1074
     1075=cut
    5581076sub rpc_updateRec {
    5591077  my %args = @_;
     
    5901108
    5911109
     1110
     1111=head3 addOrUpdateRevRec
     1112
     1113Add or update a reverse DNS record (usually A+PTR template) as appropriate based on a passed CIDR address and
     1114hostname pattern.  The record will automatically be downconverted to a PTR template if the forward zone
     1115referenced by the hostname pattern is not managed in this DNSAdmin instance.
     1116
     1117=over 4
     1118
     1119=item cidr
     1120
     1121The CIDR address or IP for the record
     1122
     1123=item name
     1124
     1125The hostname pattern for template records, or the hostname for single IP records
     1126
     1127=back
     1128
     1129=cut
    5921130# Takes a passed CIDR block and DNS pattern;  adds a new record or updates the record(s) affected
    5931131sub addOrUpdateRevRec {
     
    6851223} # done addOrUpdateRevRec()
    6861224
     1225
     1226=head3 updateRevSet
     1227
     1228Update reverse DNS entries for a set of IP addresses all at once.  Calls addOrUpdateRevRec internally.
     1229
     1230=over 4
     1231
     1232=item host_[ip.add.re.ss] (Multiple entries)
     1233
     1234One or more identifiers for one or more IP addresses to update reverse DNS on.  The value of the argument is the
     1235hostname to set on that IP.
     1236
     1237=back
     1238
     1239=cut
    6871240# Update rDNS on a whole batch of IP addresses.  Presented as a separate sub via RPC
    6881241# since RPC calls can be s...l...o...w....
     
    7151268} # done updateRevSet()
    7161269
     1270
     1271=head3 splitTemplate
     1272
     1273Split a PTR template record into multiple records.
     1274
     1275=over 4
     1276
     1277=item cidr
     1278
     1279The CIDR address for the record to split
     1280
     1281=item newmask
     1282
     1283The new masklength for the new records. 
     1284
     1285=back
     1286
     1287=cut
    7171288# Split a template record as per a passed CIDR.
    7181289# Requires the CIDR and the new mask length
     
    7821353} # done splitTemplate()
    7831354
     1355
     1356=head3 resizeTemplate
     1357
     1358Resize a template record based on a pair of passed CIDR addresses.
     1359
     1360=over 4
     1361
     1362=item oldcidr
     1363
     1364The old CIDR to look for in the existing records
     1365
     1366=item newcidr
     1367
     1368The new CIDR
     1369
     1370=back
     1371
     1372=cut
    7841373# Resize a template according to an old/new CIDR pair
    7851374# Takes the old cidr in $args{oldcidr} and the new in $args{newcidr}
     
    8501439} # done resizeTemplate()
    8511440
     1441
     1442=head3 templatesToRecords
     1443
     1444Convert one or more template records to individual IP records, expanding the template as would be done on
     1445export.
     1446
     1447=over 4
     1448
     1449=item templates
     1450
     1451A list/array of CIDR addresses to search for for conversion.
     1452
     1453=back
     1454
     1455=cut
    8521456# Convert one or more template records to a set of individual IP records.  Expands the template.
    8531457# Handle the case of nested templates, although the primary caller (IPDB) should not be
     
    9281532} # done templatesToRecords()
    9291533
     1534
     1535=head3 delRec
     1536
     1537Delete a record.
     1538
     1539=over 4
     1540
     1541=item defrec
     1542
     1543Default/live records flag. Accepts C<y> and C<n>.
     1544
     1545=item revrec
     1546
     1547Forward/reverse flag. Accepts C<y> and C<n>.  Used for logging to pick the "primary" zone of the record.
     1548
     1549=item id
     1550
     1551The record to delete.
     1552
     1553=back
     1554
     1555=cut
    9301556sub delRec {
    9311557  my %args = @_;
     
    9411567}
    9421568
     1569
     1570=head3 delByCIDR
     1571
     1572Delete a record by CIDR address.
     1573
     1574=over 4
     1575
     1576=item cidr
     1577
     1578The CIDR address for the record or record group to delete.
     1579
     1580=back
     1581
     1582B<Optional arguments>
     1583
     1584=over 4
     1585
     1586=item delforward (default 0/off)
     1587
     1588Delete the matching A record on A+PTR and similar metarecords.
     1589
     1590=item delsubs (default 0/off)
     1591
     1592Delete all records within C<cidr>.  Send C<y> if desired, otherwise it reverts to default even for other
     1593otherwise "true" values.
     1594
     1595=item parpatt
     1596
     1597Template pattern to add a replacement record if the delete removes all records from a reverse zone.
     1598
     1599=back
     1600
     1601=cut
    9431602sub delByCIDR {
    9441603  my %args = @_;
     
    10591718} # end delByCIDR()
    10601719
     1720
     1721=head3 delRevSet
     1722
     1723Delete a set of single-IP records similar to updateRevSet
     1724
     1725=over 4
     1726
     1727=item cidrlist
     1728
     1729Simple comma-separated string containing the IP addresses that should be removed.
     1730
     1731=back
     1732
     1733=cut
    10611734# Batch-delete a set of reverse entries similar to updateRevSet
    10621735sub delRevSet {
     
    10771750#sub getLogEntries {}
    10781751
     1752
     1753=head3 getRevPattern
     1754
     1755Get the pattern that would be applied to IPs in a CIDR range that do not have narrower patterns or separate
     1756individual reverse entries.
     1757
     1758=over 4
     1759
     1760=item cidr
     1761
     1762The CIDR address range to find a pattern for.
     1763
     1764=item group
     1765
     1766The group to restrict reverse zone matches to.
     1767
     1768=item location
     1769
     1770The DNS view/location to restrict record matches to.
     1771
     1772=back
     1773
     1774=cut
    10791775sub getRevPattern {
    10801776  my %args = @_;
     
    10851781}
    10861782
     1783
     1784=head3 getRevSet
     1785
     1786Retrieve the set of per-IP reverse records within a CIDR range, if any.
     1787
     1788Returns a list of hashes.
     1789
     1790=over 4
     1791
     1792=item cidr
     1793
     1794The CIDR address range to find a pattern for.
     1795
     1796=item group
     1797
     1798The group to restrict reverse zone matches to.
     1799
     1800=item location
     1801
     1802The DNS view/location to restrict record matches to.
     1803
     1804=back
     1805
     1806=cut
    10871807sub getRevSet {
    10881808  my %args = @_;
     
    10931813}
    10941814
     1815
     1816=head3 getTypelist
     1817
     1818Retrieve a list of record types suitable for a dropdown form field.  Returns only record types currently
     1819supported by DNSAdmin.
     1820
     1821Returns a list of hashes.
     1822
     1823=over 4
     1824
     1825=item recgroup
     1826
     1827Flag argument to determine which record types will be returned.  Values not listed fall back to C<f>.
     1828
     1829=over 4
     1830
     1831=item r
     1832
     1833Logical records commonly found in reverse zones (includes A+PTR and related metatypes)
     1834
     1835=item l
     1836
     1837Records that can actually be looked up in the DNS.
     1838
     1839=item f
     1840
     1841Logical records commonly found in forward zones (includes A+PTR and similar metatypes that include a forward
     1842record component).  Append C<o> to exclude the metatypes.
     1843
     1844=back
     1845
     1846=item selected
     1847
     1848Optional flag argument if a particular type should be "selected".  Sets the C<tselect> key on that entry.  Note
     1849that the passed type will always be present in the returned list, even if it wouldn't be otherwise - eg, PTR
     1850template if C<recgroup> is set to C<fo>, or SRV if C<recgroup> is set to C<r>.
     1851
     1852=back
     1853
     1854=cut
    10951855sub getTypelist {
    10961856  my %args = @_;
     
    11021862}
    11031863
     1864
     1865=head3 getTypemap
     1866
     1867Return DNS record type hash mapping DNS integer type values to text names
     1868
     1869=cut
    11041870sub getTypemap {
    11051871  my %args = @_;
     
    11081874}
    11091875
     1876
     1877=head3 getReverse_typemap
     1878
     1879Return DNS record type hash mapping text names to integer type values
     1880
     1881=cut
    11101882sub getReverse_typemap {
    11111883  my %args = @_;
     
    11171889#sub isParent {}
    11181890
     1891
     1892=head3 zoneStatus
     1893
     1894Get or set the status of a zone.  Returns the status of the zone.
     1895
     1896=over 4
     1897
     1898=item zoneid
     1899
     1900The ID of the zone to get or set status on
     1901
     1902=back
     1903
     1904B<Optional arguments>
     1905
     1906=over 4
     1907
     1908=item reverse
     1909
     1910Set to C<y> if you want to get/set the status for a reverse zone
     1911
     1912=item status
     1913
     1914Pass C<0> or C<domoff> to set the zone to inactive;  C<1> or C<domon> to set it to active
     1915
     1916=back
     1917
     1918=cut
    11191919sub zoneStatus {
    11201920  my %args = @_;
     
    11281928  my $status = $dnsdb->zoneStatus(@arglist);
    11291929}
     1930
     1931
     1932=head3 getZonesByCIDR
     1933
     1934Get a list of reverse zones within a passed CIDR block.  Returns a list of hashes.
     1935
     1936=over 4
     1937
     1938=item cidr
     1939
     1940The CIDR range to look for reverse zones in
     1941
     1942=back
     1943
     1944=cut
    11301945
    11311946# Get a list of hashes referencing the reverse zone(s) for a passed CIDR block
     
    11501965  return \@methods;
    11511966}
     1967
     1968
     1969# and we're done.  close the POD
     1970
     1971#back
Note: See TracChangeset for help on using the changeset viewer.