- https://en.wikipedia.org/wiki/Port_mirroring
- jpillora/go-tcp-proxy#23
- https://www.zupzup.org/go-port-forwarding/index.html
- https://github.com/codeexpress/tcpmirror
- https://github.com/gherlein/gonetmon
- https://medium.com/swlh/traffic-mirroring-with-linux-tc-df4d36116119
- https://adamkuj.net/blog/2016/05/18/pro-tip-port-mirroring-in-linux/
- https://superuser.com/questions/1289166/mirror-all-traffic-from-one-port-to-another-on-localhost-using-iptables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IsIp checks that the given string is IPv4 or IPv6 address. | |
func IsIp(addr string) bool { | |
// IPv6 | |
if addr[0] == '[' { | |
return true | |
} | |
// domain can have digits, but it can't have ONLY digits | |
// So if all symbols are digits then this is an IPv4 address. We can check only first octet before dot . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bytesmap | |
var m = make(map[string]*string) | |
// this works faster | |
func GetOrDefaultInline(host []byte) *string { | |
hc, found := m[string(host)] | |
if !found { | |
m[string(host)] = nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EncodeToJsonAsciiText Fast json text value encode: escape " with \" and \ with \\ | |
// Any non printable or Unicode chars will be removed. | |
// Please note that value is not enclosed into double quotes. | |
func EncodeToJsonAsciiText(plain string) string { | |
plainLen := len(plain) | |
newSize := plainLen | |
for i := 0; i < plainLen; i++ { | |
c := plain[i] | |
if c < 32 || c > 127 { // skip non printable and unicode | |
newSize-- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"github.com/prometheus/client_golang/prometheus" | |
"github.com/prometheus/client_golang/prometheus/promauto" | |
"google.golang.org/grpc/codes" | |
"google.golang.org/grpc/status" | |
"reflect" | |
"strconv" | |
) | |
// GrpcError The interface the same as internal type Error from grpc: internal/status/status.go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// parseIPv4 fast path clone of net.ParseIP that don't wrap IPv4 into IPv6 array | |
func parseIPv4(s string) []byte { | |
var p [4]byte | |
for i := 0; i < 4; i++ { | |
octet, pos := dtoi(s) | |
p[i] = octet | |
if i < 3 { | |
s = s[pos+1:] |
- https://www.nushell.sh/ https://github.com/nushell/nushell https://habr.com/ru/company/flant/news/t/465335/
- https://elv.sh/
- https://hackaday.com/2020/08/08/a-shell-a-programming-language-relax-its-both/
- https://hackaday.com/2020/05/21/linux-fu-alternative-shells/
- https://github.com/liljencrantz/crush
- https://github.com/babashka/babashka Closure
- https://kinsta.com/blog/scripting-languages/
- https://github.com/alebcay/awesome-shell
- https://github.com/uhub/awesome-shell
- https://awesomeopensource.com/project/awesome-lists/awesome-bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// UInt16Slice is a sorted slice | |
type UInt16Slice []uint16 | |
// BinSearch binary search over the sorted sclice | |
func (a UInt16Slice) BinSearch(key uint16) int { | |
low := 0 | |
high := len(a) - 1 | |
for low <= high { |
The Base64 url safe already supported by basenc
command. But it may be not pre-installed on many platfroms.
You can call base64
command but there is a pitfalls:
- On most Linux distros the
base64
command comes fromcoreutils
package. And it already have abasenc
command - On OpenWrt the
base64
is not installed by default and comes fromcoreutils-base64
package and thebaseenc
command fromcoreutils-baseenc
- You can enable the
base64
in BusyBox i.e. if you building the OpenWrt image yourself. - You may use
openssl base64
oropenssl enc -base64
see docs but it will read by lines so you must also specify-A
param. - On MacOS the
-d
decode flag must be in upper casebase64 -D
so most users use--decode
flag. Previously MacOS used the-d
for debug but it's not clear who ever used it. Then Applce just removed the-d
param but again it's not clear why they don't changed it to be compatible with coreutil
Firts you need to enable mod_openssl
/usr/sbin/lighttpd-enable-mod ssl
Then edit /etc/lighttpd/conf-enabled/10-ssl.conf :
vi /etc/lighttpd/conf-enabled/10-ssl.conf
Adjust to: