JavaScript DNS-SD



用了 npm 包 multicast-dns https://www.npmjs.com/package/multicast-dns 。其他几个包也试过了,各种残废,要不想太多要不瞎搞,还是这个单纯。

核心的环节是,正确地响应 “_services._dns-sd._udp.local” 的query。

响应的包 answers 放 PTR,additional records 放 SRV、TXT、A。TXT可以放多个 key=value,来处理自定义配置,例如端口、是否加密,认证等信息。

Gist: https://gist.github.com/sskaje/974ec85b39f51dd3a4c6734c2bfb214f



JavaScript DNS-SD by @sskaje: https://sskaje.me/2020/05/javascript-dns-sd/

JPEG 自动旋转



手机拍照的时候,EXIF里会带上Orientation的标记,一般的看图工具能很好地处理拍照方向,但是照片直接用于图像识别就麻烦了,不是所有工具都会认这个EXIF信息。使用手机拍照构建图像学习数据集的时候,务必要让图片正确旋转,否则标注的信息或者识别到的位置都可能会是错的。

使用 jhead http://www.sentex.net/~mwandel/jhead/usage.html

jhead -autorot xxx.jpg

JPEG 自动旋转 by @sskaje: https://sskaje.me/2019/11/jpeg-auto-rotate/

WireGuard as a “Switch”



Not really a switch, but similar. If you want to exchange data from two network using a host on Internet, this post helps.

In this case, Router 1 want to use Router 2 as gateway for some destinations. All 3 Nodes here have Internet public IP address.

I set-up a network, 192.168.20.0/24, using WireGuard. Our work are all on the Server in the middle.

If I put such config to /etc/wireguard/wg0.conf and run wg-quick up wg0, then I may lost connection to the server, because of the default route.

Now, add a route table to your system and change wg0.conf, let’s name it wgswitch and table id 201.

Then modify wg0.conf.

Now when you establish connections, you’ll be able to ping from router1 to router2 using 192.168.20.0/24 network.

But if you want to try a custom network, that’s not enough, you need extra route and ip rule for your network



WireGuard as a “Switch” by @sskaje: https://sskaje.me/2019/11/wireguard-as-a-switch/