怎么设置go proxy

要设置go proxy,您需要使用以下命令:

go env -w GOPROXY=https://代理地址

其中,”https://代理地址”是您要使用的代理服务器地址。例如,如果您要使用http://Goproxy.io作为您的代理服务器,您将输入以下命令:

go env -w GOPROXY=https://goproxy.io,direct

在此示例中,我们指定http://Goproxy.io为主要代理服务器,并使用“direct”作为备用服务器(如果http://Goproxy.io无法访问)。

您还可以配置其他参数来控制go proxy的行为。例如,您可以使用以下命令将代理超时设置为5秒:

go env -w GOPROXY=https://goproxy.io,direct,timeout=5s

python

类型转换四个函数

int() float() str() bool()

算数运算

// 除法,取整

** 幂运算符, 去几次幂

% 取模

赋值

  • +=
  • -=
  • *=
  • **=
  • /=
  • //=
  • %=

关系运算符

Python中可以对字符串进行大于或小于与的运算。

当比较字符串时,比较的是unicode编码,逐位比较。按照此特性,可以进行英文字母排序比较,中文来说是不很好,因为有的是按笔画有的是按偏旁部首。

is 比较对象,(id)

is not 比较对象

逻辑运算符

短路操作, and 找false,第一个找不到会继续运行

or 找 true , 第一个找到不会继续运行

三元运算符

print(“hello”) if True else print(“world”);

如果是true执行前面,否则执行else的

max = a if a > b else b

max = a if (a > b and a > c) else (b if b > c else c)

流程控制语句

res = 1 < 2 < 3

用中间比较左右两边

RSA证书生成命令

test -d certs && rm -rf certs
 mkdir certs
 cd certs
 openssl genrsa -out rsa_private_key.pem 1024
 openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
 openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt > rsa_private_key_pkcs8.pem
 openssl req -new -x509 -key rsa_private_key.pem -out ca.crt -days 7300
 openssl req -new -key rsa_private_key.pem -out request.csr
 openssl x509 -req -days 7300 -in request.csr -CA ca.crt -CAkey rsa_private_key.pem -CAcreateserial -out rsa_public_crt.crt
 rm -f ca.crt
 rm -f request.csr
 echo '-----------------------------------------------'
 echo '*  Success! Check out files in certs folder.  *'
 echo '-----------------------------------------------'

Nginx Log日志统计分析常用命令

IP相关统计

统计IP访问量(独立ip访问数量)

awk '{print $1}' access.log | sort -n | uniq | wc -l

查看某一时间段的IP访问量(4-5点)

grep "07/Apr/2017:0[4-5]" access.log | awk '{print $1}' | sort | uniq -c| sort -nr | wc -l  

查看访问最频繁的前100个IP

awk '{print $1}' access.log | sort -n |uniq -c | sort -rn | head -n 100

查看访问100次以上的IP

awk '{print $1}' access.log | sort -n |uniq -c |awk '{if($1 >100) print $0}'|sort -rn

查询某个IP的详细访问情况,按访问频率排序

grep '127.0.01' access.log |awk '{print $7}'|sort |uniq -c |sort -rn |head -n 100

页面访问统计

查看访问最频的页面(TOP100)

awk '{print $7}' access.log | sort |uniq -c | sort -rn | head -n 100

查看访问最频的页面([排除php页面】(TOP100)

grep -v ".php"  access.log | awk '{print $7}' | sort |uniq -c | sort -rn | head -n 100 

查看页面访问次数超过100次的页面

cat access.log | cut -d ' ' -f 7 | sort |uniq -c | awk '{if ($1 > 100) print $0}' | less

查看最近1000条记录,访问量最高的页面

tail -1000 access.log |awk '{print $7}'|sort|uniq -c|sort -nr|less

每秒请求量统计

统计每秒的请求数,top100的时间点(精确到秒)

awk '{print $4}' access.log |cut -c 14-21|sort|uniq -c|sort -nr|head -n 100

每分钟请求量统计

统计每分钟的请求数,top100的时间点(精确到分钟)

awk '{print $4}' access.log |cut -c 14-18|sort|uniq -c|sort -nr|head -n 100

每小时请求量统计

统计每小时的请求数,top100的时间点(精确到小时)

awk '{print $4}' access.log |cut -c 14-15|sort|uniq -c|sort -nr|head -n 100

性能分析

在nginx log中最后一个字段加入$request_time

列出传输时间超过 3 秒的页面,显示前20条

cat access.log|awk '($NF > 3){print $7}'|sort -n|uniq -c|sort -nr|head -20

列出php页面请求时间超过3秒的页面,并统计其出现的次数,显示前100条

cat access.log|awk '($NF > 1 &&  $7~/\.php/){print $7}'|sort -n|uniq -c|sort -nr|head -100

蜘蛛抓取统计

统计蜘蛛抓取次数

grep 'Baiduspider' access.log |wc -l

统计蜘蛛抓取404的次数

grep 'Baiduspider' access.log |grep '404' | wc -l

TCP连接统计

查看当前TCP连接数

netstat -tan | grep "ESTABLISHED" | grep ":80" | wc -l

用tcpdump嗅探80端口的访问看看谁最高

tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr