• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

恥ずかしい勘違いから生まれた、DHCP6の不要かつ部分的な実装


Commit MetaInfo

修訂9b7108f06524751cd2d59521a550dcd5b92639e1 (tree)
時間2021-08-12 22:21:25
作者dyknon <dyknon@user...>
Commiterdyknon

Log Message

emit error if unparsed option is required by class

Change Summary

差異

--- a/Net/DHCP6/OptionList.pm
+++ b/Net/DHCP6/OptionList.pm
@@ -28,8 +28,16 @@ sub options {
2828 %index = (%index,
2929 map{$_, 1}grep{$opts[$_]->code == $key}(0 .. $#opts));
3030 }else{
31- %index = (%index,
32- map{$_, 1}grep{$opts[$_]->isa($key)}(0 .. $#opts));
31+ my $code = eval{$key->code};
32+ my %hits = map{$_, 1}grep{$opts[$_]->isa($key)}(0 .. $#opts);
33+ if(defined $code){
34+ my $error = join "",
35+ grep{!exists $hits{$_}}
36+ grep{$opts[$_]->code == $code}
37+ (0 .. $#opts);
38+ die "the required option is left unparsed" if($error);
39+ }
40+ %index = (%index, %hits);
3341 }
3442 }
3543 @opts[keys %index];
--- a/query_dns_servers.pl
+++ b/query_dns_servers.pl
@@ -50,14 +50,14 @@ my $client = Net::DHCP6::Exchange::InfoReq->new(
5050 DHCP6_OPT_DNS_SERVERS,
5151 ],
5252 failed => sub{print("timeout\n");},
53- recved => sub{
53+ recved => sub{ eval{
5454 my $recved = shift;
5555 print("message: $recved\n");
56- for($recved->option(DHCP6_OPT_DNS_SERVERS)->all_elems){
56+ for($recved->option("Net::DHCP6::Option::DnsServer")->all_elems){
5757 print("DNS-server: $_\n");
5858 }
5959 1;
60- },
60+ }},
6161 );
6262
6363 local $| = 1;