blondy-dhcpd 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cff451085750256df70f852e290cc0486a4662e2
4
- data.tar.gz: b04ecbb33b1926fdd552572b1f5b4d4e89114c5e
3
+ metadata.gz: 0d10055ad173749e1acceff547f91df7aa067fa9
4
+ data.tar.gz: 018ce4dddf52290ef5da6926026226a7dafb9cd7
5
5
  SHA512:
6
- metadata.gz: 325c913489b1c2dc5f2030d3f92028b9d0b3336064fba0c0b59e7cacdb814a591fe42bc56dd1f6587ff7b698bfbcb83e3911d029c8d6721c90932668ca1374e2
7
- data.tar.gz: d1b8714e9e7054d4ddb07b20620178701da0190fb49732e83c0c9dd60a598f6428e199d931c87eb3db1bd603d20907d5ddc1093bc85daf11d0ea335e41c022e0
6
+ metadata.gz: d9092ff9bb75108f2227559a946329b399cb7adc0122ac4e2638c90d896b5c7b7eefde2e180ce71f92032ccc8a90e38600d0144a2cb3e4071f4f3afbb170408d
7
+ data.tar.gz: 7d5738e5ef1a8d25b4b67eae8c8003a3c980951ad78e540d4858ee7774deb6eac414270f6a3d07d551939e238e6df769c89772b899da2b4f83112d169aa7b9c1
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/blondy-dhcpd.png)](http://badge.fury.io/rb/net-dhcp) [![Build Status](https://travis-ci.org/presto53/blondy-dhcpd.png)](https://travis-ci.org/presto53/blondy-dhcpd) [![Code Climate](https://codeclimate.com/repos/52eb8ff6e30ba06ec2002a03/badges/132cfa29229385341bee/gpa.png)](https://codeclimate.com/repos/52eb8ff6e30ba06ec2002a03/feed)
1
+ [![Gem Version](https://badge.fury.io/rb/blondy-dhcpd.png)](http://badge.fury.io/rb/blondy-dhcpd) [![Build Status](https://travis-ci.org/presto53/blondy-dhcpd.png)](https://travis-ci.org/presto53/blondy-dhcpd) [![Code Climate](https://codeclimate.com/repos/52eb8ff6e30ba06ec2002a03/badges/132cfa29229385341bee/gpa.png)](https://codeclimate.com/repos/52eb8ff6e30ba06ec2002a03/feed)
2
2
 
3
3
  blondy-dhcpd
4
4
  ============
@@ -55,8 +55,8 @@ module Blondy
55
55
  end
56
56
 
57
57
  def create_reply
58
- set_src
59
58
  set_pool_data
59
+ set_src
60
60
  set_other
61
61
  @reply
62
62
  end
@@ -74,7 +74,7 @@ module Blondy
74
74
  @reply.ip = IPAddr.new(@data.giaddr, family = Socket::AF_INET).to_s
75
75
  @reply.port = 67
76
76
  else
77
- @reply.ip = '255.255.255.255'
77
+ @reply.ip = @reply.reply_addr
78
78
  @reply.port = 68
79
79
  end
80
80
  end
@@ -83,11 +83,13 @@ module Blondy
83
83
  @reply.data.yiaddr = @pool.data.yiaddr
84
84
  @reply.data.fname = @pool.data.fname
85
85
  @reply.data.options = @pool.data.options
86
+ @reply.reply_addr = @pool.reply_addr
86
87
  end
87
88
 
88
89
  def set_other
89
90
  @reply.data.siaddr = IPAddr.new(Blondy::DHCPD::CONFIG['server_ip']).to_i
90
91
  @reply.data.xid = @data.xid if @data.xid
92
+ @reply.data.chaddr = @data.chaddr
91
93
  end
92
94
  end
93
95
  end
@@ -21,6 +21,7 @@ module Blondy
21
21
  DHCP::SubnetMaskOption.new({payload: array_from(data['netmask'])}),
22
22
  DHCP::RouterOption.new({payload: array_from(data['gw'])})
23
23
  ]
24
+ @result.reply_addr = IPAddr.new("#{data['yiaddr']}/#{data['netmask']}").to_range.last.to_s
24
25
  end
25
26
 
26
27
  def get
@@ -1,5 +1,5 @@
1
1
  module Blondy
2
2
  module Dhcpd
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -86,6 +86,7 @@ module Blondy
86
86
  before(:each) do
87
87
  discover.chaddr = [238, 238, 238, 238, 238, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
88
88
  discover.hlen = 6
89
+ pool_query_result.reply_addr = '192.168.5.255'
89
90
  pool_query_result.data.fname = 'test.txt'.unpack('C128').map {|x| x ? x : 0}
90
91
  pool_query_result.data.yiaddr = IPAddr.new('192.168.5.150').to_i
91
92
  pool_query_result.data.options = [
@@ -94,7 +95,7 @@ module Blondy
94
95
  DHCP::DomainNameOption.new({payload: 'example.com'.unpack('C*')}),
95
96
  DHCP::DomainNameServerOption.new({payload: [8,8,8,8]}),
96
97
  DHCP::IPAddressLeaseTimeOption.new({payload: [7200].pack('N').unpack('C*')}),
97
- DHCP::SubnetMaskOption.new({payload: [255, 255, 255, 255]}),
98
+ DHCP::SubnetMaskOption.new({payload: [255, 255, 255, 0]}),
98
99
  DHCP::RouterOption.new({payload: [192, 168, 1, 1]})
99
100
  ]
100
101
  reply.data = DHCP::Offer.new
@@ -103,6 +104,8 @@ module Blondy
103
104
  reply.data.yiaddr = pool_query_result.data.yiaddr
104
105
  reply.data.fname = pool_query_result.data.fname
105
106
  reply.data.siaddr = IPAddr.new(Blondy::DHCPD::CONFIG['server_ip']).to_i
107
+ reply.reply_addr = pool_query_result.reply_addr
108
+ reply.data.chaddr = discover.chaddr
106
109
  end
107
110
 
108
111
  it 'reply with offer' do
@@ -130,10 +133,10 @@ module Blondy
130
133
  it_should_behave_like 'Dispatcher', :discover
131
134
  end
132
135
  context 'giaddr = 0 and ciaddr = 0' do
133
- #send offer message to client by broadcast to 255.255.255.255
136
+ #send offer message to client by broadcast
134
137
  before(:each) do
135
138
  discover.flags = 1
136
- reply.ip = '255.255.255.255'
139
+ reply.ip = reply.reply_addr
137
140
  reply.port = 68
138
141
  end
139
142
  it_should_behave_like 'Dispatcher', :discover
@@ -163,6 +166,7 @@ module Blondy
163
166
  before(:each) do
164
167
  request.chaddr = [238, 238, 238, 238, 238, 238, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
165
168
  request.hlen = 6
169
+ pool_query_result.reply_addr = '192.168.5.255'
166
170
  pool_query_result.data.fname = 'test.txt'.unpack('C128').map {|x| x ? x : 0}
167
171
  pool_query_result.data.yiaddr = IPAddr.new('192.168.5.150').to_i
168
172
  pool_query_result.data.options = [
@@ -171,7 +175,7 @@ module Blondy
171
175
  DHCP::DomainNameOption.new({payload: 'example.com'.unpack('C*')}),
172
176
  DHCP::DomainNameServerOption.new({payload: [8,8,8,8]}),
173
177
  DHCP::IPAddressLeaseTimeOption.new({payload: [7200].pack('N').unpack('C*')}),
174
- DHCP::SubnetMaskOption.new({payload: [255, 255, 255, 255]}),
178
+ DHCP::SubnetMaskOption.new({payload: [255, 255, 255, 0]}),
175
179
  DHCP::RouterOption.new({payload: [192, 168, 1, 1]})
176
180
  ]
177
181
  reply.data = DHCP::ACK.new
@@ -180,6 +184,8 @@ module Blondy
180
184
  reply.data.yiaddr = pool_query_result.data.yiaddr
181
185
  reply.data.fname = pool_query_result.data.fname
182
186
  reply.data.siaddr = IPAddr.new(Blondy::DHCPD::CONFIG['server_ip']).to_i
187
+ reply.reply_addr = pool_query_result.reply_addr
188
+ reply.data.chaddr = request.chaddr
183
189
  message = request
184
190
  end
185
191
  it 'reply with ack' do
@@ -206,10 +212,10 @@ module Blondy
206
212
  it_should_behave_like 'Dispatcher', :request
207
213
  end
208
214
  context 'giaddr = 0 and ciaddr = 0' do
209
- #send ack message to client by broadcast to 255.255.255.255
215
+ #send ack message to client by broadcast
210
216
  before(:each) do
211
217
  request.flags = 1
212
- reply.ip = '255.255.255.255'
218
+ reply.ip = reply.reply_addr
213
219
  reply.port = 68
214
220
  end
215
221
  it_should_behave_like 'Dispatcher', :request
data/spec/pool_spec.rb CHANGED
@@ -28,6 +28,7 @@ module Blondy
28
28
  DHCP::SubnetMaskOption.new({payload: [255, 255, 255, 255]}),
29
29
  DHCP::RouterOption.new({payload: [192, 168, 1, 3]})
30
30
  ]
31
+ pool_query_result.reply_addr="192.168.5.150"
31
32
  pool_query_result
32
33
  end
33
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blondy-dhcpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Novitskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler