-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1618 lines (1167 loc) · 90.4 KB
/
index.html
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
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.3.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {
hostname: new URL('https://doraemomo.github.io').hostname,
root: '/',
scheme: 'Gemini',
version: '7.7.1',
exturl: false,
sidebar: {"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},
copycode: {"enable":false,"show_result":false,"style":null},
back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
bookmark: {"enable":false,"color":"#222","save":"auto"},
fancybox: false,
mediumzoom: false,
lazyload: false,
pangu: false,
comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
algolia: {
appID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
},
localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
path: '',
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
};
</script>
<meta property="og:type" content="website">
<meta property="og:title" content="Doraemomo's site">
<meta property="og:url" content="https://doraemomo.github.io/index.html">
<meta property="og:site_name" content="Doraemomo's site">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="doraemomo">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://doraemomo.github.io/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome: true,
isPost: false
};
</script>
<title>Doraemomo's site</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-meta">
<div>
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Doraemomo's site</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
</div>
<div class="site-nav-toggle">
<div class="toggle" aria-label="Toggle navigation bar">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>Tags<span class="badge">48</span></a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>Categories<span class="badge">36</span></a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives<span class="badge">46</span></a>
</li>
<li class="menu-item menu-item-about">
<a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>About</a>
</li>
<li class="menu-item menu-item-booklist">
<a href="/booklist/" rel="section"><i class="fa fa-fw fa-book list"></i>booklist</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content">
<div class="posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="en">
<link itemprop="mainEntityOfPage" href="https://doraemomo.github.io/2022/12/05/javascript-note/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="doraemomo">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Doraemomo's site">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/12/05/javascript-note/" class="post-title-link" itemprop="url">JavaScript Note</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-12-05 14:02:50 / Modified: 14:05:26" itemprop="dateCreated datePublished" datetime="2022-12-05T14:02:50+01:00">2022-12-05</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Programming-Language/" itemprop="url" rel="index">
<span itemprop="name">Programming Language</span>
</a>
</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Disqus: </span>
<a title="disqus" href="/2022/12/05/javascript-note/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2022/12/05/javascript-note/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="match-a-phone-number-with-regex-and-javascript">Match a phone number with Regex and JavaScript</h2>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> regex = <span class="regexp">/^(1[ -]?)?\d{3}[ -]?\d{3}[ -]?\d{4}$/</span>;</span><br><span class="line"><span class="keyword">const</span> phoneNumber = <span class="string">'1202-515-5555'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// test returns 'true' if there's a match and 'false' if there is not</span></span><br><span class="line"><span class="keyword">const</span> match = regex.<span class="title function_">test</span>(phoneNumber);</span><br><span class="line"></span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="en">
<link itemprop="mainEntityOfPage" href="https://doraemomo.github.io/2022/11/03/dns-note/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="doraemomo">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Doraemomo's site">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/11/03/dns-note/" class="post-title-link" itemprop="url">DNS note</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-11-03 14:29:47" itemprop="dateCreated datePublished" datetime="2022-11-03T14:29:47+01:00">2022-11-03</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2022-11-04 12:05:32" itemprop="dateModified" datetime="2022-11-04T12:05:32+01:00">2022-11-04</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/DNS/" itemprop="url" rel="index">
<span itemprop="name">DNS</span>
</a>
</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Disqus: </span>
<a title="disqus" href="/2022/11/03/dns-note/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2022/11/03/dns-note/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>DNS解析不涉及端口.</p>
<p>DNS服务器有不同的类型: 递归解析器, 根域名服务器, TLD域名服务器 (Top Level Domain), 权威域名服务器.</p>
<p>根域名服务器一共有13台 (都是服务器集群, 通过Anycast路由来提供快速响应), 他们的IP地址是不变的, 集成在操作系统里.</p>
<p>直接输入dig命令, 就会得到根服务器的信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dig</span><br></pre></td></tr></table></figure>
<table>
<thead>
<tr class="header">
<th style="text-align: center;">Root Server</th>
<th style="text-align: center;">IPv4</th>
<th style="text-align: center;">IPv6</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">a.root-servers.net</td>
<td style="text-align: center;">198.41.0.4</td>
<td style="text-align: center;">2001:503:ba3e::2:30</td>
</tr>
<tr class="even">
<td style="text-align: center;">b.root-servers.net</td>
<td style="text-align: center;">199.9.14.201</td>
<td style="text-align: center;">2001:500:200::b</td>
</tr>
<tr class="odd">
<td style="text-align: center;">c.root-servers.net</td>
<td style="text-align: center;">192.33.4.12</td>
<td style="text-align: center;">2001:500:2::c</td>
</tr>
<tr class="even">
<td style="text-align: center;">d.root-servers.net</td>
<td style="text-align: center;">199.7.91.13</td>
<td style="text-align: center;">2001:500:2d::d</td>
</tr>
<tr class="odd">
<td style="text-align: center;">e.root-servers.net</td>
<td style="text-align: center;">192.203.230.10</td>
<td style="text-align: center;">2001:500:a8::e</td>
</tr>
<tr class="even">
<td style="text-align: center;">f.root-servers.net</td>
<td style="text-align: center;">192.5.5.241</td>
<td style="text-align: center;">2001:500:2f::f</td>
</tr>
<tr class="odd">
<td style="text-align: center;">g.root-servers.net</td>
<td style="text-align: center;">192.112.36.4</td>
<td style="text-align: center;">2001:500:12::d0d</td>
</tr>
<tr class="even">
<td style="text-align: center;">h.root-servers.net</td>
<td style="text-align: center;">198.97.190.53</td>
<td style="text-align: center;">2001:500:1::53</td>
</tr>
<tr class="odd">
<td style="text-align: center;">i.root-servers.net</td>
<td style="text-align: center;">192.36.148.17</td>
<td style="text-align: center;">2001:7fe::53</td>
</tr>
<tr class="even">
<td style="text-align: center;">j.root-servers.net</td>
<td style="text-align: center;">192.58.128.30</td>
<td style="text-align: center;">2001:503:c27::2:30</td>
</tr>
<tr class="odd">
<td style="text-align: center;">k.root-servers.net</td>
<td style="text-align: center;">193.0.14.129</td>
<td style="text-align: center;">2001:7fd::1</td>
</tr>
<tr class="even">
<td style="text-align: center;">l.root-servers.net</td>
<td style="text-align: center;">199.7.83.42</td>
<td style="text-align: center;">2001:500:9f::42</td>
</tr>
<tr class="odd">
<td style="text-align: center;">m.root-servers.net</td>
<td style="text-align: center;">202.12.27.33</td>
<td style="text-align: center;">2001:dc3::35</td>
</tr>
</tbody>
</table>
<h2 id="dns递归解析器">DNS递归解析器</h2>
<p>递归解析器作为客户端与DNS域名服务器的中间人, DNS的分级解析下行过程 (从根服务器到顶级服务器到权威服务器)是由递归解析器完成的, 不是由DNS服务器完成的. 大多数Internet用户使用他们ISP提供的递归解析器,但还有其他可用选择, 例如Cloudflare的1.1.1.1.</p>
<h2 id="manually-add-host-手动添加dns记录">Manually add host 手动添加DNS记录</h2>
<p>如果域名在本地文件中, 访问该域名时就不会询问域名服务器.</p>
<p>Edit first <strong>/etc/hosts</strong>, then flush local DNS cache:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dscacheutil -flushcache</span><br></pre></td></tr></table></figure>
<h2 id="dig命令">Dig命令</h2>
<p>可以指定域名服务器</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dig @<DNS server IP/DNS server URL> <domaine name></span><br></pre></td></tr></table></figure>
<p>可以查询所有的信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dig +nocmd google.com any +noall +answer</span><br></pre></td></tr></table></figure>
<h2 id="dns查询流程">DNS查询流程</h2>
<p>为了更好的的理解DNS的查询步骤, 我们可以用dig命令来做一个释例.</p>
<p>递归解析器帮助完成逐级查询的全部任务, 所以通过递归解析器查询, 可以直接得到IP</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dig @1.1.1.1 google.com</span><br></pre></td></tr></table></figure>
<p>因为递归解析器干了所有的活, 所以在<strong>ANSWER SECTION</strong>里, 我们直接得到了IP地址</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">; <<>> DiG 9.10.6 <<>> @1.1.1.1 google.com</span><br><span class="line">; (1 server found)</span><br><span class="line">;; global options: +cmd</span><br><span class="line">;; Got answer:</span><br><span class="line">;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36771</span><br><span class="line">;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1</span><br><span class="line"></span><br><span class="line">;; OPT PSEUDOSECTION:</span><br><span class="line">; EDNS: version: 0, flags:; udp: 1232</span><br><span class="line">;; QUESTION SECTION:</span><br><span class="line">;google.com. IN A</span><br><span class="line"></span><br><span class="line">;; ANSWER SECTION:</span><br><span class="line">google.com. 18 IN A 142.250.201.174</span><br><span class="line"></span><br><span class="line">;; Query time: 43 msec</span><br><span class="line">;; SERVER: 1.1.1.1#53(1.1.1.1)</span><br><span class="line">;; WHEN: Thu Nov 03 18:04:36 CET 2022</span><br><span class="line">;; MSG SIZE rcvd: 55</span><br></pre></td></tr></table></figure>
<p>如果我们尝试去询问根服务器,</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dig @198.41.0.4 google.com</span><br></pre></td></tr></table></figure>
<p>根服务器并没有域名的具体IP, 相应的, 根服务器会发送给我们顶级服务器的地址在<strong>AUTHORITY SECTION</strong>里, 以便于逐级查询. 换句话说, 根服务器只提供顶级服务器的信息.</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line">; <<>> DiG 9.10.6 <<>> @198.41.0.4 google.com</span><br><span class="line">; (1 server found)</span><br><span class="line">;; global options: +cmd</span><br><span class="line">;; Got answer:</span><br><span class="line">;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2331</span><br><span class="line">;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 13, ADDITIONAL: 27</span><br><span class="line">;; WARNING: recursion requested but not available</span><br><span class="line"></span><br><span class="line">;; OPT PSEUDOSECTION:</span><br><span class="line">; EDNS: version: 0, flags:; udp: 4096</span><br><span class="line">;; QUESTION SECTION:</span><br><span class="line">;google.com. IN A</span><br><span class="line"></span><br><span class="line">;; AUTHORITY SECTION:</span><br><span class="line">com. 172800 IN NS e.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS b.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS j.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS m.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS i.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS f.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS a.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS g.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS h.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS l.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS k.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS c.gtld-servers.net.</span><br><span class="line">com. 172800 IN NS d.gtld-servers.net.</span><br><span class="line"></span><br><span class="line">;; ADDITIONAL SECTION:</span><br><span class="line">e.gtld-servers.net. 172800 IN A 192.12.94.30</span><br><span class="line">e.gtld-servers.net. 172800 IN AAAA 2001:502:1ca1::30</span><br><span class="line">b.gtld-servers.net. 172800 IN A 192.33.14.30</span><br><span class="line">b.gtld-servers.net. 172800 IN AAAA 2001:503:231d::2:30</span><br><span class="line">j.gtld-servers.net. 172800 IN A 192.48.79.30</span><br><span class="line">j.gtld-servers.net. 172800 IN AAAA 2001:502:7094::30</span><br><span class="line">m.gtld-servers.net. 172800 IN A 192.55.83.30</span><br><span class="line">m.gtld-servers.net. 172800 IN AAAA 2001:501:b1f9::30</span><br><span class="line">i.gtld-servers.net. 172800 IN A 192.43.172.30</span><br><span class="line">i.gtld-servers.net. 172800 IN AAAA 2001:503:39c1::30</span><br><span class="line">f.gtld-servers.net. 172800 IN A 192.35.51.30</span><br><span class="line">f.gtld-servers.net. 172800 IN AAAA 2001:503:d414::30</span><br><span class="line">a.gtld-servers.net. 172800 IN A 192.5.6.30</span><br><span class="line">a.gtld-servers.net. 172800 IN AAAA 2001:503:a83e::2:30</span><br><span class="line">g.gtld-servers.net. 172800 IN A 192.42.93.30</span><br><span class="line">g.gtld-servers.net. 172800 IN AAAA 2001:503:eea3::30</span><br><span class="line">h.gtld-servers.net. 172800 IN A 192.54.112.30</span><br><span class="line">h.gtld-servers.net. 172800 IN AAAA 2001:502:8cc::30</span><br><span class="line">l.gtld-servers.net. 172800 IN A 192.41.162.30</span><br><span class="line">l.gtld-servers.net. 172800 IN AAAA 2001:500:d937::30</span><br><span class="line">k.gtld-servers.net. 172800 IN A 192.52.178.30</span><br><span class="line">k.gtld-servers.net. 172800 IN AAAA 2001:503:d2d::30</span><br><span class="line">c.gtld-servers.net. 172800 IN A 192.26.92.30</span><br><span class="line">c.gtld-servers.net. 172800 IN AAAA 2001:503:83eb::30</span><br><span class="line">d.gtld-servers.net. 172800 IN A 192.31.80.30</span><br><span class="line">d.gtld-servers.net. 172800 IN AAAA 2001:500:856e::30</span><br><span class="line"></span><br><span class="line">;; Query time: 81 msec</span><br><span class="line">;; SERVER: 198.41.0.4#53(198.41.0.4)</span><br><span class="line">;; WHEN: Fri Nov 04 10:39:58 CET 2022</span><br><span class="line">;; MSG SIZE rcvd: 835</span><br></pre></td></tr></table></figure>
<p>根据根服务器提供的顶级服务器的信息, 我们继续询问顶级服务器</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dig @192.12.94.30 google.com</span><br></pre></td></tr></table></figure>
<p>顶级域名服务器会发给我们权威域名服务器的信息, 在<strong>AUTHORITY SECTION</strong>里面, 换句话说, 顶级域名服务器,只记录了权威服务器的信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">; <<>> DiG 9.10.6 <<>> @192.12.94.30 google.com</span><br><span class="line">; (1 server found)</span><br><span class="line">;; global options: +cmd</span><br><span class="line">;; Got answer:</span><br><span class="line">;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35625</span><br><span class="line">;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 9</span><br><span class="line">;; WARNING: recursion requested but not available</span><br><span class="line"></span><br><span class="line">;; OPT PSEUDOSECTION:</span><br><span class="line">; EDNS: version: 0, flags:; udp: 4096</span><br><span class="line">;; QUESTION SECTION:</span><br><span class="line">;google.com. IN A</span><br><span class="line"></span><br><span class="line">;; AUTHORITY SECTION:</span><br><span class="line">google.com. 172800 IN NS ns2.google.com.</span><br><span class="line">google.com. 172800 IN NS ns1.google.com.</span><br><span class="line">google.com. 172800 IN NS ns3.google.com.</span><br><span class="line">google.com. 172800 IN NS ns4.google.com.</span><br><span class="line"></span><br><span class="line">;; ADDITIONAL SECTION:</span><br><span class="line">ns2.google.com. 172800 IN AAAA 2001:4860:4802:34::a</span><br><span class="line">ns2.google.com. 172800 IN A 216.239.34.10</span><br><span class="line">ns1.google.com. 172800 IN AAAA 2001:4860:4802:32::a</span><br><span class="line">ns1.google.com. 172800 IN A 216.239.32.10</span><br><span class="line">ns3.google.com. 172800 IN AAAA 2001:4860:4802:36::a</span><br><span class="line">ns3.google.com. 172800 IN A 216.239.36.10</span><br><span class="line">ns4.google.com. 172800 IN AAAA 2001:4860:4802:38::a</span><br><span class="line">ns4.google.com. 172800 IN A 216.239.38.10</span><br><span class="line"></span><br><span class="line">;; Query time: 51 msec</span><br><span class="line">;; SERVER: 192.12.94.30#53(192.12.94.30)</span><br><span class="line">;; WHEN: Fri Nov 04 11:06:09 CET 2022</span><br><span class="line">;; MSG SIZE rcvd: 287</span><br></pre></td></tr></table></figure>
<p>我们继续询问权威服务器</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dig @216.239.34.10 google.com</span><br></pre></td></tr></table></figure>
<p>权威服务器终于发给我们想要的IP地址了, 在<strong>ANSWER SECTION</strong>字段里</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">; <<>> DiG 9.10.6 <<>> @216.239.34.10 google.com</span><br><span class="line">; (1 server found)</span><br><span class="line">;; global options: +cmd</span><br><span class="line">;; Got answer:</span><br><span class="line">;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40547</span><br><span class="line">;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1</span><br><span class="line">;; WARNING: recursion requested but not available</span><br><span class="line"></span><br><span class="line">;; OPT PSEUDOSECTION:</span><br><span class="line">; EDNS: version: 0, flags:; udp: 512</span><br><span class="line">;; QUESTION SECTION:</span><br><span class="line">;google.com. IN A</span><br><span class="line"></span><br><span class="line">;; ANSWER SECTION:</span><br><span class="line">google.com. 300 IN A 142.250.178.142</span><br><span class="line"></span><br><span class="line">;; Query time: 50 msec</span><br><span class="line">;; SERVER: 216.239.34.10#53(216.239.34.10)</span><br><span class="line">;; WHEN: Fri Nov 04 11:09:45 CET 2022</span><br><span class="line">;; MSG SIZE rcvd: 55</span><br></pre></td></tr></table></figure>
<p>我们总结一下, 域名解析系统就是一个分级系统, 逐级向下, 根服务器, 顶级服务器, 权威服务器分别负责记录他们那一级别的信息, 查询是逐级向下的, 而递归解析服务器的角色比较特殊, 他就像一个管家, 把逐级查询的任务都包了, 直接发给我们想要的结果.</p>
<h2 id="host命令">host命令</h2>
<p>host命令可以得到比较综合的信息.</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">host -a <domaine name> </span><br></pre></td></tr></table></figure>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">Trying "visiocheck.fr"</span><br><span class="line">;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6105</span><br><span class="line">;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 0, ADDITIONAL: 2</span><br><span class="line"></span><br><span class="line">;; QUESTION SECTION:</span><br><span class="line">;visiocheck.fr. IN ANY</span><br><span class="line"></span><br><span class="line">;; ANSWER SECTION:</span><br><span class="line">visiocheck.fr. 3189 IN A 80.12.14.37</span><br><span class="line">visiocheck.fr. 3201 IN NS ns1.pcreseaux.com.</span><br><span class="line">visiocheck.fr. 3201 IN NS ns2.lhebergeur.org.</span><br><span class="line">visiocheck.fr. 3201 IN SOA ns1.pcreseaux.com. postmaster.visiocheck.fr. 2021012107 3600 900 1209600 3600</span><br><span class="line">visiocheck.fr. 3201 IN MX 1 mx1.mail.ovh.net.</span><br><span class="line">visiocheck.fr. 3201 IN MX 100 mx3.mail.ovh.net.</span><br><span class="line">visiocheck.fr. 3201 IN MX 5 mx2.mail.ovh.net.</span><br><span class="line">visiocheck.fr. 3201 IN TXT "v=spf1 include:mx.ovh.com include:spf.protection.outlook.com ip4:34.231.41.20 ~all"</span><br><span class="line">visiocheck.fr. 3201 IN TXT "1|www.visiocheck.fr"</span><br><span class="line"></span><br><span class="line">;; ADDITIONAL SECTION:</span><br><span class="line">ns1.pcreseaux.com. 81242 IN A 185.103.140.84</span><br><span class="line">ns2.lhebergeur.org. 1497 IN A 185.103.140.85</span><br><span class="line"></span><br><span class="line">Received 388 bytes from 192.168.1.4#53 in 52 ms</span><br></pre></td></tr></table></figure>
<table>
<thead>
<tr class="header">
<th style="text-align: center;">Key</th>
<th style="text-align: center;">Content</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">A</td>
<td style="text-align: center;">IPv4地址</td>
</tr>
<tr class="even">
<td style="text-align: center;">AAAA</td>
<td style="text-align: center;">IPv6地址</td>
</tr>
<tr class="odd">
<td style="text-align: center;">NS</td>
<td style="text-align: center;">Name Server 域名服务器</td>
</tr>
<tr class="even">
<td style="text-align: center;">SOA</td>
<td style="text-align: center;">Start of Authority 起始授权机构</td>
</tr>
<tr class="odd">
<td style="text-align: center;">MX</td>
<td style="text-align: center;">Mail Exchange 邮件交换</td>
</tr>
<tr class="even">
<td style="text-align: center;">CNAME</td>
<td style="text-align: center;">Canonical Name 规范名</td>
</tr>
<tr class="odd">
<td style="text-align: center;">PTR</td>
<td style="text-align: center;">Pointer 指针</td>
</tr>
<tr class="even">
<td style="text-align: center;">TXT</td>
<td style="text-align: center;">Text</td>
</tr>
<tr class="odd">
<td style="text-align: center;">SRV</td>
<td style="text-align: center;">Service</td>
</tr>
</tbody>
</table>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="en">
<link itemprop="mainEntityOfPage" href="https://doraemomo.github.io/2022/10/21/cryptography/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="doraemomo">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Doraemomo's site">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/10/21/cryptography/" class="post-title-link" itemprop="url">Cryptography 密码学</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-10-21 14:55:43" itemprop="dateCreated datePublished" datetime="2022-10-21T14:55:43+02:00">2022-10-21</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2022-12-13 17:46:37" itemprop="dateModified" datetime="2022-12-13T17:46:37+01:00">2022-12-13</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/cryptography/" itemprop="url" rel="index">
<span itemprop="name">cryptography</span>
</a>
</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Disqus: </span>
<a title="disqus" href="/2022/10/21/cryptography/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2022/10/21/cryptography/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>X.509 基本算是公钥证书的标准格式, 看一下IETF文档的更新历史就可见一斑</p>
<ul>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc2459">RFC2459</a> (被3280替代, 已过期)</li>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc3280">RFC3280</a> (被5280替代, 已过期)</li>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc4325">RFC4325</a> (补充3280, 已过期)</li>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc4630">RFC4630</a> (补充3280, 已过期)</li>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc5280">RFC5280</a></li>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc6818">RFC6818</a> (补充, 5280)</li>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc8398">RFC8398</a> (补充, 5280)</li>
<li><a target="_blank" rel="noopener" href="https://www.rfc-editor.org/rfc/rfc8399">RFC8399</a> (补充, 5280)</li>
</ul>
<p>不同的证书编码格式</p>
<p>PEM Privacy Enhanced Mail 内容一般是BASE64的, 查看证书信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl x509 -in <.pem> -text -noout</span><br></pre></td></tr></table></figure>
<p>DER Distinguished Encoding Rules 二进制格式, 查看证书信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl x509 -in <.der> -inform der -text -noout</span><br></pre></td></tr></table></figure>
<p>相关的文件扩展名</p>
<p>CRT, CER</p>
<p>KEY 存放公钥或者私钥</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl rsa -in mykey.key -text -noout</span><br></pre></td></tr></table></figure>
<p>CSR Signing Request</p>
<h3 id="工具">工具</h3>
<ul>
<li>keytool</li>
<li>openssl</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl rsa -in mykey.key -text -noout </span><br></pre></td></tr></table></figure>
<h2 id="openssl">OpenSSL</h2>
<h3 id="password">password</h3>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">openssl rand -base64 6</span><br><span class="line"></span><br><span class="line">openssl rand -hex 4</span><br></pre></td></tr></table></figure>
<h3 id="generate-rsa-private-key">generate RSA private key</h3>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl genrsa</span><br></pre></td></tr></table></figure>
<p>more parameters for generation</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl genrsa -out private_pkcs1.pem 2048</span><br></pre></td></tr></table></figure>
<p>2048 is the length of the modulus, -out redirect the key to a file for example.</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="en">
<link itemprop="mainEntityOfPage" href="https://doraemomo.github.io/2022/09/21/nodejs-note/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="doraemomo">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Doraemomo's site">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/09/21/nodejs-note/" class="post-title-link" itemprop="url">Node.js note</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-09-21 16:59:26 / Modified: 17:21:15" itemprop="dateCreated datePublished" datetime="2022-09-21T16:59:26+02:00">2022-09-21</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/runtime/" itemprop="url" rel="index">
<span itemprop="name">runtime</span>
</a>
</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Disqus: </span>
<a title="disqus" href="/2022/09/21/nodejs-note/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2022/09/21/nodejs-note/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="查看包的版本">查看包的版本</h2>
<p>所有历史版本</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm view <package name> versions</span><br></pre></td></tr></table></figure>
<p>最新版本</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm view <package name> version</span><br></pre></td></tr></table></figure>
<p>列出可更新的版本</p>
<p>本地</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm outdated</span><br></pre></td></tr></table></figure>
<p>全局</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm outdated -g</span><br></pre></td></tr></table></figure>
<p>更新包</p>
<p>更新本地指定包</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm update <package name></span><br></pre></td></tr></table></figure>
<p>更新全局指定包</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm update -g <package name> </span><br></pre></td></tr></table></figure>
<p>更新所有本地</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm update</span><br></pre></td></tr></table></figure>
<p>更新所有全局</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm update -g</span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="en">
<link itemprop="mainEntityOfPage" href="https://doraemomo.github.io/2022/06/16/protocol-buffers-note/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="doraemomo">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Doraemomo's site">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/06/16/protocol-buffers-note/" class="post-title-link" itemprop="url">Protocol Buffers Note Protocol Buffers笔记</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-06-16 11:43:04 / Modified: 11:58:16" itemprop="dateCreated datePublished" datetime="2022-06-16T11:43:04+02:00">2022-06-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Serialization/" itemprop="url" rel="index">
<span itemprop="name">Serialization</span>
</a>
</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Disqus: </span>
<a title="disqus" href="/2022/06/16/protocol-buffers-note/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2022/06/16/protocol-buffers-note/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="c-sharp">C sharp</h2>
<h3 id="compile-the-proto-file">Compile the proto file</h3>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">protoc -I=$SRC_DIR --csharp_out=$DST_DIR $SRC_DIR/your.proto</span><br></pre></td></tr></table></figure>
<h3 id="dependencies">Dependencies</h3>
<p>NuGet Package Manager will manage the dependencies, just install the Google.protobuf package, which is the official one.</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="en">
<link itemprop="mainEntityOfPage" href="https://doraemomo.github.io/2022/06/13/websocket-note/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="doraemomo">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Doraemomo's site">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/06/13/websocket-note/" class="post-title-link" itemprop="url">WebSocket Note WebSocket笔记</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-06-13 15:38:38 / Modified: 15:59:04" itemprop="dateCreated datePublished" datetime="2022-06-13T15:38:38+02:00">2022-06-13</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/TCP/" itemprop="url" rel="index">
<span itemprop="name">TCP</span>
</a>
</span>
,
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/TCP/Socket/" itemprop="url" rel="index">
<span itemprop="name">Socket</span>
</a>
</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Disqus: </span>
<a title="disqus" href="/2022/06/13/websocket-note/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2022/06/13/websocket-note/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><a target="_blank" rel="noopener" href="https://datatracker.ietf.org/doc/html/rfc6455">The WebSocket Protocol</a></p>
<h2 id="opcode">Opcode</h2>
<p>Opcode表明了WebSocket每一帧的类型, 是一个范围从0到15的整数. Opcode位于每一帧第一字节的低四位比特, 参见协议文档6455的5.2段.</p>
<figure class="highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"> 0 1 2 3</span><br><span class="line"> 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1</span><br><span class="line">+-+-+-+-+-------+-+-------------+-------------------------------+</span><br><span class="line">|F|R|R|R| opcode|M| Payload len | Extended payload length |</span><br><span class="line">|I|S|S|S| (4) |A| (7) | (16/64) |</span><br><span class="line">|N|V|V|V| |S| | (if payload len==126/127) |</span><br><span class="line">| |1|2|3| |K| | |</span><br><span class="line">+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +</span><br><span class="line">| Extended payload length continued, if payload len == 127 |</span><br><span class="line">+ - - - - - - - - - - - - - - - +-------------------------------+</span><br><span class="line">| |Masking-key, if MASK set to 1 |</span><br><span class="line">+-------------------------------+-------------------------------+</span><br><span class="line">| Masking-key (continued) | Payload Data |</span><br><span class="line">+-------------------------------- - - - - - - - - - - - - - - - +</span><br><span class="line">: Payload Data continued ... :</span><br><span class="line">+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +</span><br><span class="line">| Payload Data continued ... |</span><br><span class="line">+---------------------------------------------------------------+</span><br></pre></td></tr></table></figure>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="en">
<link itemprop="mainEntityOfPage" href="https://doraemomo.github.io/2022/04/22/aws-note/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="doraemomo">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Doraemomo's site">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2022/04/22/aws-note/" class="post-title-link" itemprop="url">AWS Note</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2022-04-22 11:21:21" itemprop="dateCreated datePublished" datetime="2022-04-22T11:21:21+02:00">2022-04-22</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2022-12-13 12:00:55" itemprop="dateModified" datetime="2022-12-13T12:00:55+01:00">2022-12-13</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">In</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/devops/" itemprop="url" rel="index">
<span itemprop="name">devops</span>
</a>
</span>
,
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/devops/server/" itemprop="url" rel="index">
<span itemprop="name">server</span>
</a>
</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<span class="post-meta-item-text">Disqus: </span>
<a title="disqus" href="/2022/04/22/aws-note/#disqus_thread" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="2022/04/22/aws-note/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>