vagrant-unbundled 2.0.3.0 → 2.0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -10
- data/Gemfile.lock +16 -2
- data/README.md +1 -0
- data/bin/vagrant +1 -1
- data/lib/vagrant/action/builtin/handle_box.rb +1 -1
- data/lib/vagrant/action/general/package.rb +1 -1
- data/lib/vagrant/action.rb +3 -1
- data/lib/vagrant/alias.rb +56 -0
- data/lib/vagrant/bundler.rb +1 -1
- data/lib/vagrant/capability_host.rb +1 -1
- data/lib/vagrant/cli.rb +8 -0
- data/lib/vagrant/config/version_base.rb +1 -1
- data/lib/vagrant/environment.rb +7 -1
- data/lib/vagrant/errors.rb +4 -0
- data/lib/vagrant/host.rb +1 -1
- data/lib/vagrant/machine.rb +1 -1
- data/lib/vagrant/machine_index.rb +1 -1
- data/lib/vagrant/plugin/v1/guest.rb +1 -1
- data/lib/vagrant/plugin/v1/host.rb +1 -1
- data/lib/vagrant/plugin/v1/plugin.rb +1 -1
- data/lib/vagrant/plugin/v1/provider.rb +1 -1
- data/lib/vagrant/plugin/v2/guest.rb +1 -1
- data/lib/vagrant/plugin/v2/host.rb +1 -1
- data/lib/vagrant/plugin/v2/plugin.rb +1 -1
- data/lib/vagrant/plugin/v2/provider.rb +1 -1
- data/lib/vagrant/shared_helpers.rb +30 -9
- data/lib/vagrant/util/checkpoint_client.rb +8 -0
- data/lib/vagrant/util/downloader.rb +1 -1
- data/lib/vagrant/util/platform.rb +11 -3
- data/lib/vagrant/util/powershell.rb +17 -1
- data/lib/vagrant/util/safe_exec.rb +1 -1
- data/lib/vagrant/util/ssh.rb +4 -1
- data/lib/vagrant/util/stacked_proc_runner.rb +1 -1
- data/lib/vagrant/util/template_renderer.rb +2 -2
- data/lib/vagrant/vagrantfile.rb +1 -1
- data/lib/vagrant.rb +8 -0
- data/plugins/commands/plugin/gem_helper.rb +1 -1
- data/plugins/commands/powershell/command.rb +2 -2
- data/plugins/commands/powershell/scripts/enable_psremoting.ps1 +1 -1
- data/plugins/communicators/ssh/communicator.rb +10 -1
- data/plugins/communicators/winrm/command_filters/mkdir.rb +4 -2
- data/plugins/communicators/winrm/command_filters/rm.rb +5 -3
- data/plugins/communicators/winrm/command_filters/test.rb +3 -1
- data/plugins/communicators/winrm/command_filters/which.rb +4 -2
- data/plugins/communicators/winrm/communicator.rb +3 -3
- data/plugins/guests/amazon/cap/flavor.rb +1 -1
- data/plugins/guests/coreos/cap/configure_networks.rb +1 -1
- data/plugins/guests/coreos/guest.rb +1 -1
- data/plugins/guests/debian/cap/configure_networks.rb +1 -1
- data/plugins/guests/freebsd/cap/configure_networks.rb +1 -1
- data/plugins/guests/photon/guest.rb +1 -1
- data/plugins/guests/windows/cap/change_host_name.rb +6 -1
- data/plugins/guests/windows/cap/mount_shared_folder.rb +1 -1
- data/plugins/hosts/alt/plugin.rb +1 -1
- data/plugins/hosts/arch/plugin.rb +1 -1
- data/plugins/hosts/gentoo/plugin.rb +1 -1
- data/plugins/hosts/linux/plugin.rb +1 -1
- data/plugins/hosts/redhat/plugin.rb +1 -1
- data/plugins/hosts/slackware/plugin.rb +2 -2
- data/plugins/kernel_v2/config/push.rb +1 -1
- data/plugins/kernel_v2/config/vm.rb +1 -1
- data/plugins/providers/docker/action/compare_synced_folders.rb +1 -1
- data/plugins/providers/virtualbox/action/network.rb +9 -5
- data/plugins/providers/virtualbox/action/network_fix_ipv6.rb +1 -1
- data/plugins/provisioners/chef/config/chef_zero.rb +1 -1
- data/plugins/provisioners/chef/provisioner/chef_solo.rb +2 -2
- data/plugins/provisioners/chef/provisioner/chef_zero.rb +3 -3
- data/plugins/provisioners/puppet/config/puppet.rb +2 -0
- data/plugins/provisioners/puppet/provisioner/puppet.rb +18 -1
- data/plugins/provisioners/salt/config.rb +6 -0
- data/plugins/provisioners/salt/provisioner.rb +11 -1
- data/templates/locales/command_ps.yml +1 -1
- data/templates/locales/en.yml +13 -4
- data/templates/locales/guest_windows.yml +1 -1
- data/templates/locales/providers_docker.yml +1 -1
- data/templates/locales/synced_folder_smb.yml +2 -2
- data/vagrant.gemspec +2 -0
- data/vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-spec-f3daedaac493/vagrant-spec.gemspec +1 -1
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/.document +5 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/.gitignore +17 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/.travis.yml +21 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/CHANGELOG.md +209 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/Gemfile +4 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/LICENSE.txt +78 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/README.md +67 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/Rakefile +88 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/data/public_suffix_list.dat +12440 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/domain_name.gemspec +36 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/etld_data.rb +8474 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/etld_data.rb.erb +11 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/punycode.rb +283 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name/version.rb +3 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/lib/domain_name.rb +297 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/test/helper.rb +17 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/test/test_domain_name-punycode.rb +97 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/test/test_domain_name.rb +317 -0
- data/vendor/bundle/ruby/2.5.0/gems/domain_name-0.5.20180417/tool/gen_etld_data.rb +63 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/CHANGES +13 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/LICENSE +201 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/MANIFEST +9 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/README +48 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/Rakefile +42 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/certs/djberg96_pub.pem +21 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/ffi-win32-extensions.gemspec +25 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/lib/ffi/win32/extensions.rb +96 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/lib/ffi-win32-extensions.rb +1 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/test/test_ffi_extensions.rb +41 -0
- data/vendor/bundle/ruby/2.5.0/gems/ffi-win32-extensions-1.0.3/test/test_string_extensions.rb +20 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/CHANGES +235 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/MANIFEST +16 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/README +73 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/Rakefile +49 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/appveyor.yml +50 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/certs/djberg96_pub.pem +21 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file/constants.rb +33 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file/functions.rb +42 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file/structs.rb +54 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32/file.rb +585 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/lib/win32-file.rb +1 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_link.rb +141 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_misc.rb +16 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_path.rb +282 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/test/test_win32_file_stat.rb +330 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-0.8.1/win32-file.gemspec +33 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/CHANGES +63 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/MANIFEST +18 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/README +47 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/Rakefile +66 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/appveyor.yml +53 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/certs/djberg96_pub.pem +21 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security/constants.rb +149 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security/functions.rb +63 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security/structs.rb +68 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32/file/security.rb +963 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/lib/win32-file-security.rb +1 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_acls.rb +34 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_constants.rb +54 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_encryption.rb +90 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_ffi.rb +33 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_ownership.rb +174 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_permissions.rb +88 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/test/test_win32_file_security_version.rb +14 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-security-1.0.10/win32-file-security.gemspec +28 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/CHANGES +169 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/MANIFEST +12 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/README +94 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/Rakefile +28 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/appveyor.yml +48 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/certs/djberg96_pub.pem +21 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/stat.rb +1008 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/windows/constants.rb +94 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/windows/functions.rb +68 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32/file/windows/structs.rb +196 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/lib/win32-file-stat.rb +1 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/test/test_file_stat.rb +677 -0
- data/vendor/bundle/ruby/2.5.0/gems/win32-file-stat-1.5.5/win32-file-stat.gemspec +30 -0
- data/vendor/bundle/ruby/2.5.0/specifications/domain_name-0.5.20180417.gemspec +46 -0
- data/vendor/bundle/ruby/2.5.0/specifications/ffi-win32-extensions-1.0.3.gemspec +38 -0
- data/vendor/bundle/ruby/2.5.0/specifications/win32-file-0.8.1.gemspec +51 -0
- data/vendor/bundle/ruby/2.5.0/specifications/win32-file-security-1.0.10.gemspec +47 -0
- data/vendor/bundle/ruby/2.5.0/specifications/win32-file-stat-1.5.5.gemspec +48 -0
- data/version.txt +1 -1
- metadata +114 -2
@@ -0,0 +1,11 @@
|
|
1
|
+
class DomainName
|
2
|
+
ETLD_DATA_DATE = '<%= etld_data_date.utc.strftime('%Y-%m-%dT%H:%M:%SZ') %>'
|
3
|
+
|
4
|
+
ETLD_DATA = {
|
5
|
+
<% etld_data.each_pair { |key, value| %> <%= key.inspect %> => <%= value.inspect %>,
|
6
|
+
<% } %> }
|
7
|
+
|
8
|
+
def self.etld_data
|
9
|
+
ETLD_DATA
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,283 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# punycode.rb - PunyCode encoder for the Domain Name library
|
4
|
+
#
|
5
|
+
# Copyright (C) 2011-2017 Akinori MUSHA, All rights reserved.
|
6
|
+
#
|
7
|
+
# Ported from puny.c, a part of VeriSign XCode (encode/decode) IDN
|
8
|
+
# Library.
|
9
|
+
#
|
10
|
+
# Copyright (C) 2000-2002 Verisign Inc., All rights reserved.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or
|
13
|
+
# without modification, are permitted provided that the following
|
14
|
+
# conditions are met:
|
15
|
+
#
|
16
|
+
# 1) Redistributions of source code must retain the above copyright
|
17
|
+
# notice, this list of conditions and the following disclaimer.
|
18
|
+
#
|
19
|
+
# 2) Redistributions in binary form must reproduce the above copyright
|
20
|
+
# notice, this list of conditions and the following disclaimer in
|
21
|
+
# the documentation and/or other materials provided with the
|
22
|
+
# distribution.
|
23
|
+
#
|
24
|
+
# 3) Neither the name of the VeriSign Inc. nor the names of its
|
25
|
+
# contributors may be used to endorse or promote products derived
|
26
|
+
# from this software without specific prior written permission.
|
27
|
+
#
|
28
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
29
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
30
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
31
|
+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
32
|
+
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
33
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
34
|
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
35
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
36
|
+
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
37
|
+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
38
|
+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
39
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
40
|
+
#
|
41
|
+
# This software is licensed under the BSD open source license. For more
|
42
|
+
# information visit www.opensource.org.
|
43
|
+
#
|
44
|
+
# Authors:
|
45
|
+
# John Colosi (VeriSign)
|
46
|
+
# Srikanth Veeramachaneni (VeriSign)
|
47
|
+
# Nagesh Chigurupati (Verisign)
|
48
|
+
# Praveen Srinivasan(Verisign)
|
49
|
+
#++
|
50
|
+
|
51
|
+
class DomainName
|
52
|
+
module Punycode
|
53
|
+
BASE = 36
|
54
|
+
TMIN = 1
|
55
|
+
TMAX = 26
|
56
|
+
SKEW = 38
|
57
|
+
DAMP = 700
|
58
|
+
INITIAL_BIAS = 72
|
59
|
+
INITIAL_N = 0x80
|
60
|
+
DELIMITER = '-'.freeze
|
61
|
+
|
62
|
+
MAXINT = (1 << 32) - 1
|
63
|
+
|
64
|
+
LOBASE = BASE - TMIN
|
65
|
+
CUTOFF = LOBASE * TMAX / 2
|
66
|
+
|
67
|
+
RE_NONBASIC = /[^\x00-\x7f]/
|
68
|
+
|
69
|
+
# Returns the numeric value of a basic code point (for use in
|
70
|
+
# representing integers) in the range 0 to base-1, or nil if cp
|
71
|
+
# is does not represent a value.
|
72
|
+
DECODE_DIGIT = {}.tap { |map|
|
73
|
+
# ASCII A..Z map to 0..25
|
74
|
+
# ASCII a..z map to 0..25
|
75
|
+
(0..25).each { |i| map[65 + i] = map[97 + i] = i }
|
76
|
+
# ASCII 0..9 map to 26..35
|
77
|
+
(26..35).each { |i| map[22 + i] = i }
|
78
|
+
}
|
79
|
+
|
80
|
+
# Returns the basic code point whose value (when used for
|
81
|
+
# representing integers) is d, which must be in the range 0 to
|
82
|
+
# BASE-1. The lowercase form is used unless flag is true, in
|
83
|
+
# which case the uppercase form is used. The behavior is
|
84
|
+
# undefined if flag is nonzero and digit d has no uppercase
|
85
|
+
# form.
|
86
|
+
ENCODE_DIGIT = proc { |d, flag|
|
87
|
+
(d + 22 + (d < 26 ? 75 : 0) - (flag ? (1 << 5) : 0)).chr
|
88
|
+
# 0..25 map to ASCII a..z or A..Z
|
89
|
+
# 26..35 map to ASCII 0..9
|
90
|
+
}
|
91
|
+
|
92
|
+
DOT = '.'.freeze
|
93
|
+
PREFIX = 'xn--'.freeze
|
94
|
+
|
95
|
+
# Most errors we raise are basically kind of ArgumentError.
|
96
|
+
class ArgumentError < ::ArgumentError; end
|
97
|
+
class BufferOverflowError < ArgumentError; end
|
98
|
+
|
99
|
+
class << self
|
100
|
+
# Encode a +string+ in Punycode
|
101
|
+
def encode(string)
|
102
|
+
input = string.unpack('U*')
|
103
|
+
output = ''
|
104
|
+
|
105
|
+
# Initialize the state
|
106
|
+
n = INITIAL_N
|
107
|
+
delta = 0
|
108
|
+
bias = INITIAL_BIAS
|
109
|
+
|
110
|
+
# Handle the basic code points
|
111
|
+
input.each { |cp| output << cp.chr if cp < 0x80 }
|
112
|
+
|
113
|
+
h = b = output.length
|
114
|
+
|
115
|
+
# h is the number of code points that have been handled, b is the
|
116
|
+
# number of basic code points, and out is the number of characters
|
117
|
+
# that have been output.
|
118
|
+
|
119
|
+
output << DELIMITER if b > 0
|
120
|
+
|
121
|
+
# Main encoding loop
|
122
|
+
|
123
|
+
while h < input.length
|
124
|
+
# All non-basic code points < n have been handled already. Find
|
125
|
+
# the next larger one
|
126
|
+
|
127
|
+
m = MAXINT
|
128
|
+
input.each { |cp|
|
129
|
+
m = cp if (n...m) === cp
|
130
|
+
}
|
131
|
+
|
132
|
+
# Increase delta enough to advance the decoder's <n,i> state to
|
133
|
+
# <m,0>, but guard against overflow
|
134
|
+
|
135
|
+
delta += (m - n) * (h + 1)
|
136
|
+
raise BufferOverflowError if delta > MAXINT
|
137
|
+
n = m
|
138
|
+
|
139
|
+
input.each { |cp|
|
140
|
+
# AMC-ACE-Z can use this simplified version instead
|
141
|
+
if cp < n
|
142
|
+
delta += 1
|
143
|
+
raise BufferOverflowError if delta > MAXINT
|
144
|
+
elsif cp == n
|
145
|
+
# Represent delta as a generalized variable-length integer
|
146
|
+
q = delta
|
147
|
+
k = BASE
|
148
|
+
loop {
|
149
|
+
t = k <= bias ? TMIN : k - bias >= TMAX ? TMAX : k - bias
|
150
|
+
break if q < t
|
151
|
+
q, r = (q - t).divmod(BASE - t)
|
152
|
+
output << ENCODE_DIGIT[t + r, false]
|
153
|
+
k += BASE
|
154
|
+
}
|
155
|
+
|
156
|
+
output << ENCODE_DIGIT[q, false]
|
157
|
+
|
158
|
+
# Adapt the bias
|
159
|
+
delta = h == b ? delta / DAMP : delta >> 1
|
160
|
+
delta += delta / (h + 1)
|
161
|
+
bias = 0
|
162
|
+
while delta > CUTOFF
|
163
|
+
delta /= LOBASE
|
164
|
+
bias += BASE
|
165
|
+
end
|
166
|
+
bias += (LOBASE + 1) * delta / (delta + SKEW)
|
167
|
+
|
168
|
+
delta = 0
|
169
|
+
h += 1
|
170
|
+
end
|
171
|
+
}
|
172
|
+
|
173
|
+
delta += 1
|
174
|
+
n += 1
|
175
|
+
end
|
176
|
+
|
177
|
+
output
|
178
|
+
end
|
179
|
+
|
180
|
+
# Encode a hostname using IDN/Punycode algorithms
|
181
|
+
def encode_hostname(hostname)
|
182
|
+
hostname.match(RE_NONBASIC) or return hostname
|
183
|
+
|
184
|
+
hostname.split(DOT).map { |name|
|
185
|
+
if name.match(RE_NONBASIC)
|
186
|
+
PREFIX + encode(name)
|
187
|
+
else
|
188
|
+
name
|
189
|
+
end
|
190
|
+
}.join(DOT)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Decode a +string+ encoded in Punycode
|
194
|
+
def decode(string)
|
195
|
+
# Initialize the state
|
196
|
+
n = INITIAL_N
|
197
|
+
i = 0
|
198
|
+
bias = INITIAL_BIAS
|
199
|
+
|
200
|
+
if j = string.rindex(DELIMITER)
|
201
|
+
b = string[0...j]
|
202
|
+
|
203
|
+
b.match(RE_NONBASIC) and
|
204
|
+
raise ArgumentError, "Illegal character is found in basic part: #{string.inspect}"
|
205
|
+
|
206
|
+
# Handle the basic code points
|
207
|
+
|
208
|
+
output = b.unpack('U*')
|
209
|
+
u = string[(j + 1)..-1]
|
210
|
+
else
|
211
|
+
output = []
|
212
|
+
u = string
|
213
|
+
end
|
214
|
+
|
215
|
+
# Main decoding loop: Start just after the last delimiter if any
|
216
|
+
# basic code points were copied; start at the beginning
|
217
|
+
# otherwise.
|
218
|
+
|
219
|
+
input = u.unpack('C*')
|
220
|
+
input_length = input.length
|
221
|
+
h = 0
|
222
|
+
out = output.length
|
223
|
+
|
224
|
+
while h < input_length
|
225
|
+
# Decode a generalized variable-length integer into delta,
|
226
|
+
# which gets added to i. The overflow checking is easier
|
227
|
+
# if we increase i as we go, then subtract off its starting
|
228
|
+
# value at the end to obtain delta.
|
229
|
+
|
230
|
+
oldi = i
|
231
|
+
w = 1
|
232
|
+
k = BASE
|
233
|
+
|
234
|
+
loop {
|
235
|
+
digit = DECODE_DIGIT[input[h]] or
|
236
|
+
raise ArgumentError, "Illegal character is found in non-basic part: #{string.inspect}"
|
237
|
+
h += 1
|
238
|
+
i += digit * w
|
239
|
+
raise BufferOverflowError if i > MAXINT
|
240
|
+
t = k <= bias ? TMIN : k - bias >= TMAX ? TMAX : k - bias
|
241
|
+
break if digit < t
|
242
|
+
w *= BASE - t
|
243
|
+
raise BufferOverflowError if w > MAXINT
|
244
|
+
k += BASE
|
245
|
+
h < input_length or raise ArgumentError, "Malformed input given: #{string.inspect}"
|
246
|
+
}
|
247
|
+
|
248
|
+
# Adapt the bias
|
249
|
+
delta = oldi == 0 ? i / DAMP : (i - oldi) >> 1
|
250
|
+
delta += delta / (out + 1)
|
251
|
+
bias = 0
|
252
|
+
while delta > CUTOFF
|
253
|
+
delta /= LOBASE
|
254
|
+
bias += BASE
|
255
|
+
end
|
256
|
+
bias += (LOBASE + 1) * delta / (delta + SKEW)
|
257
|
+
|
258
|
+
# i was supposed to wrap around from out+1 to 0, incrementing
|
259
|
+
# n each time, so we'll fix that now:
|
260
|
+
|
261
|
+
q, i = i.divmod(out + 1)
|
262
|
+
n += q
|
263
|
+
raise BufferOverflowError if n > MAXINT
|
264
|
+
|
265
|
+
# Insert n at position i of the output:
|
266
|
+
|
267
|
+
output[i, 0] = n
|
268
|
+
|
269
|
+
out += 1
|
270
|
+
i += 1
|
271
|
+
end
|
272
|
+
output.pack('U*')
|
273
|
+
end
|
274
|
+
|
275
|
+
# Decode a hostname using IDN/Punycode algorithms
|
276
|
+
def decode_hostname(hostname)
|
277
|
+
hostname.gsub(/(\A|#{Regexp.quote(DOT)})#{Regexp.quote(PREFIX)}([^#{Regexp.quote(DOT)}]*)/o) {
|
278
|
+
$1 << decode($2)
|
279
|
+
}
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
@@ -0,0 +1,297 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# domain_name.rb - Domain Name manipulation library for Ruby
|
4
|
+
#
|
5
|
+
# Copyright (C) 2011-2017 Akinori MUSHA, All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'domain_name/version'
|
9
|
+
require 'domain_name/punycode'
|
10
|
+
require 'domain_name/etld_data'
|
11
|
+
require 'unf'
|
12
|
+
require 'ipaddr'
|
13
|
+
|
14
|
+
# Represents a domain name ready for extracting its registered domain
|
15
|
+
# and TLD.
|
16
|
+
class DomainName
|
17
|
+
# The full host name normalized, ASCII-ized and downcased using the
|
18
|
+
# Unicode NFC rules and the Punycode algorithm. If initialized with
|
19
|
+
# an IP address, the string representation of the IP address
|
20
|
+
# suitable for opening a connection to.
|
21
|
+
attr_reader :hostname
|
22
|
+
|
23
|
+
# The Unicode representation of the #hostname property.
|
24
|
+
#
|
25
|
+
# :attr_reader: hostname_idn
|
26
|
+
|
27
|
+
# The least "universally original" domain part of this domain name.
|
28
|
+
# For example, "example.co.uk" for "www.sub.example.co.uk". This
|
29
|
+
# may be nil if the hostname does not have one, like when it is an
|
30
|
+
# IP address, an effective TLD or higher itself, or of a
|
31
|
+
# non-canonical domain.
|
32
|
+
attr_reader :domain
|
33
|
+
|
34
|
+
# The Unicode representation of the #domain property.
|
35
|
+
#
|
36
|
+
# :attr_reader: domain_idn
|
37
|
+
|
38
|
+
# The TLD part of this domain name. For example, if the hostname is
|
39
|
+
# "www.sub.example.co.uk", the TLD part is "uk". This property is
|
40
|
+
# nil only if +ipaddr?+ is true. This may be nil if the hostname
|
41
|
+
# does not have one, like when it is an IP address or of a
|
42
|
+
# non-canonical domain.
|
43
|
+
attr_reader :tld
|
44
|
+
|
45
|
+
# The Unicode representation of the #tld property.
|
46
|
+
#
|
47
|
+
# :attr_reader: tld_idn
|
48
|
+
|
49
|
+
# Returns an IPAddr object if this is an IP address.
|
50
|
+
attr_reader :ipaddr
|
51
|
+
|
52
|
+
# Returns true if this is an IP address, such as "192.168.0.1" and
|
53
|
+
# "[::1]".
|
54
|
+
def ipaddr?
|
55
|
+
@ipaddr ? true : false
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns a host name representation suitable for use in the host
|
59
|
+
# name part of a URI. A host name, an IPv4 address, or a IPv6
|
60
|
+
# address enclosed in square brackets.
|
61
|
+
attr_reader :uri_host
|
62
|
+
|
63
|
+
# Returns true if this domain name has a canonical TLD.
|
64
|
+
def canonical_tld?
|
65
|
+
@canonical_tld_p
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns true if this domain name has a canonical registered
|
69
|
+
# domain.
|
70
|
+
def canonical?
|
71
|
+
@canonical_tld_p && (@domain ? true : false)
|
72
|
+
end
|
73
|
+
|
74
|
+
DOT = '.'.freeze # :nodoc:
|
75
|
+
|
76
|
+
# Parses _hostname_ into a DomainName object. An IP address is also
|
77
|
+
# accepted. An IPv6 address may be enclosed in square brackets.
|
78
|
+
def initialize(hostname)
|
79
|
+
hostname.is_a?(String) or
|
80
|
+
(hostname.respond_to?(:to_str) && (hostname = hostname.to_str).is_a?(String)) or
|
81
|
+
raise TypeError, "#{hostname.class} is not a String"
|
82
|
+
if hostname.start_with?(DOT)
|
83
|
+
raise ArgumentError, "domain name must not start with a dot: #{hostname}"
|
84
|
+
end
|
85
|
+
case hostname
|
86
|
+
when /\A([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\z/
|
87
|
+
@ipaddr = IPAddr.new($1)
|
88
|
+
@uri_host = @hostname = @ipaddr.to_s
|
89
|
+
@domain = @tld = nil
|
90
|
+
return
|
91
|
+
when /\A([0-9A-Fa-f:]*:[0-9A-Fa-f:]*:[0-9A-Fa-f:]*)\z/,
|
92
|
+
/\A\[([0-9A-Fa-f:]*:[0-9A-Fa-f:]*:[0-9A-Fa-f:]*)\]\z/
|
93
|
+
@ipaddr = IPAddr.new($1)
|
94
|
+
@hostname = @ipaddr.to_s
|
95
|
+
@uri_host = "[#{@hostname}]"
|
96
|
+
@domain = @tld = nil
|
97
|
+
return
|
98
|
+
end
|
99
|
+
@ipaddr = nil
|
100
|
+
@hostname = DomainName.normalize(hostname)
|
101
|
+
@uri_host = @hostname
|
102
|
+
if last_dot = @hostname.rindex(DOT)
|
103
|
+
@tld = @hostname[(last_dot + 1)..-1]
|
104
|
+
else
|
105
|
+
@tld = @hostname
|
106
|
+
end
|
107
|
+
etld_data = DomainName.etld_data
|
108
|
+
if @canonical_tld_p = etld_data.key?(@tld)
|
109
|
+
subdomain = domain = nil
|
110
|
+
parent = @hostname
|
111
|
+
loop {
|
112
|
+
case etld_data[parent]
|
113
|
+
when 0
|
114
|
+
@domain = domain
|
115
|
+
return
|
116
|
+
when -1
|
117
|
+
@domain = subdomain
|
118
|
+
return
|
119
|
+
when 1
|
120
|
+
@domain = parent
|
121
|
+
return
|
122
|
+
end
|
123
|
+
subdomain = domain
|
124
|
+
domain = parent
|
125
|
+
pos = @hostname.index(DOT, -domain.length) or break
|
126
|
+
parent = @hostname[(pos + 1)..-1]
|
127
|
+
}
|
128
|
+
else
|
129
|
+
# unknown/local TLD
|
130
|
+
if last_dot
|
131
|
+
# fallback - accept cookies down to second level
|
132
|
+
# cf. http://www.dkim-reputation.org/regdom-libs/
|
133
|
+
if penultimate_dot = @hostname.rindex(DOT, last_dot - 1)
|
134
|
+
@domain = @hostname[(penultimate_dot + 1)..-1]
|
135
|
+
else
|
136
|
+
@domain = @hostname
|
137
|
+
end
|
138
|
+
else
|
139
|
+
# no domain part - must be a local hostname
|
140
|
+
@domain = @tld
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Checks if the server represented by this domain is qualified to
|
146
|
+
# send and receive cookies with a domain attribute value of
|
147
|
+
# _domain_. A true value given as the second argument represents
|
148
|
+
# cookies without a domain attribute value, in which case only
|
149
|
+
# hostname equality is checked.
|
150
|
+
def cookie_domain?(domain, host_only = false)
|
151
|
+
# RFC 6265 #5.3
|
152
|
+
# When the user agent "receives a cookie":
|
153
|
+
return self == domain if host_only
|
154
|
+
|
155
|
+
domain = DomainName.new(domain) unless DomainName === domain
|
156
|
+
if ipaddr?
|
157
|
+
# RFC 6265 #5.1.3
|
158
|
+
# Do not perform subdomain matching against IP addresses.
|
159
|
+
@hostname == domain.hostname
|
160
|
+
else
|
161
|
+
# RFC 6265 #4.1.1
|
162
|
+
# Domain-value must be a subdomain.
|
163
|
+
@domain && self <= domain && domain <= @domain ? true : false
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns the superdomain of this domain name.
|
168
|
+
def superdomain
|
169
|
+
return nil if ipaddr?
|
170
|
+
pos = @hostname.index(DOT) or return nil
|
171
|
+
self.class.new(@hostname[(pos + 1)..-1])
|
172
|
+
end
|
173
|
+
|
174
|
+
def ==(other)
|
175
|
+
other = DomainName.new(other) unless DomainName === other
|
176
|
+
other.hostname == @hostname
|
177
|
+
end
|
178
|
+
|
179
|
+
def <=>(other)
|
180
|
+
other = DomainName.new(other) unless DomainName === other
|
181
|
+
othername = other.hostname
|
182
|
+
if othername == @hostname
|
183
|
+
0
|
184
|
+
elsif @hostname.end_with?(othername) && @hostname[-othername.size - 1, 1] == DOT
|
185
|
+
# The other is higher
|
186
|
+
-1
|
187
|
+
elsif othername.end_with?(@hostname) && othername[-@hostname.size - 1, 1] == DOT
|
188
|
+
# The other is lower
|
189
|
+
1
|
190
|
+
else
|
191
|
+
nil
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def <(other)
|
196
|
+
case self <=> other
|
197
|
+
when -1
|
198
|
+
true
|
199
|
+
when nil
|
200
|
+
nil
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def >(other)
|
207
|
+
case self <=> other
|
208
|
+
when 1
|
209
|
+
true
|
210
|
+
when nil
|
211
|
+
nil
|
212
|
+
else
|
213
|
+
false
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def <=(other)
|
218
|
+
case self <=> other
|
219
|
+
when -1, 0
|
220
|
+
true
|
221
|
+
when nil
|
222
|
+
nil
|
223
|
+
else
|
224
|
+
false
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def >=(other)
|
229
|
+
case self <=> other
|
230
|
+
when 1, 0
|
231
|
+
true
|
232
|
+
when nil
|
233
|
+
nil
|
234
|
+
else
|
235
|
+
false
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def to_s
|
240
|
+
@hostname
|
241
|
+
end
|
242
|
+
|
243
|
+
alias to_str to_s
|
244
|
+
|
245
|
+
def hostname_idn
|
246
|
+
@hostname_idn ||=
|
247
|
+
if @ipaddr
|
248
|
+
@hostname
|
249
|
+
else
|
250
|
+
DomainName::Punycode.decode_hostname(@hostname)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
alias idn hostname_idn
|
255
|
+
|
256
|
+
def domain_idn
|
257
|
+
@domain_idn ||=
|
258
|
+
if @ipaddr
|
259
|
+
@domain
|
260
|
+
else
|
261
|
+
DomainName::Punycode.decode_hostname(@domain)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def tld_idn
|
266
|
+
@tld_idn ||=
|
267
|
+
if @ipaddr
|
268
|
+
@tld
|
269
|
+
else
|
270
|
+
DomainName::Punycode.decode_hostname(@tld)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def inspect
|
275
|
+
str = '#<%s:%s' % [self.class.name, @hostname]
|
276
|
+
if @ipaddr
|
277
|
+
str << ' (ipaddr)'
|
278
|
+
else
|
279
|
+
str << ' domain=' << @domain if @domain
|
280
|
+
str << ' tld=' << @tld if @tld
|
281
|
+
end
|
282
|
+
str << '>'
|
283
|
+
end
|
284
|
+
|
285
|
+
class << self
|
286
|
+
# Normalizes a _domain_ using the Punycode algorithm as necessary.
|
287
|
+
# The result will be a downcased, ASCII-only string.
|
288
|
+
def normalize(domain)
|
289
|
+
DomainName::Punycode.encode_hostname(domain.chomp(DOT).to_nfc).downcase
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# Short hand for DomainName.new().
|
295
|
+
def DomainName(hostname)
|
296
|
+
DomainName.new(hostname)
|
297
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'domain_name'
|
15
|
+
|
16
|
+
class Test::Unit::TestCase
|
17
|
+
end
|