Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@smallnest
smallnest / client.go
Created January 11, 2022 08:05 — forked from mowings/client.go
Golang Websocket JSONRPC server and client
package main
import (
"golang.org/x/net/websocket"
"log"
"net/rpc/jsonrpc"
)
// In a real project, these would be defined in a common file
type Args struct {
@smallnest
smallnest / traceroute.go
Created December 8, 2021 12:57 — forked from niedbalski/traceroute.go
A small traceroute written in go
package main
import (
//"bufio"
"fmt"
"golang.org/x/net/icmp"
"golang.org/x/net/internal/iana"
"golang.org/x/net/ipv4"
"log"
"net"
@smallnest
smallnest / clickhousedump
Created October 13, 2021 09:53 — forked from inkrement/clickhousedump
dump all clickhouse databases and tables
#!/bin/bash
OUTDIR=.
while read -r db ; do
while read -r table ; do
if [ "$db" == "system" ]; then
echo "skip system db"
continue 2;
@smallnest
smallnest / ipint.go
Created September 26, 2021 04:51 — forked from ammario/ipint.go
Golang ip <-> int conversion
func ip2int(ip net.IP) uint32 {
if len(ip) == 16 {
return binary.BigEndian.Uint32(ip[12:16])
}
return binary.BigEndian.Uint32(ip)
}
func int2ip(nn uint32) net.IP {
ip := make(net.IP, 4)
binary.BigEndian.PutUint32(ip, nn)
@smallnest
smallnest / HttpProxy.go
Created July 29, 2021 08:34 — forked from yowu/HttpProxy.go
A simple HTTP proxy by Golang
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@smallnest
smallnest / sched.go
Created July 7, 2021 08:11 — forked from ipcjk/sched.go
golang syscall set real time priority for task
package main
import (
"fmt"
"syscall"
"unsafe"
)
const (
SCHED_NORMAL = iota
// Author : Sandesh Bhusal
// Date Feb 23, 2021
// You may copy, download and modify the source code according to your requirements :)
// Happy Spoofing!
// Original Code Lives at https://gist.github.com/sandeshbhusal/c8fa09546ffc076e5103456dd4e3742d
package main
import (
"flag"
@smallnest
smallnest / rawudp.go
Created May 28, 2021 03:22 — forked from chrisnc/rawudp.go
constructing ip/udp packets in go
package main
import (
"bufio"
"bytes"
"encoding/binary"
"flag"
"fmt"
"net"
"os"
@smallnest
smallnest / raw_udp4.go
Created April 29, 2021 03:59 — forked from unakatsuo/raw_udp4.go
Send UDP packet using Linux raw socket.
// +build linux
package main
import (
"fmt"
"net"
"os"
"syscall"
@smallnest
smallnest / scratch_server.go
Created April 23, 2021 02:05 — forked from jschaf/scratch_server.go
A Go web server from scratch using syscalls
package main
// Simple, single-threaded server using system calls instead of the net library.
//
// Omitted features from the go net package:
//
// - TLS
// - Most error checking
// - Only supports bodies that close, no persistent or chunked connections
// - Redirects