Skip to content

Instantly share code, notes, and snippets.

Avatar

ihc童鞋@提不起劲 ihciah

View GitHub Profile
@ihciah
ihciah / pool.rs
Last active April 23, 2023 09:57
Rust Simple Pool
View pool.rs
//! 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
View 1-Compile.md

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
View README.md

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
View README.md

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
View README.md

额外 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
View global_cache.rs
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
View README.md

Configure v2ray with cloudflare with docker and docker-compose

  • caddy-*: http server related files
  • v2ray-*: v2ray related files
  • forword-*: files to relay requests
@ihciah
ihciah / README.MD
Last active June 4, 2023 01:23
V2ray MTProto through Shadowsocks
View README.MD

V2ray MTProto through Shadowsocks

Why use it

The MTProto is easy to block; shadowsocks is hard to identify but cannot work without a client.

You can deylop this docker image to run a relay inside the firewall (China/Russia etc.), it provide a MTProto and all the packets will be sent through shadowsocks protocol.

How to run

@ihciah
ihciah / portfw.go
Last active May 21, 2019 09:34
Port forward for SMB
View portfw.go
package main
import (
"flag"
"io"
"log"
"net"
"os"
"time"
)
@ihciah
ihciah / ss-test.py
Created January 9, 2019 11:01
speed-test
View ss-test.py
import requests
import time
proxies_original = {
'http': 'socks5://127.0.0.1:18081',
'https': 'socks5://127.0.0.1:18081'
}
proxies_my = {
'http': 'socks5://127.0.0.1:18080',
'https': 'socks5://127.0.0.1:18080'
}