ed557

学习笔记

2023年3月19日 #

golang  实现 sync.WaitGroup wait() 方法 超时 自动释放

摘要: 思路是把 wg.wait() 放到一个协程里,通过chan向外发送完成信号。 外层通过一个select超时结构来控制最大超时时间。 func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool { c := make(chan st 阅读全文

posted @ 2023-03-19 14:55 ed557 阅读(691) 评论(0) 推荐(0) 编辑

2022年11月15日 #

libcurl 发送HTTP请求时获取目标IP

摘要: #include "curl/curl.h" int main() { char* ip; CURL* curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, "https://baidu.com"); CURLcode res = 阅读全文

posted @ 2022-11-15 22:55 ed557 阅读(130) 评论(0) 推荐(0) 编辑

golang发送HTTP请求时获取目标IP (server ip)

摘要: golang net/http库在发送http请求时会通过调用net下的Dialer建立TCP连接, net.Dialer 会在发起连接前执行通过ControlContext字段传入的一个函数, 我们可以通过这个函数获取ip、端口和网络名等信息。 https://cs.opensource.goog 阅读全文

posted @ 2022-11-15 21:24 ed557 阅读(609) 评论(0) 推荐(0) 编辑

2022年2月6日 #

Qt实现定时退出

摘要: 可以使用QTimer的静态方法singleShot来触发QApplication对象的quit方法,就可以实现定时退出了。 #include <QApplication> #include <QTimer> int main(int argc, char *argv[]) { QApplicatio 阅读全文

posted @ 2022-02-06 02:36 ed557 阅读(518) 评论(0) 推荐(1) 编辑

2022年2月5日 #

openssl EVP_CIPHER_CTX_set_padding 只支持 pkcs7/pkcs5

摘要: openssl中padding的一个坑,现在在openssl里面AES的padding事实上只支持pkcs7/pkcs5这一种padding模式。 今天被错误的资料误导了,使用EVP接口实现对称加密的时候有个EVP_CIPHER_CTX_set_padding()函数,看上去能给加密上下文ctx设置 阅读全文

posted @ 2022-02-05 21:19 ed557 阅读(1658) 评论(0) 推荐(0) 编辑

导航