vagrant-share 0.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ require 'stringio'
2
+
3
+ module VagrantPlugins
4
+ module Share
5
+ # Contains helper methods that the command uses.
6
+ class Helper
7
+ class Api
8
+ @@logger = Log4r::Logger.new("vagrant::plugins::share_api")
9
+
10
+ class Logger
11
+ def initialize(target)
12
+ @target = target
13
+ end
14
+
15
+ def <<(string)
16
+ @target.debug(string.chomp)
17
+ end
18
+ end
19
+
20
+ def self.start_api(machine)
21
+ require "webrick/https"
22
+ begin
23
+ logger = Logger.new(@@logger)
24
+ $stderr = StringIO.new("")
25
+ api = WEBrick::HTTPServer.new(
26
+ AccessLog: [
27
+ [logger, WEBrick::AccessLog::COMMON_LOG_FORMAT]
28
+ ],
29
+ Logger: WEBrick::Log.new(logger),
30
+ Port: 0,
31
+ SSLCertName: [%w(CN vagrant)],
32
+ SSLEnable: true
33
+ )
34
+ ensure
35
+ $stderr = STDERR
36
+ end
37
+ if block_given?
38
+ yield api
39
+ end
40
+ api
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,550 @@
1
+ module VagrantPlugins
2
+ module Share
3
+ # Contains helper methods that the command uses.
4
+ class Helper
5
+ class WordList
6
+ # Word list content
7
+ LIST = {"even"=>
8
+ {"01"=>"roman",
9
+ "02"=>"forward",
10
+ "03"=>"club",
11
+ "04"=>"static",
12
+ "05"=>"sample",
13
+ "06"=>"opera",
14
+ "07"=>"polygon",
15
+ "08"=>"transit",
16
+ "09"=>"fidel",
17
+ "0A"=>"mixer",
18
+ "0B"=>"jacket",
19
+ "0C"=>"celtic",
20
+ "0D"=>"phone",
21
+ "0E"=>"bambino",
22
+ "0F"=>"igloo",
23
+ "10"=>"door",
24
+ "11"=>"omega",
25
+ "12"=>"basket",
26
+ "13"=>"distant",
27
+ "14"=>"frog",
28
+ "15"=>"leopard",
29
+ "16"=>"smart",
30
+ "17"=>"hilton",
31
+ "18"=>"panel",
32
+ "19"=>"empire",
33
+ "1A"=>"product",
34
+ "1B"=>"enigma",
35
+ "1C"=>"alice",
36
+ "1D"=>"sweet",
37
+ "1E"=>"banjo",
38
+ "1F"=>"golf",
39
+ "20"=>"sphere",
40
+ "21"=>"culture",
41
+ "22"=>"people",
42
+ "23"=>"libra",
43
+ "24"=>"vega",
44
+ "25"=>"dynasty",
45
+ "26"=>"inca",
46
+ "27"=>"modem",
47
+ "28"=>"koala",
48
+ "29"=>"basic",
49
+ "2A"=>"jamaica",
50
+ "2B"=>"yankee",
51
+ "2C"=>"august",
52
+ "2D"=>"crimson",
53
+ "2E"=>"alaska",
54
+ "2F"=>"fabric",
55
+ "30"=>"bazaar",
56
+ "31"=>"compact",
57
+ "32"=>"tractor",
58
+ "33"=>"geneva",
59
+ "34"=>"potato",
60
+ "35"=>"melon",
61
+ "36"=>"novel",
62
+ "37"=>"instant",
63
+ "38"=>"brazil",
64
+ "39"=>"adios",
65
+ "3A"=>"hunter",
66
+ "3B"=>"kilo",
67
+ "3C"=>"everest",
68
+ "3D"=>"pamela",
69
+ "3E"=>"clock",
70
+ "3F"=>"diego",
71
+ "40"=>"caviar",
72
+ "41"=>"melody",
73
+ "42"=>"orange",
74
+ "43"=>"budget",
75
+ "44"=>"motor",
76
+ "45"=>"october",
77
+ "46"=>"object",
78
+ "47"=>"samba",
79
+ "48"=>"regular",
80
+ "49"=>"export",
81
+ "4A"=>"person",
82
+ "4B"=>"energy",
83
+ "4C"=>"demo",
84
+ "4D"=>"angel",
85
+ "4E"=>"printer",
86
+ "4F"=>"savage",
87
+ "50"=>"evening",
88
+ "51"=>"bonus",
89
+ "52"=>"shelter",
90
+ "53"=>"origin",
91
+ "54"=>"logic",
92
+ "55"=>"maximum",
93
+ "56"=>"comedy",
94
+ "57"=>"liquid",
95
+ "58"=>"humor",
96
+ "59"=>"collect",
97
+ "5A"=>"equator",
98
+ "5B"=>"monday",
99
+ "5C"=>"monarch",
100
+ "5D"=>"pony",
101
+ "5E"=>"silk",
102
+ "5F"=>"balloon",
103
+ "60"=>"educate",
104
+ "61"=>"leonid",
105
+ "62"=>"aztec",
106
+ "63"=>"harbor",
107
+ "64"=>"sabrina",
108
+ "65"=>"palace",
109
+ "66"=>"kimono",
110
+ "67"=>"group",
111
+ "68"=>"panther",
112
+ "69"=>"snake",
113
+ "6A"=>"project",
114
+ "6B"=>"cobra",
115
+ "6C"=>"casino",
116
+ "6D"=>"optimal",
117
+ "6E"=>"chess",
118
+ "6F"=>"tempo",
119
+ "70"=>"bikini",
120
+ "71"=>"address",
121
+ "72"=>"toga",
122
+ "73"=>"target",
123
+ "74"=>"depend",
124
+ "75"=>"gong",
125
+ "76"=>"company",
126
+ "77"=>"vanilla",
127
+ "78"=>"isotope",
128
+ "79"=>"tornado",
129
+ "7A"=>"union",
130
+ "7B"=>"plasma",
131
+ "7C"=>"film",
132
+ "7D"=>"marvin",
133
+ "7E"=>"annual",
134
+ "7F"=>"athena",
135
+ "80"=>"finance",
136
+ "81"=>"escape",
137
+ "82"=>"germany",
138
+ "83"=>"brother",
139
+ "84"=>"fragile",
140
+ "85"=>"patriot",
141
+ "86"=>"camera",
142
+ "87"=>"paradox",
143
+ "88"=>"atomic",
144
+ "89"=>"switch",
145
+ "8A"=>"hamlet",
146
+ "8B"=>"hawaii",
147
+ "8C"=>"consul",
148
+ "8D"=>"lucas",
149
+ "8E"=>"begin",
150
+ "8F"=>"lithium",
151
+ "90"=>"multi",
152
+ "91"=>"fruit",
153
+ "92"=>"jungle",
154
+ "93"=>"ecology",
155
+ "94"=>"solo",
156
+ "95"=>"right",
157
+ "96"=>"little",
158
+ "97"=>"planet",
159
+ "98"=>"vodka",
160
+ "99"=>"cherry",
161
+ "9A"=>"cafe",
162
+ "9B"=>"today",
163
+ "9C"=>"gravity",
164
+ "9D"=>"neptune",
165
+ "9E"=>"import",
166
+ "9F"=>"vitamin",
167
+ "A0"=>"salami",
168
+ "A1"=>"section",
169
+ "A2"=>"percent",
170
+ "A3"=>"forum",
171
+ "A4"=>"ethnic",
172
+ "A5"=>"portal",
173
+ "A6"=>"rainbow",
174
+ "A7"=>"concert",
175
+ "A8"=>"empty",
176
+ "A9"=>"sultan",
177
+ "AA"=>"galileo",
178
+ "AB"=>"mega",
179
+ "AC"=>"elegant",
180
+ "AD"=>"ferrari",
181
+ "AE"=>"tina",
182
+ "AF"=>"rival",
183
+ "B0"=>"galaxy",
184
+ "B1"=>"numeric",
185
+ "B2"=>"member",
186
+ "B3"=>"laser",
187
+ "B4"=>"mars",
188
+ "B5"=>"clean",
189
+ "B6"=>"optic",
190
+ "B7"=>"remote",
191
+ "B8"=>"pretend",
192
+ "B9"=>"hotel",
193
+ "BA"=>"zipper",
194
+ "BB"=>"burma",
195
+ "BC"=>"aroma",
196
+ "BD"=>"soda",
197
+ "BE"=>"stereo",
198
+ "BF"=>"london",
199
+ "C0"=>"crown",
200
+ "C1"=>"aloha",
201
+ "C2"=>"boxer",
202
+ "C3"=>"texas",
203
+ "C4"=>"george",
204
+ "C5"=>"morning",
205
+ "C6"=>"combine",
206
+ "C7"=>"contour",
207
+ "C8"=>"clinic",
208
+ "C9"=>"total",
209
+ "CA"=>"amanda",
210
+ "CB"=>"tahiti",
211
+ "CC"=>"trilogy",
212
+ "CD"=>"marble",
213
+ "CE"=>"chapter",
214
+ "CF"=>"agenda",
215
+ "D0"=>"lima",
216
+ "D1"=>"audio",
217
+ "D2"=>"episode",
218
+ "D3"=>"nobel",
219
+ "D4"=>"mambo",
220
+ "D5"=>"extend",
221
+ "D6"=>"crater",
222
+ "D7"=>"trapeze",
223
+ "D8"=>"magnet",
224
+ "D9"=>"graph",
225
+ "DA"=>"pupil",
226
+ "DB"=>"lady",
227
+ "DC"=>"canvas",
228
+ "DD"=>"nominal",
229
+ "DE"=>"blitz",
230
+ "DF"=>"eclipse",
231
+ "E0"=>"lemon",
232
+ "E1"=>"trick",
233
+ "E2"=>"vatican",
234
+ "E3"=>"delta",
235
+ "E4"=>"venus",
236
+ "E5"=>"young",
237
+ "E6"=>"opinion",
238
+ "E7"=>"studio",
239
+ "E8"=>"western",
240
+ "E9"=>"salary",
241
+ "EA"=>"senator",
242
+ "EB"=>"william",
243
+ "EC"=>"diet",
244
+ "ED"=>"abraham",
245
+ "EE"=>"package",
246
+ "EF"=>"aspect",
247
+ "F0"=>"fiction",
248
+ "F1"=>"santana",
249
+ "F2"=>"cairo",
250
+ "F3"=>"bishop",
251
+ "F4"=>"shrink",
252
+ "F5"=>"garage",
253
+ "F6"=>"korea",
254
+ "F7"=>"binary",
255
+ "F8"=>"jasmine",
256
+ "F9"=>"sigma",
257
+ "FA"=>"dollar",
258
+ "FB"=>"control",
259
+ "FC"=>"france",
260
+ "FD"=>"organic",
261
+ "FE"=>"system",
262
+ "FF"=>"water"},
263
+ "odd"=>
264
+ {"01"=>"amigo",
265
+ "02"=>"album",
266
+ "03"=>"deluxe",
267
+ "04"=>"grille",
268
+ "05"=>"alarm",
269
+ "06"=>"design",
270
+ "07"=>"cable",
271
+ "08"=>"avenue",
272
+ "09"=>"spring",
273
+ "0A"=>"jargon",
274
+ "0B"=>"tokyo",
275
+ "0C"=>"analog",
276
+ "0D"=>"madonna",
277
+ "0E"=>"liberal",
278
+ "0F"=>"python",
279
+ "10"=>"bernard",
280
+ "11"=>"prepare",
281
+ "12"=>"sulfur",
282
+ "13"=>"sahara",
283
+ "14"=>"kitchen",
284
+ "15"=>"denver",
285
+ "16"=>"develop",
286
+ "17"=>"history",
287
+ "18"=>"john",
288
+ "19"=>"viking",
289
+ "1A"=>"soviet",
290
+ "1B"=>"social",
291
+ "1C"=>"madrid",
292
+ "1D"=>"guitar",
293
+ "1E"=>"medical",
294
+ "1F"=>"alex",
295
+ "20"=>"axiom",
296
+ "21"=>"gamma",
297
+ "22"=>"mile",
298
+ "23"=>"diana",
299
+ "24"=>"zero",
300
+ "25"=>"crash",
301
+ "26"=>"rose",
302
+ "27"=>"saturn",
303
+ "28"=>"machine",
304
+ "29"=>"script",
305
+ "2A"=>"inch",
306
+ "2B"=>"oregano",
307
+ "2C"=>"tropic",
308
+ "2D"=>"helena",
309
+ "2E"=>"gemini",
310
+ "2F"=>"museum",
311
+ "30"=>"ramirez",
312
+ "31"=>"ninja",
313
+ "32"=>"laptop",
314
+ "33"=>"change",
315
+ "34"=>"declare",
316
+ "35"=>"effect",
317
+ "36"=>"asia",
318
+ "37"=>"radar",
319
+ "38"=>"lucky",
320
+ "39"=>"spain",
321
+ "3A"=>"modern",
322
+ "3B"=>"pump",
323
+ "3C"=>"fresh",
324
+ "3D"=>"secret",
325
+ "3E"=>"limbo",
326
+ "3F"=>"maxwell",
327
+ "40"=>"coral",
328
+ "41"=>"method",
329
+ "42"=>"public",
330
+ "43"=>"tommy",
331
+ "44"=>"carbon",
332
+ "45"=>"courage",
333
+ "46"=>"telex",
334
+ "47"=>"david",
335
+ "48"=>"vincent",
336
+ "49"=>"famous",
337
+ "4A"=>"resume",
338
+ "4B"=>"miami",
339
+ "4C"=>"filter",
340
+ "4D"=>"heroic",
341
+ "4E"=>"model",
342
+ "4F"=>"process",
343
+ "50"=>"summer",
344
+ "51"=>"vampire",
345
+ "52"=>"indigo",
346
+ "53"=>"driver",
347
+ "54"=>"extreme",
348
+ "55"=>"meteor",
349
+ "56"=>"eternal",
350
+ "57"=>"italian",
351
+ "58"=>"orlando",
352
+ "59"=>"parker",
353
+ "5A"=>"dolphin",
354
+ "5B"=>"almond",
355
+ "5C"=>"chicken",
356
+ "5D"=>"ceramic",
357
+ "5E"=>"neutral",
358
+ "5F"=>"video",
359
+ "60"=>"carpet",
360
+ "61"=>"master",
361
+ "62"=>"loyal",
362
+ "63"=>"liter",
363
+ "64"=>"music",
364
+ "65"=>"camel",
365
+ "66"=>"memo",
366
+ "67"=>"jeep",
367
+ "68"=>"austria",
368
+ "69"=>"norway",
369
+ "6A"=>"morgan",
370
+ "6B"=>"kermit",
371
+ "6C"=>"bottle",
372
+ "6D"=>"partner",
373
+ "6E"=>"imagine",
374
+ "6F"=>"chef",
375
+ "70"=>"meter",
376
+ "71"=>"lexicon",
377
+ "72"=>"risk",
378
+ "73"=>"event",
379
+ "74"=>"mozart",
380
+ "75"=>"turbo",
381
+ "76"=>"corona",
382
+ "77"=>"select",
383
+ "78"=>"insect",
384
+ "79"=>"granite",
385
+ "7A"=>"reptile",
386
+ "7B"=>"status",
387
+ "7C"=>"style",
388
+ "7D"=>"carmen",
389
+ "7E"=>"network",
390
+ "7F"=>"nevada",
391
+ "80"=>"figure",
392
+ "81"=>"panda",
393
+ "82"=>"biscuit",
394
+ "83"=>"message",
395
+ "84"=>"wizard",
396
+ "85"=>"mirage",
397
+ "86"=>"police",
398
+ "87"=>"immune",
399
+ "88"=>"brain",
400
+ "89"=>"mentor",
401
+ "8A"=>"complex",
402
+ "8B"=>"desert",
403
+ "8C"=>"citizen",
404
+ "8D"=>"house",
405
+ "8E"=>"uncle",
406
+ "8F"=>"cuba",
407
+ "90"=>"exhibit",
408
+ "91"=>"cartoon",
409
+ "92"=>"alamo",
410
+ "93"=>"algebra",
411
+ "94"=>"express",
412
+ "95"=>"wolf",
413
+ "96"=>"nothing",
414
+ "97"=>"quiet",
415
+ "98"=>"prosper",
416
+ "99"=>"simple",
417
+ "9A"=>"poetic",
418
+ "9B"=>"sector",
419
+ "9C"=>"blonde",
420
+ "9D"=>"sport",
421
+ "9E"=>"titanic",
422
+ "9F"=>"agent",
423
+ "A0"=>"extra",
424
+ "A1"=>"email",
425
+ "A2"=>"candle",
426
+ "A3"=>"sensor",
427
+ "A4"=>"gorilla",
428
+ "A5"=>"mimic",
429
+ "A6"=>"bronze",
430
+ "A7"=>"sharp",
431
+ "A8"=>"climax",
432
+ "A9"=>"pasta",
433
+ "AA"=>"storm",
434
+ "AB"=>"perfect",
435
+ "AC"=>"cecilia",
436
+ "AD"=>"prize",
437
+ "AE"=>"popcorn",
438
+ "AF"=>"horizon",
439
+ "B0"=>"oxygen",
440
+ "B1"=>"helium",
441
+ "B2"=>"virtual",
442
+ "B3"=>"salmon",
443
+ "B4"=>"tower",
444
+ "B5"=>"protect",
445
+ "B6"=>"baker",
446
+ "B7"=>"roger",
447
+ "B8"=>"tripod",
448
+ "B9"=>"theory",
449
+ "BA"=>"period",
450
+ "BB"=>"crystal",
451
+ "BC"=>"genesis",
452
+ "BD"=>"nina",
453
+ "BE"=>"olivia",
454
+ "BF"=>"dialog",
455
+ "C0"=>"ralph",
456
+ "C1"=>"america",
457
+ "C2"=>"mary",
458
+ "C3"=>"option",
459
+ "C4"=>"english",
460
+ "C5"=>"food",
461
+ "C6"=>"lobby",
462
+ "C7"=>"iceberg",
463
+ "C8"=>"shock",
464
+ "C9"=>"tunnel",
465
+ "CA"=>"kayak",
466
+ "CB"=>"oxford",
467
+ "CC"=>"paper",
468
+ "CD"=>"deliver",
469
+ "CE"=>"jumbo",
470
+ "CF"=>"friend",
471
+ "D0"=>"hello",
472
+ "D1"=>"british",
473
+ "D2"=>"recycle",
474
+ "D3"=>"java",
475
+ "D4"=>"gossip",
476
+ "D5"=>"riviera",
477
+ "D6"=>"record",
478
+ "D7"=>"price",
479
+ "D8"=>"artist",
480
+ "D9"=>"reply",
481
+ "DA"=>"lobster",
482
+ "DB"=>"trident",
483
+ "DC"=>"yoyo",
484
+ "DD"=>"impact",
485
+ "DE"=>"textile",
486
+ "DF"=>"coconut",
487
+ "E0"=>"junior",
488
+ "E1"=>"rondo",
489
+ "E2"=>"robert",
490
+ "E3"=>"bermuda",
491
+ "E4"=>"silence",
492
+ "E5"=>"million",
493
+ "E6"=>"media",
494
+ "E7"=>"factor",
495
+ "E8"=>"freedom",
496
+ "E9"=>"echo",
497
+ "EA"=>"taxi",
498
+ "EB"=>"botanic",
499
+ "EC"=>"native",
500
+ "ED"=>"limit",
501
+ "EE"=>"queen",
502
+ "EF"=>"salon",
503
+ "F0"=>"human",
504
+ "F1"=>"patrol",
505
+ "F2"=>"juliet",
506
+ "F3"=>"elvis",
507
+ "F4"=>"square",
508
+ "F5"=>"montana",
509
+ "F6"=>"school",
510
+ "F7"=>"harvest",
511
+ "F8"=>"iris",
512
+ "F9"=>"oasis",
513
+ "FA"=>"good",
514
+ "FB"=>"suzuki",
515
+ "FC"=>"tuna",
516
+ "FD"=>"strong",
517
+ "FE"=>"vocal",
518
+ "FF"=>"pigment"}}
519
+
520
+ # Encode given number to words
521
+ #
522
+ # @param [Integer] number
523
+ # @return [Array<String>]
524
+ def self.encode(number)
525
+ hex = number.to_s(16)
526
+ hex = "0#{hex}" if hex.size % 2 == 1
527
+ result = []
528
+ hex.scan(/.{2}/).each_with_index do |value, idx|
529
+ key = idx % 2 == 1 ? "odd" : "even"
530
+ result << LIST[key][value.upcase]
531
+ end
532
+ result.compact
533
+ end
534
+
535
+ # Decode given words to number
536
+ #
537
+ # @param [Array<String>] words
538
+ # @return [Integer]
539
+ def self.decode(words)
540
+ result = ""
541
+ words.each_with_index do |word, idx|
542
+ key = idx % 2 == 1 ? "odd" : "even"
543
+ result << LIST[key].key(word).to_s
544
+ end
545
+ result.to_i(16)
546
+ end
547
+ end
548
+ end
549
+ end
550
+ end