Proxy Test

socks5 # 监听1080为代理地址 ssh -f -N -D 0.0.0.0:1080 root@127.0.0.1 # test curl -v -k -x "socks5://USER:PASSWORD@HOSTIP:1080" https://baidu.com socat # forward 访问目标服务 socat TCP4-LISTEN:<本地端口>,bind=<监听本机的地址>,reuseaddr,fork TCP:<目标地址>:<目标端口> 3proxy 三方容器: 3128 http, 1080 socks5 $ docker run --rm -d \ -p "3128:3128/tcp" \ -p "1080:1080/tcp" \ tarampampam/3proxy:latest

September 23, 2022 · 1 min · Peter

Fastapi

middleware or dependency 官方说明 场景: 项目使用了sqlite+sqlalchemy,暂时不支持async方式访问,但是fastapi的middleware的 __call__ 方法必须是async,如果在middleware中去做用户会话管理等和db相关的io操作可能导致整个应用阻塞。 解决: 使用def的dependency组合完成相关操作 官方对于两个组件的对比说明: middleware 代码多一些,更复杂一些 必须是async方法 任何需要IO代码的添加都可能导致整个应用速度变慢或者阻塞 每个请求都会执行相关代码,如果是db的话,即使路由函数不需要也会创建

July 27, 2022 · 1 min · Peter

Playwright

image docker pull mcr.microsoft.com/playwright/python:v1.20.0-focal 本地环境 pip install playwright -i https://pypi.tuna.tsinghua.edu.cn/simple playwright install

March 24, 2022 · 1 min · Peter

Docker Network

访问宿主机网络 host mode 使用host模式: docker run -d --network=host my-container:latest services: my-service: network_mode: host 添加hosts 使用--add-host选项添加映射到/etc/hosts文件,添加host.docker.internal到hosts docker run --rm -it --add-host host.docker.internal:host-gateway goexpect bash hosts in container root@00e0febe04e2:/app# cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 192.168.65.2 host.docker.internal 172.17.0.2 00e0febe04e2 访问宿主机网络 ssh root@host.docker.internal -p 2222

January 26, 2022 · 1 min · Peter

Neovim

了解 vim text object概念 installation brew install neovim brew install font-hack-nerd-font # 检索 brew install ripgrep fzf # lsp format brew install efm-langserver lazy-nvim tokyonight lualine barbecue bufferline indent_blankline gitsigns.nvim alpha-nvim nvim-telescope https://github.com/nvim-treesitter/nvim-treesitter https://github.com/nvim-treesitter/nvim-treesitter-textobjects https://github.com/neovim/nvim-lspconfig https://github.com/williamboman/mason.nvim https://github.com/hrsh7th/nvim-cmp lsp-format 参考 lazyvim kickstart nvim 整理中 my lazyvim config plugin use https://github.com/junegunn/vim-plug, install this first: sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' mkdir ~/.config/nvim/ nvim ~/.config/nvim/init.vim cat << EOF > ~/.config/nvim/init.vim call plug#begin('~/.vim/plugged') call plug#end() EOF write Plug 'fatih/vim-go' between call run :PlugInstall vim config is .vimrc language support use coc.nvim ...

December 27, 2021 · 1 min · Peter