Skip to content

Instantly share code, notes, and snippets.

View xh4n3's full-sized avatar
🎯
Focusing

Shane Xie xh4n3

🎯
Focusing
  • Alibaba Cloud
  • Hangzhou, China
  • X @xh4n3
View GitHub Profile
@xh4n3
xh4n3 / arp_announcement.bt
Created July 7, 2022 02:39
traces the ARP requests in containernetworking/plugins issue#756
#!/usr/bin/env bpftrace
/*
* arp_announcement traces inetdev_event/br_handle_frame/br_set_state.
*
* Background:
* 1. This script addresses https://github.com/containernetworking/plugins/issues/756
* 2. br state definitions at https://github.com/torvalds/linux/blob/v4.19/include/uapi/linux/if_bridge.h#L49-L53
* 3. inetdev_event event type definitions at https://github.com/torvalds/linux/blob/v4.19/include/linux/netdevice.h#L2413-L2450
*
* Usage:
@xh4n3
xh4n3 / trace_dns_drops.bt
Created November 1, 2021 08:41
trace_dns_drops traces DNS drops by ip_vs_in and ipt_do_table.
#!/usr/bin/env bpftrace
/*
* trace_dns_drops traces DNS drops by ip_vs_in and ipt_do_table.
*
* Background:
* 1. Before 5.9, ip_vs_in can cause UDP packets drops when IPVS RS deleted
* and source port reused, See https://github.com/kubernetes/kubernetes/issues/71514 for more details.
* 2. Misconfiguration of iptables can cause DNS drops.
*
* Usage:
@xh4n3
xh4n3 / checkPorts.sh
Created September 23, 2016 08:42
check ports opened in docker container of Host mode
#!/bin/sh
# Port Exporter
#
# Description:
# When docker containers are running in Host mode, thus /proc/[int]/net are shared across all containers.
# This script mimicks the "netstat -nlp".
# Firstly it finds all fds in current container into $FDS, then traverses /proc/[int]/net/tcp and /proc/[int]/net/tcp6 to collect fds. If any fd is in $FDS, the port is presumed to be opened in current container.
#
# if SKIP_PORT_CHECK is set, skip port check
@xh4n3
xh4n3 / bash-cheatsheet.sh
Created September 22, 2016 09:09 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@xh4n3
xh4n3 / etcd.go
Last active June 7, 2016 14:33
Client Set returns ErrClusterUnavailable but succeed
package main
import (
"github.com/coreos/etcd/client"
"golang.org/x/net/context"
"log"
"time"
)
var (
<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-with-addons-0.14.7.min.js"></script>
<script src="https://fb.me/react-dom-0.14.7.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://npmcdn.com/redux@latest/dist/redux.min.js"></script>
@xh4n3
xh4n3 / get-watchers.js
Created March 3, 2016 09:05 — forked from kentcdodds/get-watchers.js
Get Watchers of element and its children
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
@xh4n3
xh4n3 / surge.conf
Created October 5, 2015 11:53 — forked from janlay/README.md
Yet another config for Surge.app
# This config file was created for myself (@janlay). You may want to add or remove some rules to make efficient use of the Internet.
[General]
# warning, notify, info, verbose
loglevel = notify
# bypass HTTP persistent connections
bypass = e.crashlytics.com
[Proxy]
# http, https, socks5
@xh4n3
xh4n3 / Surge.md
Last active June 16, 2020 07:42
Surge

Feature

  • 替代 PAC,实现根据规则区分选择代理线路
  • 支持 SOCKS5 和 Shadowsocks 协议
  • 完整支持所有的 Shadowsocks 加密方式 (table, rc4-md5, salsa20, chacha20, aes-256-cfb, aes-192-cfb, aes-128-cfb, bf-cfb, cast5-cfb, des-cfb, rc2-cfb, rc4, seed-cfb)
  • 全面支持双向 HTTP Keep-Alvie
  • 快,各种黑科技加速
  • 直接临时修改某个域名的访问规则 (暂时仅 Mac 版本)
  • 支持使用 GeoIP 规则决定线路

Usage