-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_input.go
More file actions
700 lines (612 loc) · 23.2 KB
/
user_input.go
File metadata and controls
700 lines (612 loc) · 23.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
package main
import (
"bufio"
"fmt"
"net"
"os"
"regexp"
"strings"
. "github.com/dirtman/sitepkg"
)
/*****************************************************************************\
This file deals with user input for the Infoblox object(s) to be processed.
A DNS record has a "name" and resource-type specific "data" value, as well
as a "TTL" and a few other "fields". Infoblox WAPI objects have introduced
many additional fields, and sometimes the concept of a name and data pair
does not fit well with Infoblox objects - everything is just a field.
However, this CLI does separate out a "name" and "data" field from the other
fields. While to Infoblox everything is a field, this CLI expects the name
and data fields, if present, to be specified as command line arguments or
in a file. The only exception is Get requests, since these support search
modifiers which can only be expressed via the --fields option, such as in
"--fields name~=.seci.rice.edu".
For Add, Update and Delete requests the user must provide a name/data pair
for each object to be added, updated or deleted. Depending on the object
type and operation, the name or data may be empty. For Get requests, as
mentioned, name/data pairs are optional.
The user specifies the name/data pairs via command line arguments, or via a
file (-f/--file) containing a list of name/data value pairs.
Fields are specified with the -F/--fields option, or in a few cases a
separate option is defined for a specific field, such as --view.
\*****************************************************************************/
const nameDataSep = "/"
const requestTypeCreate = 1
const requestTypeGet = 2
const requestTypeDelete = 3
const requestTypeUpdate = 4
const objectTypeHost = 1
const objectTypeA = 2
const objectTypePTR = 3
const objectTypeCNAME = 4
const objectTypeAlias = 5
const objectTypeFixedAddress = 6
const objectTypeMX = 7
const objectTypeTXT = 8
const objectTypeZoneAuth = 9
const objectTypeAAAA = 10
const viewAny = "any"
const targetAny = "any"
type UserInput struct {
objectType int // Type of object specified by user
operation int // Operation requested by user, such as get or add
ndList []string // The list of name/data pairs provided by the user
maxNameLength int // For prettier print-out formatting later.
view string // --view value
comment string // --comment value
disable string // --disable: handled differently for Add vs Update
ttl uint32 // --ttl value
fields []string // --fields
rFields []string // --rFields, for Get requests
enableDNS string // --enableDNS, for Host
enableDHCP string // --enableDCHP, for Host
mac string // --mac, for Host
bootfile string // --bootfile, for Host
nextserver string // --nextserver, for Host
bootserver string // --bootserver, for Host
ipFields []string // --ipFields, for Host
restartServices bool // --restart_if_needed, for Host
targetType string // --targetType, for Alias and CNAME
txtData map[string]string // original, pre-sanitized TXT data.
}
// Process and store the user arguments that define the objects on which to
// operate. Some requests require both a "name" and a "data" value as input,
// others require one and/or the other, and "get" requests can get by with
// neither, as long as one or more "field" option/value pairs are provided.
// Except for get requests, "duo" determines whether both a name and a data
// value are required.
// In addition to handling user arguments, some commonly used options are
// also handled here.
func getUserInput(objectType, operation string, duo bool, args []string) (*UserInput, error) {
input := new(UserInput)
input.ndList = make([]string, 0)
var err error
if operation == "add" || operation == "create" {
input.operation = requestTypeCreate
} else if operation == "get" || operation == "fetch" {
input.operation = requestTypeGet
} else if operation == "delete" {
input.operation = requestTypeDelete
} else if operation == "update" {
input.operation = requestTypeUpdate
}
if objectType == "host" {
input.objectType = objectTypeHost
} else if objectType == "address" || objectType == "a" {
input.objectType = objectTypeA
} else if objectType == "ptr" {
input.objectType = objectTypePTR
} else if objectType == "cname" {
input.objectType = objectTypeCNAME
} else if objectType == "alias" {
input.objectType = objectTypeAlias
} else if objectType == "fixedaddress" {
input.objectType = objectTypeFixedAddress
} else if objectType == "mx" {
input.objectType = objectTypeMX
} else if objectType == "txt" {
input.objectType = objectTypeTXT
input.txtData = make(map[string]string, 0)
} else if objectType == "authzone" {
input.objectType = objectTypeZoneAuth
} else if objectType == "aaaa" {
input.objectType = objectTypeAAAA
}
if err = GetFieldOptions(input); err != nil {
return nil, Error("failure processing fields options: %v", err)
}
ShowDebug("getUserInput: input.fields: %#v", input.fields)
ShowDebug("getUserInput: input.rFields: %#v", input.rFields)
if filename, _ := GetStringOpt("filename"); filename != "" {
err = getUserInputFromFile(filename, input, duo, args)
} else if len(args) > 0 {
err = getUserInputFromArgs(input, duo, args)
} else if input.operation != requestTypeGet {
err = Error("a name and/or data value is required")
} else if input.fields == nil || len(input.fields) == 0 {
err = Error("no name, data or fields provided")
} else {
input.ndList = append(input.ndList, "/")
}
ShowDebug("getUserInput: input.ndList: %#v", input.ndList)
return input, err
}
// Process the various options that will be part of the WAPI request.
// Most operations support a --fields option, and this string is split
// into a string array and saved as input.fields. Several other
// options, such as --view, are appended to input.fields.
func GetFieldOptions(input *UserInput) error {
var ttl uint
var err error
// Each operation except Delete has a field option.
if input.operation != requestTypeDelete {
if fields, _ := GetStringOpt("fields"); fields != "" {
input.fields = strings.Split(fields, ",")
}
}
// We are transitioning to multiple views, and it seems it will be safer
// to always require the view to be specified. May need to change this...
// Note the view of an object cannot be updated. For Update, the view
// option specifies the object to be updated, not a field to be updated.
if input.view, _ = GetStringOpt("view"); input.view == "" {
return Error("the \"view\" option cannot be empty")
} else if (!(input.view == viewAny && input.operation == requestTypeGet)) &&
input.operation != requestTypeUpdate {
if input.objectType == objectTypeFixedAddress {
input.fields = append(input.fields, "network_view="+input.view)
} else {
input.fields = append(input.fields, "view="+input.view)
}
}
// A "target_type" is required for Alias records. Note that for Update, the
// target_type specifies the object to be updated, not a field to be updated.
if input.objectType == objectTypeAlias {
if input.targetType, _ = GetStringOpt("targetType"); input.targetType == "" {
return Error("the \"targetType\" option cannot be empty")
} else if (!(input.targetType == targetAny && input.operation == requestTypeGet)) &&
input.operation != requestTypeUpdate {
input.fields = append(input.fields, "target_type="+input.targetType)
}
}
// A host record has a "restart_if_needed" field, and host add, update and
// delete have the --resetartService option to reflect this. But note this
// field is not searchable; my guess is that it is not saved with the host
// record object, but is more of a one-time flag. We'll see...
if (input.objectType == objectTypeHost ||
input.objectType == objectTypeFixedAddress ||
input.objectType == objectTypeZoneAuth) &&
input.operation != requestTypeGet {
input.restartServices, _ = GetBoolOpt("restartServices")
}
// For Deletes we're done.
if input.operation == requestTypeDelete {
return nil
}
// Get supports a return fields option.
if input.operation == requestTypeGet {
if rFields, _ := GetStringOpt("rFields"); rFields != "" {
input.rFields = strings.Split(rFields, ",")
}
// The API will not return the TTL field if its value is inherited.
// While not very helpful, let's return the "use_ttl" field if the
// ttl field is specified; this flag indicates that ttl is inherited.
if inList, _ := InList(input.rFields, "ttl"); inList {
if inList, _ := InList(input.rFields, "use_ttl"); !inList {
input.rFields = append(input.rFields, "use_ttl")
}
}
// Let's force the "disable" fields, since we may want to let
// the user know if the fetched record is disabled or not.
if inList, _ := InList(input.rFields, "disable"); !inList {
input.rFields = append(input.rFields, "disable")
}
// Get MX supports an mx and preference fields.
if input.objectType == objectTypeMX {
var mx, preference string
if mx, err = GetStringOpt("mx"); err != nil {
return Error("failure getting MX option: %v", err)
} else if preference, err = GetStringOpt("preference"); err != nil {
return Error("failure getting preference option: %v", err)
}
if mx != "" {
input.fields = append(input.fields, "mail_exchanger="+mx)
}
if preference != "" {
input.fields = append(input.fields, "preference="+preference)
}
}
// Get TXT supports a txt field.
if input.objectType == objectTypeTXT {
var txt string
if txt, err = GetStringOpt("txt"); err != nil {
return Error("failure getting TXT option: %v", err)
}
if txt != "" {
input.fields = append(input.fields, "text="+sanitizeRecordData(txt))
}
}
}
// Handle the comment option.
if input.comment, _ = GetStringOpt("comment"); input.comment != "" {
// Replace each space with its hex code (%20).
comment := strings.ReplaceAll(input.comment, " ", "%20")
input.fields = append(input.fields, "comment="+comment)
}
// The infoblox-go-client package defines a TTL as a uint32.
if ttl, err = GetUintOpt("ttl"); err != nil &&
!strings.Contains(err.Error(), ConfErrNoSuchOption) {
return Error("failure parsing ttl option: %v", err)
} else if ttl != 0 {
input.ttl = uint32(ttl)
input.fields = append(input.fields, "ttl="+fmt.Sprintf("%d", int(ttl)))
}
// The disable option is type boolean for Add, but type string for Update.
if input.disable, err = getStringBool("disable", "", input, &input.fields); err != nil {
return Error("%v", err)
}
// ipFields is only for host records.
if input.objectType == objectTypeHost {
if ipFields, _ := GetStringOpt("ipFields"); ipFields != "" {
input.ipFields = strings.Split(ipFields, ",")
}
}
// The rest only applies to host and fixedaddress records
if input.objectType != objectTypeHost && input.objectType != objectTypeFixedAddress {
return nil
}
// Handle the mac option.
if input.mac, _ = GetStringOpt("mac"); input.mac != "" {
if input.objectType == objectTypeHost {
input.ipFields = append(input.ipFields, "mac="+input.mac)
} else if input.operation != requestTypeCreate {
input.fields = append(input.fields, "mac="+input.mac)
}
}
// Handle the bootfile option.
if input.bootfile, _ = GetStringOpt("bootfile"); input.bootfile != "" {
if input.objectType == objectTypeHost {
input.ipFields = append(input.ipFields, "bootfile="+input.bootfile)
} else {
input.fields = append(input.fields, "bootfile="+input.bootfile)
}
}
// Handle the nextserver option.
if input.nextserver, _ = GetStringOpt("nextserver"); input.nextserver != "" {
if input.objectType == objectTypeHost {
input.ipFields = append(input.ipFields, "nextserver="+input.nextserver)
} else {
input.fields = append(input.fields, "nextserver="+input.nextserver)
}
}
// Handle the bootserver option.
if input.bootserver, _ = GetStringOpt("bootserver"); input.bootserver != "" {
if input.objectType == objectTypeHost {
input.ipFields = append(input.ipFields, "bootserver="+input.bootserver)
} else {
input.fields = append(input.fields, "bootserver="+input.bootserver)
}
}
// The rest only apply to host records
if input.objectType != objectTypeHost {
return nil
}
// enableDNS is type boolean for Add, but type string for Update.
if input.enableDNS, err =
getStringBool("enableDNS", "configure_for_dns", input, &input.fields); err != nil {
return Error("%v", err)
}
// enableDHCP is type boolean for Add, but type string for Update.
if input.enableDHCP, err =
getStringBool("enableDHCP", "configure_for_dhcp", input, &input.ipFields); err != nil {
return Error("%v", err)
}
return nil
}
// The "update" and "add" commands all support the "disable" option. Host records
// additionally support the "configure_for_dns" option, and a Host's address records
// support the "configure_for_dhcp" option. For the add commands, these are defined
// as boolean options, but for the update commands they are string options since 3
// possible values are needed: update to true, update to false, or don't update.
// userOpt is the option presented to the user.
// ibOpt is the corresponding Infoblox setting.
// fields specifies a fields slice to which the option should be added.
func getStringBool(userOpt, ibOpt string, input *UserInput, fields *[]string) (string, error) {
var boolString string
var boolean bool
var err error
// If the Infloblox option name is not provided, it defaults to the user option name.
if ibOpt == "" {
ibOpt = userOpt
}
if input.operation == requestTypeUpdate {
if boolString, _ = GetStringOpt(userOpt); boolString != "" {
if boolean, err = StringToBool(boolString); err != nil {
return "", Error("invalid value \"%s\" for %s option", boolString, userOpt)
} else if boolean {
boolString = "true"
} else {
boolString = "false"
}
}
} else if input.operation == requestTypeCreate {
if boolean, _ = GetBoolOpt(userOpt); boolean {
boolString = "true"
} else {
boolString = "false"
}
}
if boolString != "" && fields != nil {
*fields = append(*fields, ibOpt+"="+boolString)
}
return boolString, nil
}
// Get name/data input from the user's command line arguments.
func getUserInputFromArgs(input *UserInput, duo bool, args []string) error {
var name, data string
var err error
if name, data, err = getND(input, args); err != nil {
return err
} else if duo && (name == "" || data == "") {
return Error("both a name and a data value must be specified")
} else if input.objectType == objectTypeHost && name == "" &&
input.operation != requestTypeGet {
return Error("a name must be specified")
} else if name == "" && data == "" {
return Error("a name and/or a data value must be specified")
}
input.ndList = append(input.ndList, name+nameDataSep+data)
return nil
}
// Get name/data inputs from a user specified input file.
func getUserInputFromFile(filename string, input *UserInput, duo bool, args []string) error {
var name, data string
var file *os.File
var lineNo, fl int
var err error
if len(args) > 0 {
return Error("no arguments allowed when an input file is specified.")
} else if filename == "" {
return Error("bad call: filename not defined")
} else if filename == "-" {
file = os.Stdin
} else {
file, err = os.Open(filename)
if err != nil {
return Error("failure opening file \"%s\": %v", filename, err)
}
defer file.Close()
}
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lineNo++
// Remove leading and trailing spaces and tabs:
line := strings.TrimLeft(scanner.Text(), " \t")
line = strings.TrimRight(line, " \t")
// Skip comment (#) lines:
if strings.HasPrefix(line, "#") {
continue
} else if line == "" {
continue
}
// Shave off a trailing comment (must be separated from option value by at least on space):
comment := regexp.MustCompile("[ \t]+#.*$")
fields := comment.Split(line, 2)
line = fields[0]
space := regexp.MustCompile("[ \t]+")
fields = space.Split(line, -1)
if fl = len(fields); fl == 0 {
return Error("no fields, line %d, file %s", lineNo, filename)
} else if duo && fl != 2 {
return Error("wrong field count (%d), line %d, file %s", fl, lineNo, filename)
} else if name, data, err = getND(input, fields); err != nil {
return Error("failure parsing line %d, file %s: %v", lineNo, filename, err)
} else if input.objectType == objectTypeHost && name == "" &&
input.operation != requestTypeGet {
return Error("name missing, line %d, file %s", lineNo, filename)
}
nameData := name + nameDataSep + data
input.ndList = append(input.ndList, nameData)
if len(nameData) > input.maxNameLength {
input.maxNameLength = len(nameData)
}
}
return nil
}
// getND is used to preprocess input provided by the user via either command line
// arguments or via an input file. Either 1 or 2 arguments must be provided, and
// one is taken as the "name" of the record, and the other is taken to be the
// "data", or content, of the record. Some objects allow the name and data values
// to be in either order, and for these object types getND determines which is
// which. Some objects may require the data to be sanitized.
func getND(input *UserInput, args []string) (string, string, error) {
ShowDebug("getND: args: %#v", args)
var name, data string
numArgs := len(args)
if numArgs < 1 {
return "", "", Error("no name or data value specified")
} else if numArgs > 2 {
return "", "", Error("extra arguments not allowed (only a single name and/or data value)")
} else if name = args[0]; len(args) == 2 {
data = args[1]
}
if input.objectType == objectTypeHost || input.objectType == objectTypeA ||
input.objectType == objectTypeAAAA {
return getNameIP(args)
}
if input.objectType == objectTypePTR {
return getPtrNameIP(args)
}
if input.objectType == objectTypeFixedAddress {
return getIPMac(args)
}
ShowDebug("getND: name: \"%s\"; data: \"%s\".", name, data)
// Hmmm, trying to get TXT records workings...
if input.objectType == objectTypeTXT {
// Save the original raw data provided by the user.
if data == "" {
input.txtData[name+nameDataSep] = data
} else {
// Sanitize the data provided by the user.
sanitizedData := sanitizeRecordData(data)
input.txtData[name+nameDataSep+sanitizedData] = data
//if input.operation != requestTypeGet {
data = sanitizedData
//}
}
}
return name, data, nil
}
// For old-times sake (i.e., pdns_utils), allow either "name IP" or "IP name".
func getNameIP(args []string) (string, string, error) {
ShowDebug("getNameIP: args: %#v", args)
var name, data string
numArgs := len(args)
arg := args[0]
if net.ParseIP(arg) != nil {
data = arg
} else if validHost(arg) {
name = arg
} else {
return "", "", Error("argument \"%s\" is neither a valid IP or name", arg)
}
if numArgs == 2 {
arg = args[1]
if data == "" {
if net.ParseIP(arg) != nil {
data = arg
} else {
return "", "", Error("neither argument is a valid IP address")
}
} else if validHost(arg) {
name = arg
} else {
return "", "", Error("neither argument is a valid name")
}
}
return name, data, nil
}
// getPtrNameIP converts user input to name/data pairs for PTR records.
//
// For PTR records, map the "name" value not to the record:ptr "name" field as
// sense would dictate, but rather to the Infoblox "ptrdname" field, which is
// the hostname to which an IP points. And map the "data" value to the IP
// address. This is awkward, not mapping "name to name", but for the sole purpose
// of related records checking (--Check option), the name to ptrdname mapping
// benefit outways the awkwardness.
//
// For the IP address ("data" value), allow the user to specify either an
// IP address (ipv4 or ipv6), or a reverse IP string (in-addr.arpa or .ip6.arpa).
// If the user enters an .arpa domain name, map it to either an ipv4 or ipv6.
// Example PTR record fields and values:
// Name: "236.182.42.128.in-addr.arpa" (OR ....4.0.6.2.ip6.arpa)
// PtrdName: "help.rice.edu"
// Ipv4Addr: "128.42.182.236"
// Ipv6Addr: "c00:1234:5678:9abc::21"
// For our "name/data" scenerio:
// name = ptrdname
// data = ipv4addr or ipv6addr (possibly converted from a .arpa domain name)
func getPtrNameIP(args []string) (string, string, error) {
ShowDebug("getPtrNameIP: args: %#v", args)
var name, data, arpaName string
numArgs := len(args)
var err error
arg := args[0]
if net.ParseIP(arg) != nil {
data = arg
} else if validPtrHost(arg) {
data = arg
arpaName = arg
} else if validHost(arg) {
name = arg
} else {
return "", "", Error("argument \"%s\" is neither a valid IP or name", arg)
}
if numArgs == 2 {
arg = args[1]
if data == "" {
if net.ParseIP(arg) != nil {
data = arg
} else if validPtrHost(arg) {
data = arg
arpaName = arg
} else {
return "", "", Error("neither argument is a valid IP address")
}
} else if validHost(arg) {
if name == "" {
name = arg
} else {
return "", "", Error("both arguments are hostnames")
}
} else {
return "", "", Error("neither argument is a valid data")
}
}
// Check if we need to convert an IP address to a PTR data:
if arpaName != "" {
if data, err = arpaToIP(arpaName); err != nil {
return "", "", err
}
} else if data == "168.7.56.2222" {
// Shut up lint warning for now (func not used).
_, _ = ipToPtrHost(data)
}
return name, data, nil
}
func getIPMac(args []string) (string, string, error) {
ShowDebug("getIPMac: args: %#v", args)
var name, data string
numArgs := len(args)
arg := args[0]
if net.ParseIP(arg) != nil {
name = arg
} else if validMac(arg) {
data = arg
} else {
return "", "", Error("argument \"%s\" is neither a valid IP or MAC", arg)
}
if numArgs == 2 {
arg = args[1]
if name == "" {
if net.ParseIP(arg) != nil {
name = arg
} else {
return "", "", Error("neither argument is a valid IP address")
}
} else if validMac(arg) {
data = arg
} else {
return "", "", Error("neither argument is a valid MAC")
}
}
return name, data, nil
}
// Split the name and data parts from the specified nameData pair.
func splitND(nameData string) (string, string, error) {
// Some data fields may contain the nameDataSep; don't split the data.
s := strings.SplitN(nameData, nameDataSep, 2)
if len(s) != 2 {
return "", "", Error("failure getting name/data from \"%s\"", nameData)
}
return s[0], s[1], nil
}
// When checking for conficting PTR records, the name/data pair may need to be
// reversed. For instance, when adding an A record with the --check options,
// a PTR record with the same "data" as the A record "name" must be checked for.
func reverseNDList(ndList []string) ([]string, error) {
var ptrNDList []string
for _, nameData := range ndList {
s := strings.Split(nameData, nameDataSep)
if len(s) != 2 {
return nil, Error("failure getting name/data from \"%s\"", nameData)
}
ptrNDList = append(ptrNDList, s[1] + nameDataSep + s[0])
}
return ptrNDList, nil
}
func reverseND(nameData string) (string, error) {
s := strings.Split(nameData, nameDataSep)
if len(s) != 2 {
return "", Error("failure getting name/data from \"%s\"", nameData)
}
return s[1] + nameDataSep + s[0], nil
}