Skip to content

Instantly share code, notes, and snippets.

@ihciah
ihciah / custom.css
Created April 20, 2024 15:22 — forked from Ynng/custom.css
vscode vtuber logo
.editor-group-watermark > .letterpress{
background-image: url("https://raw.githubusercontent.com/Aikoyori/ProgrammingVTuberLogos/main/VSCode/VSCode.png") !important;
opacity: .75;
}
@ihciah
ihciah / Dockerfile.master
Created October 3, 2023 06:36
Tinc Dockerfile
FROM alpine:latest
ENV DEV_PACKAGES="build-base make zlib-dev lzo-dev libressl-dev linux-headers ncurses-dev readline-dev"
ENV TINC_VERSION=4c6a9a9611442f958c3049a566ac4369653978e9
RUN cd /tmp && \
wget https://github.com/gsliepen/tinc/archive/${TINC_VERSION}.tar.gz && \
tar -xzf ${TINC_VERSION}.tar.gz && \
cd tinc-${TINC_VERSION} && \
.ci/deps.sh && \
@ihciah
ihciah / README.md
Last active December 31, 2023 18:53
Policy Routing VPN with Tinc and Nftables

Policy Routing VPN with Tinc and Nftables

This is just a personal backup, but if it helps you, that's even better.

Target

  1. Make linux work as a router.
  2. For domestic targets, connect them directly.
  3. For traffic that need to bypass the firewall, use VPN.

Setup

@ihciah
ihciah / pool.rs
Last active April 23, 2023 09:57
Rust Simple Pool
//! A generic but simple pool implemention.
use std::sync::{Arc, Weak};
use parking_lot::Mutex;
/// A Vec based buffer pool.
#[derive(Default)]
pub struct Pool<T, F = fn() -> T> {
cached: Vec<T>,
@ihciah
ihciah / 1-Compile.md
Last active August 5, 2022 03:29
Try Rust for Linux

My note for trying rust-for-linux.

Prepare environment

Here I take arch linux as an example, and I assume you already installed rust and put ~/.cargo/bin inside your PATH.

cd /some/where

# Install requirements
sudo pacman -Syuu --noconfirm bc bison curl clang diffutils flex git gcc llvm libelf lld ncurses make qemu-system-x86 cpio
export MAKEFLAGS="-j32"
@ihciah
ihciah / README.md
Created June 5, 2022 04:00
AX88U Network Isolation

AX88U 网络隔离

物理端口映射:eth0 - WAN, eth1~4 - LAN4~1。

默认梅林会将 eth1~7 组成 br0。要做独立的网络就要将 Guest 网络需要用到的 eth 接口从 br0 里摘掉,然后加入到新的 br 里。 这里摘掉了 eth1(对应 LAN4)、wl0.2(第二个 2.4G 访客网络)和 wl1.2(第二个 5G 访客网络)。

之后利用 iptables 允许 Guest 网络访问公网,但禁止其向 br0 主动通信即可。

三个脚本 +x 后放 /jffs/scripts 里(管理页面也要开启 jffs 功能),dnsmasq.conf.add/jffs/configs 里。

@ihciah
ihciah / README.md
Created April 18, 2022 08:45
Ansible playbook to upgrade all packages

Ansible playbook to upgrade packages

Modify hosts and run ansible-playbook -i hosts upgrade.yaml.

Note: On debain to make reboot detect work, you may install unattended-upgrades.

@ihciah
ihciah / README.md
Created April 9, 2022 10:36
CHN Route Additional

额外 CHN Route

主要维护额外的 CHN Route ip 段。目前仅有腾讯游戏相关。

加载

在 load 了 chn 之后,额外使用 ipset restore -f chn_additional.ipset 将这些条目加入到已有的 chn ipset 中。

腾讯游戏

软路由上使用 CHN Route 导致王者荣耀延迟爆炸,tcpdump 一通操作最后筛选出来几个腾讯游戏的 ip 段。 这些 ip 段并不是直接用于游戏对局的,但他们会影响对局服务器 ip 分配,也算是 DNS 吧。

@ihciah
ihciah / global_cache.rs
Created January 19, 2022 08:51
Rust Global Cache
use std::{borrow::Borrow, cell::UnsafeCell, hash::Hash, ptr::NonNull, sync::RwLock};
use fxhash::FxHashMap;
// const CACHE: Cache = unsafe { Cache::new() };
struct Cache<K, V> {
data: UnsafeCell<NonNull<RwLock<FxHashMap<K, V>>>>,
}
@ihciah
ihciah / README.md
Last active January 18, 2023 19:28
V2ray with cloudflare websocket

Configure v2ray with cloudflare with docker and docker-compose

  • caddy-*: http server related files
  • v2ray-*: v2ray related files
  • forword-*: files to relay requests