Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
Inclure des appels à Go lang dans Python
Voir :
Voir aussi :
Tuto 1
Source : https://dev.to/leapcell/how-to-call-go-code-in-python-accelerate-python-with-go-54if
Linux and Mac
go build -buildmode=c-shared -o add.so add.go
windows
go build -buildmode=c-shared -o add.dll add.go
go build -ldflags "-s -w" -buildmode=c-shared -o add.so add.go
-s indicates compression -w indicates removing debugging
# Test calling code written in the GO language from Python # First, the GO code needs to be compiled into a dynamic link library from ctypes import cdll lib = cdll.LoadLibrary("./add.so") # Specify the compiled dynamic link library file here # Call the Add function in the GO language result = lib.Add(100, 200) print("result ", result) # Call the PrintDll function in the GO language lib.PrintDll()
Tuto 2
Exemple 1
library.go
package main import ( "C" "log" ) //export helloWorld func helloWorld(){ log.Println("Hello World") } func main(){ }
Compilation de la lib
go build -buildmode=c-shared -o library.so library.go
Execution depuis Python
import ctypes library = ctypes.cdll.LoadLibrary('./library.so') hello_world = library.helloWorld hello_world()
Exemple 2
library.go
//export hello func hello(namePtr *C.char){ name := C.GoString(namePtr) log.Println("Hello", name) }
app.py
hello = library.hello hello.argtypes = [ctypes.c_char_p] hello("everyone".encode('utf-8'))
library.go
//export farewell func farewell() *C.char{ return C.CString("Bye!") }
Notes protocoles TCP/IP - IGMP et multicast
Voir multicast :
Voir IGMP :
iptables règles multicast :
Multicast IGMP (Internet Group Management Protocol) :
- 224.0.0.0/4
Filtre Wireshark pour IGMP et mulicast :
igmp or ip.addr==224.0.0.0/4
Règle iptables pour autoriser IGMP
iptables -I INPUT -p igmp -j ACCEPT iptables -I FORWARD -p igmp -j ACCEPT
Règle pour bloquer le multicast
iptables -A INPUT -m pkttype --pkt-type multicast -j DROP
iptables -A INPUT -m pkttype --pkt-type multicast -j ACCEPT iptables -A FORWARD -m pkttype --pkt-type multicast -j ACCEPT iptables -A OUTPUT -m pkttype --pkt-type multicast -j ACCEPT # Or: iptables -A INPUT -s 224.0.0.0/4 -j ACCEPT iptables -A FORWARD -s 224.0.0.0/4 -d 224.0.0.0/4 -j ACCEPT iptables -A OUTPUT -d 224.0.0.0/4 -j ACCEPT
Source : https://gist.github.com/juliojsb/00e3bb086fd4e0472dbe#file-iptables-multicast-sh
Notes go lang programmation fonctionnelle
Voir :
Voir aussi Expr :
Voir aussi :
map
Voir :
package main import "fmt" //type f_ii func(int) int //func MapInt(f f_ii, l []int) [](int) { func MapInt(f func(int) int, l []int) [](int) { ret := []int{} for _, v := range l { ret = append(ret, f(v)) } return (ret) } func carre(i int) int { return i * i } func main() { liste := []int{1, 2, 3} fmt.Println(MapInt(carre, liste)) }
Voir aussi
package main import "fmt" type FuncType func(int) int func square(x int) int { return x * x } var f FuncType = FuncType(square) func main() { fmt.Println(f(5)) }
Autres
func stringInSlice(a string, list []string) bool { for _, b := range list { if b == a { return true } } return false }
Notes ping ICMP
rootless
Allowing ping
Most distributions do not allow non-root users to send ICMP Echo Request packets (aka ping) by default.
To allow running ping without root, create /etc/sysctl.d/99-rootless.conf with the following content:
/etc/sysctl.d/99-rootless.conf
net.ipv4.ping_group_range = 0 2147483647
Then run the following command to reload the new sysctl configuration:
sudo sysctl --system
Source : https://rootlesscontaine.rs/getting-started/common/sysctl/
Notes SOPS
Voir :
Voir aussi :
- GPG
- HashiCorp Vault
# age-keygen -o ~/.config/sops/age/keys.txt
$ age-keygen -o "${HOME}"/private-key
Public key: age1p6svvezfcg3jz33d0ynd27n3j72p7tjrqxdkssmwsvph7ct3y44qxvv8s7
source <(sops completion bash) # SOPS variables export SOPS_AGE_KEY_FILE="${HOME}/private-key" # Ansible variables export ANSIBLE_SOPS_AGE_KEYFILE="$SOPS_AGE_KEY_FILE" # Public key export SOPS_AGE_RECIPIENTS=age1p6svvezfcg3jz33d0ynd27n3j72p7tjrqxdkssmwsvph7ct3y44qxvv8s7
Avec GPG # On récupère la fingerprint de notre clé gpg --list-keys # On export le fingerprint export SOPS_PGP_FP="<VOTRE FINGERPRINT>"
Usage
sops --encrypt --encrypted-regex '^(password|apiKey)$' --in-place ./secrets.yaml
sops -e secrets.yaml > secrets.enc.yaml sops -d secrets.enc.yaml > secrets.decrypted.yaml # Déconseillé sops edit secrets.yaml sops set plop.yaml '["user1"]["password"]' '"P@ssw0rd"' sops unset plop.yaml '["user1"]' sops encrypt --age age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw test.yaml > test.enc.yaml sops decrypt mynewtestfile.yaml sops -d mynewtestfile.yaml
# Chiffrer depuis stdin (JSON) echo '{"secret": "from-stdin"}' | sops encrypt --input-type json --output-type json /dev/stdin # Écrire le résultat dans un fichier sops decrypt secrets.enc.yaml --output secrets.yaml
Rotate / rekey
sops rotate -i example.yaml
Rekey
sops updatekeys -y secrets.enc.yaml
Looks for keys.txt in $XDG_CONFIG_HOME/sops/age/keys.txt; Falls back to $HOME/.config/sops/age/keys.txt if $XDG_CONFIG_HOME isn’t set.
Cloud
sops -e --kms arn:aws:kms:us-west-2:123456789012:key/your-key-id secrets.yaml > secrets.enc.yaml
Config
.sops.yaml
# creation rules are evaluated sequentially, the first match wins creation_rules: # upon creation of a file that matches the pattern *.dev.yaml, # KMS set A as well as PGP and age is used - path_regex: \.dev\.yaml$ age: 'age129h70qwx39k7h5x6l9hg566nwm53527zvamre8vep9e3plsm44uqgy8gla' # prod files use KMS set B in the PROD IAM, PGP and age - path_regex: \.prod\.yaml$ age: 'age129h70qwx39k7h5x6l9hg566nwm53527zvamre8vep9e3plsm44uqgy8gla'
creation_rules: # Prod : ne chiffrer que les secrets - path_regex: 'prod/.*' age: age1abc... encrypted_regex: '^(password|token|secret|key)$' # Dev : tout chiffrer - path_regex: '.*' age: age1abc...
# Injecter les secrets comme variables d'environnement sops exec-env secrets.enc.env 'echo DB_PASSWORD=$DB_PASSWORD' # DB_PASSWORD=super-secret-123
