Windows VPN Hotspot
在 Windows 上将当前的 V2Ray 代理通过网络热点(Wi-Fi 热点)分享给其他设备(如手机、Switch、其他电脑),通常有两种主要方法。
方法一最简单、最推荐,不需要复杂的 Windows 网络配置。
方法一:利用 V2Ray 客户端的“允许局域网连接”(最推荐)
这个方法是通过局域网 IP 和端口进行分享。无论你是用 v2rayN 还是 Clash 等客户端,原理都一样。
步骤 1:开启客户端的局域网共享
- 打开你的 V2Ray 客户端(以 v2rayN 为例)。
- 在底部状态栏或设置中,勾选 “允许来自局域网的连接”(Allow Lan)。
- 记下此时客户端的 Http 端口(通常默认是
10809或10811,在客户端主界面底部可以看到)。
步骤 2:开启 Windows 热点
- 打开 Windows 设置 -> 网络和 Internet -> 移动热点。
- 打开移动热点开关,并记住(或设置)热点的名称和密码。
- 让你的其他设备(如手机)连接这个 Windows 热点。
步骤 3:获取电脑的局域网 IP
- 在电脑上按下
Win + R,输入cmd回车打开命令行。 - 输入
ipconfig回车。 - 找到 “无线局域网适配器 本地连接”* 或 “移动热点” 对应的 IPv4 地址(通常是
192.168.137.1或192.168.xx.x)。
步骤 4:在其他设备上配置代理
- 拿着连接了热点的手机或 Switch,进入当前 Wi-Fi 的高级设置。
- 将 代理 改为 手动。
- 输入以下信息:
- 服务器/主机名:填 步骤3 查到的电脑 IP(例如
192.168.137.1)。 - 端口:填 步骤1 记下的 V2Ray Http 端口(例如
10809)。
- 保存即可。现在该设备就可以通过电脑的 V2Ray 上网了。
方法二:使用全局虚拟网卡(适合 Switch/PS5 等无法设置代理的设备)
如果你的外接设备(如某些游戏机)不支持手动输入代理端口,或者你想让所有连接热点的流量自动走代理,可以使用虚拟网卡(TUN 模式)。
步骤 1:客户端开启 TUN 模式
- 建议使用支持 TUN 模式 的客户端(如 v2rayN 的新版本、Clash Verge Rev 或 sing-box)。
- 在客户端中开启 开启 TUN 模式(开启后,系统会多出一个虚拟网卡,把所有流量接管)。
步骤 2:开启 Windows 热点
- 同方法一,在 Windows 设置里把“移动热点”打开。
步骤 3:设置网络适配器共享(关键)
- 按下
Win + R,输入ncpa.cpl回车,打开“网络连接”窗口。 - 找到你的 虚拟网卡(通常带有
sing-box、Clash、v2ray或TAP/TUN字样)。 - 右键该虚拟网卡 -> 选择 属性。
- 切换到 共享 选项卡:
- 勾选 “允许其他网络用户通过此计算机的 Internet 连接来连接”。
- 在“家庭网络连接”下拉菜单中,选择你 Windows 热点对应的网卡名称(通常叫
本地连接* xx或Microsoft Wi-Fi Direct Virtual Adapter)。
- 点击确定保存。
⚠️ 注意:使用方法二时,连接热点的设备不需要在 Wi-Fi 里设置任何代理端口,直接连接就能直接翻墙。
Workspace Setup
Steps to set up my personal workspace.
V2Ray Server - Ubuntu
How to set up v2ray server on Ubuntu.
https://github.com/v2fly/fhs-install-v2ray
v2fly
1 | // 安裝執行檔和 .dat 資料檔 |
ufw
1 | ufw allow http |
config
1 | vi /usr/local/etc/v2ray/config.json |
server
1 | { |
Note: remember to set the value inbounds.settings.clients.id correctly.
tls (acme.sh)
1 | DOMAIN_NAME=songzy.cc |
install
1 | apt install socat |
register
1 | acme.sh --register-account -m songzy_thu@163.com |
issue & installcert
1 | acme.sh --issue -d $DOMAIN_NAME --standalone -k ec-256 --debug |
1 | acme.sh --installcert -d $DOMAIN_NAME --fullchainpath /usr/local/etc/v2ray/$DOMAIN_NAME.cer --keypath /usr/local/etc/v2ray/$DOMAIN_NAME.key --ecc |
renew
1 | acme.sh --renew -d $DOMAIN_NAME --force --ecc --debug |
vmess aead
1 | env v2ray.vmess.aead.forced=false /usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json |
ip check
WSL HTTP Proxy
Set up http/https proxy inside WSL.
https://learn.microsoft.com/en-us/windows/wsl/networking
Port
If the v2ray has the following setting:
1 | 本地:[socks:10808] | [http:10809] |
Then:
1 | PROXY_PORT=10811 |
NAT
1 | WINDOWS_HOST=`cat /etc/resolv.conf|grep nameserver|awk '{print $2}'` |
Mirrored
In C:\Users\songz\.wslconfig of Windows host:
1 | [experimental] |
Then in WSL2:
1 | WINDOWS_HOST=localhost |
Code Server
How to install and use Code Server.
Motivation
This way, we can put our project codes in remote cloud machines, and access it from a browser in any other computers.
NOTE: Without the “browser” requirement, you can use vscode directly to access files in remote cloud machine from any computers.
Install
https://coder.com/docs/code-server/install#debian-ubuntu
1 | export VERSION=4.92.2 |
1 | sudo dpkg -i code-server_${VERSION}_amd64.deb |
1 | sudo systemctl enable --now code-server@$USER |
SSH Port Forwarding
Remote Host
https://coder.com/docs/code-server/guide#port-forwarding-via-ssh
1 | # Replaces "auth: password" with "auth: none" in the code-server config. |
1 | sudo service code-server@$USER status |
Local Client
1 | set -x |
Then, you can visit http://localhost:8080 in your local machine to access the code server started in remote machine.
Extensions
Some extensions are not avaliable in the default extension market, you might need to install them manually. Let us use the “C/C++” extension as an example.
First, find the extension download link from the “Version History” tab of the vscode extension marketplace:
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools&ssr=false#version-history
Then, in your remote machine, use wget to download the extension:
1 | wget https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/cpptools/1.23.0/vspackage\?targetPlatform\=linux-x64 |
The file downloaded by wget (or curl) cannot be installed directly since it is in a gzip format. So we need to first rename it with suffix .gz and then gunzip it:
1 | mv vspackage\?targetPlatform=linux-x64 ms-vscode.cpptools-1.10.3@linux-x64.vsix.gz |
Then, you can install the ms-vscode.cpptools-1.10.3@linux-x64.vsix either from commandline or search for the “Extensions: Install from VSIX” after typing “Shift-Command-P”.
Alternatives
- vscode.dev: This is a lightweight vscode running in browser to manipulate local files.
- GitHub Codespaces: This is not free, and has network connection issue (you know it) from time to time.
Laptop Collection
A collection of my personal laptop devices.
OMEN 9 Slim (2023)
- CPU: Intel Core i9-13900HX
- GPU: NVIDIA GeForce RTX 4060 8G
- Memory: 16G
- Storage: 1T SSD
MacBook Air M1 (2020)
- Chip: M1
- Memory: 16G
- Storage: 1T SSD
ThinkPad T470 (2017)
- CPU: Intel Core i5-7200U
- GPU: NVIDIA GeForce 940MX 2GB
- Memory: 16G
- Storage: 128G SSD + 500G HDD
V2Ray Client - Mac
Prefer to use V2rayN for Mac.
GitBook
GitHub Repo Index
An index of my GitHub repositories.
Cloudtop Collection
A collection of my personal cloudtop devices.
- songzy.cc
- US
- DigitalOcean
- NameCheap
- songzy.xyz
- Japan
- Vultr
- NameCheap
- songzy.cool
- Korean
- Vultr
- NameCheap
- maomaosenlin.cc
- China
- Tencent Cloud
- Tencent Cloud
Octopress 3.0
Basic usage of Octopress.
ZSH
Basic usage of zsh.
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
To view all avaliable zsh themes:
1 | ls $ZSH/themes/ |
To set zsh theme:
1 | ZSH_THEME=random |
To view the current selected random theme:
1 | echo $RANDOM_THEME |
To view the config of a specific zsh theme:
1 | vi $ZSH/themes/robbyrussell.zsh-theme |
T470 Ubuntu GPU
Enable GPU on ThinkPad T470, which runs Kubuntu.
V2Ray Client - Windows
Set up v2ray client on Windows.
V2Ray Client - Ubuntu
Set up v2ray client on Ubuntu.
ChatGPT
大陆如何注册使用 ChatGPT,并将其升级到 Plus.
- 首先需要翻墙,其次要用不那么著名的vps提供商。
- 随机试了两个 vultr 的日本区和美区的ip都提示 blocked
- 据说 bandwagon 也会 blocked
- 解决法案:使用了 digitalocean 的美区机器成功访问
注册:
- 使用了 Gmail 邮箱
- 国外手机号收验证码
- 据说 Google Voice 提供的虚拟手机号是不行的
- 解决法案:使用了 sms activate 成功收到了验证码
- 可以支付宝充值2美元
- 使用了印度尼西亚区的号码
升级 Plus:
- 国内银行发行的 visa, AE 似乎都不行
- 测试了中国银行的 visa 和招商银行的 AE 都提示 denied
- 解决方案:下载 ChatGPT 的 iOS App 使用 Apple Pay 充值
- iOS 设备也需要翻墙,并在设置中修改所在地区为美国
- 需要美区的 Apple ID
- 下载 Shadowrocket 用于翻墙
- 下载 ChatGPT
- 要求 iOS 版本 >16.1:也就是 iPad Air 2 不行的意思
- 美区 Apple ID 需要绑定美区 Paypal
- 美区 Paypal 可以绑定国内银行发行的 visa,AE 卡
VSCode
https://github.com/microsoft/vscode
Settings
1 | { |
Wear OS
Google Pixel Watch app will crash on Honor 20 Pro with HarmonyOS 2.0.0.
Windows Env Var
Built-in envrionment variables on Windows.
https://en.wikipedia.org/wiki/Environment_variable#Windows
| Variable | Locale specific | Windows XP (CMD) | Windows Vista and later (CMD) |
|---|---|---|---|
| %ALLUSERSPROFILE% | Yes | C:\Documents and Settings\All Users | C:\ProgramData |
| %APPDATA% | Yes | C:\Documents and Settings{username}\Application Data | C:\Users{username}\AppData\Roaming |
| %CommonProgramFiles% | Yes | C:\Program Files\Common Files | C:\Program Files\Common Files |
| %CommonProgramFiles(x86)% | Yes | C:\Program Files (x86)\Common Files (only in 64-bit version) | C:\Program Files (x86)\Common Files (only in 64-bit version) |
| %CommonProgramW6432% | Yes | %CommonProgramW6432% (not supported, not replaced by any value) | C:\Program Files\Common Files (only in 64-bit version) |
| %COMPUTERNAME% | No | {computername} | {computername} |
| %ComSpec% | No | C:\Windows\System32\cmd.exe | C:\Windows\System32\cmd.exe |
| %HOMEDRIVE% | No | C: | C: |
| %HOMEPATH% | Yes | \Documents and Settings{username} | \Users{username} |
| %LOCALAPPDATA% | Yes | %LOCALAPPDATA% (not supported, not replaced by any value) | C:\Users{username}\AppData\Local |
| %LOGONSERVER% | No | \{domain_logon_server} | \{domain_logon_server} |
| %PATH% | Yes | C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} | C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} |
| %PATHEXT% | No | .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.WSF;.WSH | .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc |
| %ProgramData% | Yes | %ProgramData% (not supported, not replaced by any value) | %SystemDrive%\ProgramData |
| %ProgramFiles% | Yes | %SystemDrive%\Program Files | %SystemDrive%\Program Files |
| %ProgramFiles(x86)% | Yes | %SystemDrive%\Program Files (x86) (only in 64-bit version) | %SystemDrive%\Program Files (x86) (only in 64-bit version) |
| %ProgramW6432% | Yes | %ProgramW6432% (not supported, not replaced by any value) | %SystemDrive%\Program Files (only in 64-bit version) |
| %PROMPT% | No | Code for current command prompt format, usually $P$G | Code for current command prompt format, usually $P$G |
| %PSModulePath% | %PSModulePath% (not supported, not replaced by any value) | %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\ | |
| %PUBLIC% | Yes | %PUBLIC% (not supported, not replaced by any value) | %SystemDrive%\Users\Public |
| %SystemDrive% | No | C: | C: |
| %SystemRoot% | No | The Windows directory, usually C:\Windows, formerly C:\WINNT | %SystemDrive%\Windows |
| %TEMP% and %TMP% | Yes | %SystemDrive%\Documents and Settings{username}\Local Settings\Temp | %SystemRoot%\TEMP (for system environment variables %TMP% and %TEMP%), %USERPROFILE%\AppData\Local\Temp (for user environment variables %TMP% and %TEMP%) |
| %USERDOMAIN% | No | {userdomain} | {userdomain} |
| %USERNAME% | No | {username} | {username} |
| %USERPROFILE% | Yes | %SystemDrive%\Documents and Settings{username} | %SystemDrive%\Users{username} |
| %windir% | No | %SystemDrive%\WINDOWS | %SystemDrive%\Windows |
WSL Export/Import
WSL2 export and import.
1 | PS C:\Users\songzy> wsl --list |
Config Default User
Method 1:
1 | Function WSL-SetDefaultUser ($distro, $user) { Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq $distro | Set-ItemProperty -Name DefaultUid -Value ((wsl -d $distro -u $user -e id -u) | Out-String); }; |
Method 2:
1 | ubuntu2004 config --default-user songzy |
OMEN WSL GPU
Enable GPU on OMEN, which runs Win11 and WSL2.
WSL vDisk
WSL2 vdisk management.
WSL 2 uses a Virtual Hard Disk (VHD) to store your Linux files. In WSL 2, a VHD is represented on your Windows hard drive as a .vhdx file.
The WSL 2 VHD uses the ext4 file system. This VHD automatically resizes to meet your storage needs and has an initial maximum size of 256GB.
ncdu
1 | du -h --max-depth=1 . | sort -h |
or
1 | sudo apt install ncdu |
Then press ? for shortcuts.
“ncdu” stands for “NCurses Disk Usage”, where “NCurses” stands for “new curses”, where “curses” is a pun on the term “cursor optimization”, which is a library for TUI.
- https://en.wikipedia.org/wiki/Ncdu
- https://en.wikipedia.org/wiki/Ncurses
- https://en.wikipedia.org/wiki/Curses_(programming_library)
detail vdisk
1 | wsl --shutdown |
1 | DISKPART> select vdisk file="C:\Users\songzy\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx" |
Windows use first 5 letters of our e-mail addresses as the name of our user account folders.
1 | DISKPART> detail vdisk |
compact vdisk
1 | # DISKPART> attach vdisk readonly |
expand vdisk
https://docs.microsoft.com/en-us/windows/wsl/vhd-size
1 | DISKPART> expand vdisk maximum=<sizeInMegaBytes> |
1 | wsl.exe -l -v |
1 | sudo mount -t devtmpfs none /dev |
Windows Terminal Font
Fixing font/color issue I came across when using Windows terminals.
Vim
Basic usage of vim.
.vimrc
1 | set ignorecase |
Apache
Basic usage of apache2.
https://ubuntu.com/tutorials/install-and-configure-apache
Install
1 | sudo apt update |
Web Page
1 | ls /var/www/html/index.html |
Config
1 | cd /etc/apache2/sites-available/ |
Start Server
1 | sudo a2ensite gci.conf |
Log
1 | tail -f /var/log/apache2/error.log |
School Projects
A summary of what I have learnt in university.
- 2013夏
- 汇编
- Bomb lab, Buf lab
- MIPS (Microprocessor without Interlocked Pipeline Stages)
- 汇编
- 2013秋(大二)
- 程序设计与算法基础
- 虚拟宠物
- 程序设计与算法基础
- 2014春(大二)
- 计算机组成与系统结构
- Y86流水线处理器
- 计算机组成与系统结构
- 2014夏
- 安卓
- 计步器
- 安卓
- 2014秋(大三)
- 高等计算机图形学
- 光线追踪
- 网格简化
- 机器学习
- 广告 CTR 预测
- 大数据算法与模型
- Randomness Extractor
- 编译原理
- Decaf (Decaf is a Java-like object-oriented programming language)
- 高等计算机图形学
- 2015春(大三)
- 操作系统
- Nachos (Not Another Completely Heuristic Operating System)
- Paxos
- 操作系统
- 2015夏
- SRT
- Topic Model
- SRT
- 2015秋(大四)
- 软件工程
- 安卓车载蓝牙
- 软件工程
- 2016秋(研一)
- 分布式数据库系统
- EtherLend
- 分布式数据库系统
- 2017春(研一)
- 分布式系统导论
- Raft
- 计算几何
- 平面最大空凸点集
- 高级机器学习
- 论文引用数预测
- 计算机网络安全技术
- Eternal Blue - Wanna Cry
- 分布式系统导论
Xiaomi
Xiaomi 刷系统。
DiskPart
Basic usage of diskpart on windows.
EFI
http://linuxbsdos.com/2015/09/05/how-to-delete-grub-files-from-a-boot-efi-partition-in-windows-10/
1 | % These commands are used to identify and select the hard drive |
1 | diskpart |
Windows
Windows 查看磁盘分区格式
- 按下
Win+R打开运行,输入cmd,打开命令提示符; - 输入
diskpart按回车执行,切换到 DISKPART 命令,输入list disk,按回车; - 查看最后一列的GPT,如果有*号则为GPT,如果没有则为MBR。
Nexus6P
Nexus 6P 刷系统。
Ubuntu Service Management
Service/Job management on Ubuntu.
supervisor
- reread - Reread supervisor configuration. Do not update or restart the running services.
- update - Restart service(s) whose configuration has changed. Usually run after ‘reread’.
- reload - Reread supervisor configuration, reload supervisord and supervisorctl
- restart - Restart service(s)
service
1 | service ssh status |
tee
1 | tee |
In computing, tee is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input.
将 Android 上微信的聊天记录导出为 txt.
xnheulpb
http://www.flypy.com/bbs/forum.php?mod=viewthread&tid=166
xnheulpb.reg
1 | Windows Registry Editor Version 5.00 |
LaTeX
Basic usage of LaTeX.
Tencent SNG
腾讯 SNG 校招面试分享。
- 项目中的有趣点或难点
- xgboost 和 lr 的优缺点
- C++ 虚函数的实现
- 线程和进程的区别
- 在模型中哪些 feature 最有用
- 算法题:将 1 到 m*n 按照螺旋方式填满 m * n 的矩阵。
Google 暑期实习电话面算法题。
Phone Interview
Compare keyboard events sequences
1 | # abc123\b123\b -> abc1212 |
WAP
WAP 校招面试算法题。
Round 0
Round 1
Round 2
Strobogrammatic Number I, II, III
Round 3
- 勾股定理
grep,find
Round 4
- Small Chat
Tencent IEG
腾讯互娱校招面试算法题。
这个也是 LeetCode 原题:Integer Break
给定 $m\in N$,
$\max x_1\cdot x_2\dots x_{n-1}\cdot x_n$
s.t. $x_1+x_2+…+x_n = m$ and $x_i \in N $.
(面试官给的题目里 $m = 25$)
下面我们介绍两种解法,一种是使用动态规划的编程解,另一种是直接手算出答案的数学解。
Ubuntu Package Management
Random Variable Expectation
一枚硬币, 扔出 H 的概率为 $p$, T 的概率为 $q$, 计算首次扔出 $T\underbrace{H\dots H}_{k}$ 所需投掷次数的数学期望。
Poison and Prisoner
10000桶酒,其中1桶是毒酒;48小时后要举行酒会;毒酒喝下去会在之后的第23-24小时内毒死人。
国王决定用囚犯来试酒,不介意囚犯死多少,只要求用最少的囚犯来测试出哪一桶是毒酒。
问最少需要多少囚犯才能保证找出毒酒?
Bash
Basic usage of Bash.
Docker
Basic usage of Docker.
Git
Basic usage of git.
Tmux
Basic usage of tmux.
Apktool
Android RE.