NPM 镜像源配置
1# 当前用户
2npm config set registry https://registry.npmmirror.com
3
4# ROOT
5sudo npm config set registry https://registry.npmmirror.com1# 当前用户
2npm config set registry https://registry.npmmirror.com
3
4# ROOT
5sudo npm config set registry https://registry.npmmirror.comWindows 平台上配置文件路径如下:
%appdata%\Parsec\config.txt%ProgramData%\Parsec\config.txt在配置文件中写入代理配置:
1app_proxy = true以 Docker 为例,创建或编辑 /etc/systemd/system/docker.service.d/http-proxy.conf 文件,写入以下内容:
1[Service]
2Environment="ALL_PROXY=http://192.168.1.100:7890"
3Environment="HTTP_PROXY=http://192.168.1.100:7890"
4Environment="HTTPS_PROXY=http://192.168.1.100:7890"1git clone https://github.com/Dreamacro/clash.git
2cd clash
3go build
4sudo cp clash /usr/bin首先,需要知道两个基本知识:
即使只有一个参数也需要包装为 Tuple,例如一个 string:
1const auto arg1 = Glib::Variant<Glib::ustring>::create("hello world"); 2Glib::VariantContainerBase args = Glib::VariantContainerBase::create_tuple(arg1);
广播地址通常为网段的最后一个地址
通过对一个 socket 进行 ioctl(SIOCGIFBRDADDR) 即可获取广播地址。
1struct ifreq req;
2strcpy(req.ifr_name, "网卡名");
3ioctl(sock, SIOCGIFBRDADDR, &req);1#include <stdio.h>
2#include <ifaddrs.h>
3#include <arpa/inet.h>
4
5int main (void) Hook 是一种覆盖重写进程中符号的技术,在 Linux 中,通过环境变量 LD_PRELOAD 预加载包含同名符号的动态库即可实现。
1// 文件名: memcheck.c
2// 编译命令: gcc -o memcheck.so memcheck.c --shared -fPIC
3#define _GNU_SOURCE通过 fork 创建进程后,父进程可以使用 waitpid 来获取子进程的结束状态。
如果子进程先于父进程退出,而父进程没有调用 waitpid 的话,子进程将一直存续下去以保持结束状态可以被获取。
此时,子进程被称为僵尸进程。
如果子进程没有被调用 waitpid 而父进程退出了,此时子进程被称为孤儿进程,它会被 init进程(PID为1) 领养并调用waitpid回收。
有时我们并不关心子进程的结束状态,希望像 pthread_detach 一样示释放子进程。有以下两种方法可以实现:
1// gcc main.c -lpam
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <unistd.h>
7#include <termio.h>