DN42 - 注册AS
小白第一次注册DN42过程记录。也是第一回使用git,记录一些弯路。
一、前期准备
1. 环境
操作系统:Ubuntu 20.04(啥操作系统都行,主要是方便使用git就可以)
2. 工具
git + vscode(大多数编辑器都行)
git的话,网上教程有很多。主要掌握(后面主要涉及):clone,check,push,add,commit,push,fetch,rebase,branch,log命令。
还要建立git和Gitea之间的SSH authentication。
本地电脑执行:
ssh-keygen -t rsa -C “xxxxxxxx”
然后找到~/.ssh目录下的公钥id_rsa.pub,复制到Gitea上的SSH Keys配置中。
二、注册流程
参考dn42/registry里的README.md
1. Create a local clone of the registry repository
git clone git@git.dn42.dev:dn42/registry.git
可以根据.git文件的位置来确定仓库的位置(根目录)。(第一回clone的时候,以为根目录需要自己init,后来发现并不用)
2. Create a branch for your changes
# create a new branch and switch to it
git checkout -b <username>-YYYYMMDD/<name>
# push it immediately to the registry
git push --set-upstream origin <username>-YYYYMMDD/<name>
3. Make your changes on your new branch
补充AS的注册数据,可以参考官方的wiki或者网上的一些教程,挺多的。
DN42中空闲的ASN、IPv4和IPv6可以在DN42 Free Explorer里面寻找。
DN42中已经注册的信息可以看dn42.us registry。
配置完data之后,运行下检测程序。我这好像没啥问题。
./fmt-my-stuff MNTNER-MNT
./check-my-stuff MNTNER-MNT
./check-pol origin/master MNTNER-MNT
git add .
git commit
4. Push your changes back to the registry
如果有多次commit,一定要squash到一个commit里。
而且在commit之前,要先fetch一下最新的仓库。
./squash-my-commits
git push --force
或者
# make sure your local copy of the master is up to date
git fetch origin master
# ensure you are using your new branch
git checkout foo-20200704/mychange
# rebase your branch on top of the master
#
# -i to interactively pick the commits
# -S to sign the result with your GPG key (not required for SSH authentication)
#
# In interactive mode, make sure the first commit says ‘pick’
# change the rest from ‘pick’ to ‘squash’
# save and close to create the commit
git rebase -i -S origin/master
# force push your changes back to the registry
git push --force
5. Create a pull request
我在这使用的是SSH authentication,因此需要将此次commit对应的commit hash和对应的SSH signature跟着Pull Request一块儿提交。
通过以下指令,获取对应的SSH signature:
echo “<commit hash>” | ssh-keygen -Y sign -f ~/.ssh/id_rsa -n dn42
然后,提交SSH signature时,需要将
-----BEGIN SSH SIGNATURE-----
# 和
-----END SSH SIGNATURE-----
也粘贴进去。不然验证会报错。
验证这块可以参考:How Authentication Works
6. Making updates
在审核的过程中,可能会有新的分支被合并进主分支了,所以需要Update一下。主要参考4. Push your changes back to the registry。
但是有可能会出现多个commit。多个commit需要进行squash,管理员给的建议是:
$ ./squash-my-commits -S --push
然而好像没啥用。
我用4. Push your changes back to the registry下面的rebase的方法,可以成功squash。
现在在等着merge。