参考了https://unix.stackexchange.com/questions/68956/block-network-access-of-a-process ,其中netns是docker在用的方法,配置比较复杂,比较简单的方法是创建专门的group,在iptable增加针对group的限制。
# 新增一个组
groupadd no-lan
# 验证下组
sg no-lan id
// Command click is a chromedp example demonstrating how to use a selector to | |
// click on an element. | |
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"strings" | |
"time" |
#!/bin/bash | |
run(){ | |
cmd=$@ | |
echo ">> $cmd" | |
eval $cmd | |
echo | |
} | |
run uptime |
>python3 blackjack.py -h | |
usage: blackjack.py [-h] -n NROUND [-j BLACKJACK_NUM] [-u PLAYER_HIT_UNTIL] [-s PLAYER_SKIP_LARGE] [--verbose] | |
Blackjack | |
optional arguments: | |
-h, --help show this help message and exit | |
-n NROUND, --nround NROUND | |
-j BLACKJACK_NUM, --blackjack_num BLACKJACK_NUM | |
-u PLAYER_HIT_UNTIL, --player_hit_until PLAYER_HIT_UNTIL |
#!/bin/bash | |
# Get dns-reverse-proxy from https://github.com/notsobad/dns-reverse-proxy | |
pushd /xxx/dns-reverse-proxy | |
LAN_DNS=`systemd-resolve --status | grep 'DNS Servers'|cut -d ':' -f2|xargs`:53 | |
echo "lan dns": $LAN_DNS | |
sudo ./dns-reverse-proxy\ | |
-address 0.0.0.0:53 \ | |
-default 114.114.114.114:53 \ |
#!/bin/bash | |
function tab () { | |
local cmd="" | |
local cdto="$PWD" | |
local args="$@" | |
if [ -d "$1" ]; then | |
cdto=`cd "$1"; pwd` | |
args="${@:2}" |
stages: | |
- test | |
workflow: | |
rules: | |
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' | |
pylint-error-only: | |
stage: test | |
script: |
参考了https://unix.stackexchange.com/questions/68956/block-network-access-of-a-process ,其中netns是docker在用的方法,配置比较复杂,比较简单的方法是创建专门的group,在iptable增加针对group的限制。
# 新增一个组
groupadd no-lan
# 验证下组
sg no-lan id
# python http408.py 127.0.0.1 80 25 | |
import socket | |
import time | |
import sys | |
HOST = sys.argv[1] | |
PORT = int(sys.argv[2]) | |
DELAY = int(sys.argv[3]) | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
#coding=utf-8 | |
# https://zh.wikipedia.org/wiki/%E8%92%99%E6%8F%90%E9%9C%8D%E7%88%BE%E5%95%8F%E9%A1%8C | |
import sys | |
import random | |
stay = 0 | |
change = 0 | |
MAX_TRY = int(sys.argv[1]) | |
for i in range(MAX_TRY): |