Skip to content

Instantly share code, notes, and snippets.

View sorz's full-sized avatar
😱
AAHHH

Shell Chen sorz

😱
AAHHH
View GitHub Profile
@sorz
sorz / sockshttp.py
Created October 27, 2017 12:39
Forward SOCKSv5 requests to HTTP proxy.
#!/usr/bin/env python3
"""Forward SOCKSv5 requests to HTTP proxy.
Frontend: accept SOCKSv5 CONNECT request.
Backend: HTTP proxy with CONNECT support.
"""
import asyncio
import logging
from struct import pack, unpack
from ipaddress import IPv4Address, IPv6Address
@sorz
sorz / obfs4-client.py
Last active July 24, 2017 19:24
A simple SOCKSv5 wrapper for obfs4proxy.
#!/usr/bin/env python3
import asyncio
from struct import pack
from ipaddress import ip_address
TIMEOUT = 300
OBFS_BIN = '/usr/bin/obfs4proxy'
OBFS_EXEC_PARAMS = ['-enableLogging', '-logLevel', 'DEBUG']
@sorz
sorz / dnsrelay.py
Last active July 17, 2017 22:01
Forward DNS query (in UDP) to a set of servers in parallel, then send back the fastest reply and ignore others. TCP queries are directly forward to a fixed server.
#!/usr/bin/env python3
"""
Forward DNS query (in UDP) to a set of servers in parallel, then send back
the fastest reply and ignore others. TCP queries are directly forward to a
fixed server.
"""
import asyncio
import socket
### Keybase proof
I hereby claim:
* I am sorz on github.
* I am sorz (https://keybase.io/sorz) on keybase.
* I have a public key ASAiBGBuAlnIQQZyMycLhfqfUdOoLsNj_hHy0MlBUZjfZQo
To claim this, I am signing this object:
#!/usr/bin/python
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('0.0.0.0', 6000))
while True:
data, addr = s.recvfrom(1024)
s.sendto(str(addr[1]), addr)
@sorz
sorz / ipn-tib-mixed.user.js
Last active April 3, 2017 12:23
在 IPN 首页显示字谈字畅的节目列表。
// ==UserScript==
// @name IPN - Add Type is Beautiful episodes
// @namespace org.sorz.lab.ipn
// @include https://ipn.li/
// @include http://ipn.li/
// @version 5
// @grant GM_xmlhttpRequest
// @grant GM_getResourceURL
// @grant GM_addStyle
// @require http://code.jquery.com/jquery-3.2.0.min.js
@sorz
sorz / test
Last active April 3, 2017 12:22
test
aaaa
#!/usr/bin/bash
DIR=/path/to/www/public
DATA=/path/to/pms5003.rrd
TIME=$1
time=$(date '+%H\:%M\:%S')
rrdtool graph $DIR/pm-$TIME.svg \
--imgformat SVG \
@sorz
sorz / ipn-fix-show-list.user.js
Last active March 17, 2017 07:00
以固定顺序显示 ipn.li 首页的节目列表。
// ==UserScript==
// @name IPN - Fixed show list on homepage
// @namespace org.sorz.lab.ipn
// @include https://ipn.li/
// @version 1
// @grant none
// @require http://code.jquery.com/jquery-3.2.0.slim.min.js
// ==/UserScript==
let items = $('.showList > li').toArray();
@sorz
sorz / Transmission-DMHY.user.js
Created March 10, 2017 09:00
Upload a torrent on Transmission Web Interface by pasting URL of thread on share.dmhy.org directly.
// ==UserScript==
// @name Transmission-DMHY
// @namespace org.sorz.lab.transmission-dmhy
// @include https://example.com/transmission/web/*
// @version 1
// @grant GM_xmlhttpRequest
// @require http://code.jquery.com/jquery-3.1.1.slim.min.js
// ==/UserScript==
const ICON = 'https://share.dmhy.org/favicon.ico';