Recent Posts
-
March 18, 2021
C语言最简单的makefile
makefile 的默认target是第一个 target ,所以把all放到最前面才行。这个makefile要学习一下才行SRC = .CFLAGS = -O2 -Wall -g -I../include LDFLAGS = -Wl,-rpath="/usr/mylibdir" -L/usr/mylibdirLIBS = -lmylibCC := gccAR := arobjs = main.o util.o \ test.ohdrs = test.hall:...
-
February 19, 2021
Golang的抓包程序
https://github.com/google/gopacket例子在example目录下https://github.com/google/gopacket/blob/master/examples/afpacket/afpacket.go
-
January 12, 2021
Vim Go插件和filetype plugin
https://github.com/fatih/vim-go最新的这个版本 vim-go的 保存文件是自动gofmt格式化的功能没起作用,执行:GoFmt是可以的格式化话,说明gofmt.exe的路径没有问题。看代码应该是.vim\bundle\vim-go\ftplugin\go.vim 文件里面的 autocmd BufWritePre <buffer> call go#auto#fmt_autosave()这一行代码起作用的,但这个好像没有加载。gvim默认集成了C:...
-
January 12, 2021
Bpftrace要取代systemtap了吗
https://lwn.net/Articles/793749/ Kernel analysis with bpftrace https://kernel.taobao.org/2020/01/Kernel-analysis-with-bpftrace/https://github.com/iovisor/bpftracehttps://www.brendangregg.com/blog/2021-07-03/how-to-add-bpf-observabili...
-
January 12, 2021
Centos 8.3的tcp Bbr还没有合并上游的wifi场景的补丁
高速wifi场景下ack包积聚发送问题,导致传输速度不稳定吧。https://groups.google.com/forum/#!topic/bbr-dev/8pgyOyUavvY1: Higher throughput for WiFi and other paths with aggregationAggregation effects are extremely common with WiFi, cellular, and cable modem link technologies...
-
December 07, 2020
Fuse文件系统启用page cache
fuse文件系统默认没有启用page cache的,需要配置mount选项 High-level mount options: These following options are not actually passed to the kernel but interpreted by libfuse. They can only be specified for filesystems that use the high-level libfuse AP...
-
November 23, 2020
Linux内核检查ip是否为本地接口的ip
内核有一个函数inet_lookup_ifaddr_rcu,但这个函数没有导出的,也可以inet_addr_type_dev_table这个获取路由项是否为本地ip来判断。ip_dev_find应该可以可以通过查找ip在哪个设备上来确人,不过这个麻烦些完了需要dev_put(dev);释放掉资源/* called under RCU lock */struct in_ifaddr *inet_lookup_ifaddr_rcu(struct net *net, __be32 addr){ ...
-
November 16, 2020
Openssl生成golang Grpc 自签名tls的v3_req证书
生成根证书的私钥```text选的椭圆曲线算法,后面生成server和client端的时候类似$ openssl ecparam -genkey -name prime256v1 -out root_ca.key也可以选RSA的吧,向下面这样$ openssl genrsa -out ca.key 2048``` 生成根证书x509格式(公钥)```text$ openssl req -new -x509 -days 40000 -key root_ca.key -out root_...
-
October 28, 2020
Golang修改设置全局默认resolver的dns的ip地址
package mainimport ( "context" "fmt" "net")func CloudflareDialer(ctx context.Context, network, address string) (net.Conn, error) { d := net.Dialer{} return d.DialContext(ctx, "udp", "1.1.1.1:53")}func main() { net.DefaultResolver.PreferGo = true n...
-
October 07, 2020
Golang的reflect包要使用unsafe才能修改结构的私有成员的值
poll.FD.ZeroReadIsEOF 控制文件读入0字节时,是否单做EOF错误返回, 因为linux的串口文件设置了超时会返回0字节,但不想把他单做错误来处理。func DisableiZeroReadIsEOF(conn Conn) { serialPort, ok := conn.(*serial.Port) if !ok { return } p := reflect.ValueOf(serialPort) if !p.IsValid() { return } f := p...