手机拍照的时候,EXIF里会带上Orientation的标记,一般的看图工具能很好地处理拍照方向,但是照片直接用于图像识别就麻烦了,不是所有工具都会认这个EXIF信息。使用手机拍照构建图像学习数据集的时候,务必要让图片正确旋转,否则标注的信息或者识别到的位置都可能会是错的。
使用 jhead http://www.sentex.net/~mwandel/jhead/usage.html
jhead -autorot xxx.jpgsskaje's blog, study & research on technology
手机拍照的时候,EXIF里会带上Orientation的标记,一般的看图工具能很好地处理拍照方向,但是照片直接用于图像识别就麻烦了,不是所有工具都会认这个EXIF信息。使用手机拍照构建图像学习数据集的时候,务必要让图片正确旋转,否则标注的信息或者识别到的位置都可能会是错的。
使用 jhead http://www.sentex.net/~mwandel/jhead/usage.html
jhead -autorot xxx.jpgNot 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[Interface] Address = 192.168.20.100/24 PrivateKey = KEY ListenPort = 51820 [Peer] PublicKey = RT1PUBKEY AllowedIPs = 192.168.20.200/32,192.168.10.0/24 Endpoint = RT1:51820 [Peer] PublicKey = RT2PUBKEY AllowedIPs = 0.0.0.0/0 Endpoint = RT2:51820 |
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.
1 2 |
# if you're not on Ubuntu, echo "201 wgswitch" >> /etc/iproute2/rt_tables echo "201 wgswitch" >> /etc/iproute2/rt_tables.d/wg_switch.conf |
Then modify wg0.conf.
1 2 3 4 5 |
[Interface] Address = 192.168.20.100/24 PrivateKey = KEY ListenPort = 51820 Table = 201 |
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
1 2 3 4 5 6 7 8 9 10 11 12 |
# PostUp /sbin/ip route add ROUTE_TO_ROUTER1/16 via LOCAL_GW dev eth0 table 230 /sbin/ip route add ROUTE_TO_ROUTER2/16 via LOCAL_GW dev eth0 table 230 /sbin/ip route add LOCAL_INTERFACE_IP/24 dev eth0 table 230 /sbin/ip route add 192.168.10.0/24 dev wg0 /sbin/ip rule add iif wg0 lookup 201 /bin/ping -c 1 192.168.201.1 /bin/ping -c 1 192.168.201.20 |
以前自己用 strongswan 等软件配 IPSec site-to-site 的时候,可以直接指定客户端的 IP 是 0.0.0.0,Azure 的 site-to-site IPSec VPN 必须要指定客户端 IP。
PowerShell 爱好者可以参考 https://www.hayesjupe.com/using-azure-rm-site-to-site-vpn-with-a-dynamic-ip/ 这篇文章。
我还是习惯用 Linux,于是使用 Azure CLI 来解决这个问题。
在 VPN 的 Virtual Network 里放置一台 Linux 虚拟机。按照上述连接里的说明安装软件。接下来开始操作。
SSH 登录虚拟机后,执行命令,并按照输出,用浏览器登录 Azure 账号,完成认证。
1 2 |
$ az login To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXX to authenticate. |
如果是中国区 Azure,先需要设置服务器
1 2 3 4 |
$ az cloud set -n AzureChinaCloud Switched active cloud to 'AzureChinaCloud'. Use 'az login' to log in to this cloud. Use 'az account set' to set the active subscription. |
如果需要切换回海外版本
1 |
$ az cloud set -n AzureCloud |
参考 DDNS 的玩法,让客户端定期更新IP。服务端可以简单地将数据记录到数据库、文件、或者任何地方,配置一个 cron 来执行更新检测和 Gateway IP 更新。
1 2 3 4 |
# 更新 IP $ az network local-gateway update -g RGNAME -n GWNAME --gateway-ip-address IP.ADD.RE.SS # 查看 Gateway $ az network local-gateway list -g RGNAME |
这里会有个问题,如果源 IP 和新 IP 相同,update 可能会出一个莫名其妙的404 错误。
1 |
Operation failed with status: 'Not Found'. Details: 404 Client Error: Not Found for url: https://management.chinacloudapi.cn/subscriptions/SUBSCRIPTION_ID/providers/Microsoft.Network/locations/chinanorth/operations/OPERATION_ID?api-version=2019-04-01 |
看了眼 –verbose –debug 的输出,这个 update 命令先发送了一条命令到服务端,然后轮询等待任务更新。可能这个任务服务端直接判定不需要执行,所以返回的 operation id 无效。
Unity Package Manager 的 Windows 版不认系统的证书设置,直接配置代理走 Charles Proxy 没法抓到请求的包。懒得去搭反向代理,直接使用 Charles Proxy 的 Map Remote 功能,在 manifest.json 里随便设置一个地址,用 Charles Proxy 修改请求到 https://packages.unity.com 上,就可以抓包了。
请求逻辑是这样的:
1 请求 /com.unity.package-manager.metadata ,官方地址 https://packages.unity.com/com.unity.package-manager.metadata
2 根据 1 的响应里的searchablePackages,拼接 https://packages.unity.com/{PACKAGE} 获取包信息,例如 https://packages.unity.com/com.unity.xiaomi
3 从 2 的响应里读取包下载地址,从 dist.tarball 里获取下载地址。例如 https://download.packages.unity.com/com.unity.xiaomi/-/com.unity.xiaomi-1.0.3.tgz
根据这个协议,自己写个服务端,甚至用nginx搭建一个,还是比较简单的。此外 nexus 是个好选择,不用处理 3 里域名的问题,具体看 https://sskaje.me/2019/08/sonatype-nexus-3-as-unity-package-mirror/
Unity Package Manager 使用了 npm 的协议,配置起来比较简单。安装好nexus 3之后,直接创建一个 npm 的 proxy,Remote Storage 设置成 https://packages.unity.com 就行。国内服务器有条件设置一个代理也好,毕竟unity 的服务器被墙的概率挺高的。
然而,有几个坑。
1 Unity Package Manager 启动的时候会发无数个 HEAD 请求,而 nexus 3 并不支持HEAD,直接返回了404,于是 UPM 里一片红色的报警,但是不影响安装。
2 UPM 不支持加密认证,所以要想使用本地的镜像仓库,或者用 nexus 来管理自己的包,只能开启匿名访问。而公司场景的 nexus,最好从比 http 更底层的方式控制访问,例如各层加 来源 IP 控制。官方说 2020.1 才会加认证的支持 https://forum.unity.com/threads/setup-for-scoped-registries-private-registries.573934/ 。
3 墙的问题太严重。