BlueXIII's Blog

热爱技术,持续学习

0%

GitHub

https://github.com/curve25519xsalsa20poly1305/docker-openvpn-socks5

参考

https://zzz.buzz/zh/2018/03/07/windows-openvpn-logs-algorithm-too-weak-solution/

启动脚本

1
2
3
4
5
6
docker run  -itd --name ov_publish \
--device=/dev/net/tun --cap-add=NET_ADMIN \
-v /opt/openvpn/publish:/vpn:ro \
-e OPENVPN_CONFIG=/vpn/vpn.ovpn \
-p 7031:1080 \
curve25519xsalsa20poly1305/openvpn-socks5

ovpn配置文件调整

vpn.ovpn

1
2
3
4
# 继续接受弱算法保护的证书
tls-cipher "DEFAULT:@SECLEVEL=0"
# 配置用户名密码文件
auth-user-pass login.conf

login.conf

1
2
yourname
yourpass

官网

https://github.com/ginuerzh/gost

WS端口复用

服务端Gost

1
./gost -L "ws://172.17.0.1:31314?path=/gost"

服务端Nginx转发

1
2
3
4
5
6
7
8
9
10
location /ray {
proxy_redirect off;
proxy_pass http://172.17.0.1:31313;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

本机Gost

1
./gost -L=:7013 -F="ws://10.80.8.237:8080?path=/gost"

官网及下载

教程

安装

Linux

1
2
3
# 安装
wget https://bluexiii-files.oss-cn-beijing.aliyuncs.com/k9s_Linux_x86_64.tar.gz
mv k9s /usr/local/bin/

macOS

1
brew install k9s

配置kubeconfig

vi ~/.kube/config

启动

1
2
3
4
5
6
7
8
# 启动
k9s

# 指定命名空间启动
k9s -n dubhe-test

# 查看帮助
?

本机安装kubectl

1
brew install kubectl 

配置kubeconfig

vi ~/.kube/config

1

拷贝文件

https://kubernetes.io/docs/reference/kubectl/cheatsheet/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 查询所有命名空间
kubectl get namespaces

# 查询所有Deployment
kubectl get deployments -n dubhe-test

# 查询Pods
kubectl get pods -n dubhe-test | grep dubhe-metadata-deploy

# 进入容器
kubectl exec -it -n dubhe-test dubhe-metadata-deploy-758df87bfd-wqhs2 -- /bin/bash

# 得到容器内日志路径
cd /dubhe-metadata-biz/logs

# 拷贝目录到本机
kubectl cp -n dubhe-test dubhe-metadata-deploy-758df87bfd-wqhs2:/dubhe-metadata-biz/logs ./

官网

类似应用

配置

服务端frps.ini

1
2
3
[common]
bind_port = 37000
token = yourtoken

客户端frpc.ini

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[common]
server_addr = your_ip
server_port = 37000
token = yourtoken

[web]
type = tcp
local_ip = 127.0.0.1
local_port = 8080
remote_port = 37001

[socks5]
type = tcp
remote_port = 37002
plugin = socks5
plugin_user = yourname
plugin_passwd = yourpass

启动脚本

1
2
./frps -c frps.ini
./frpc -c frpc.ini

基础库

  • code-mirror 著名编辑器基础库,支持SQL,关注
  • monaco-editor 微软,VSCode,有支持SQL的第三方fork

一体化方案

前端库

商业软件

  • sqldev 界面精美,不开源,国产

其它

  • ace 前端JS编辑器,貌似没有对SQL的支持

关于选型

  • 初步了解并罗列,未深入对比
  • 几个一体化的方案,看上去都不太好改
  • 需求灵活的话,有可能要基于code-mirror基础库自已做(或者用sql-editor这种基于code-mirror魔改的版本)

参考

https://www.v2ex.com/t/516822

参考文档

命令行

1
2
3
4
# 映射yum源
ssh -R 8081:127.0.0.1:8081 -p2203 root@192.168.23.14
# 映射socks5
ssh -R 7890:127.0.0.1:8118 -p2203 root@192.168.23.14

服务器开启gatewayport

服务器端开启gatewayport后,局域网内其它机器可共享此端口

1
2
vi /etc/ssh/sshd_config
GatewayPorts yes

本机开启临时yum服务

1
2
cd ~/opt/yum
http-server

服务器配置yum源指向

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
cp -R /etc/yum.repos.d /etc/yum.repos.d.bak2

cat << EOF >>/etc/yum.repos.d/CentOS-Remote.repo
[centos7]
name=centos7
baseurl=http://127.0.0.1:8081/centos7
enabled=1
gpgcheck=0

[epel]
name=epal
baseurl=http://127.0.0.1:8081/epel
enabled=1
gpgcheck=0
EOF

yum clean all && yum makecache

本机socks5转http

解决clash的mix端口兼容性问题

1
2
3
4
5
6
7
brew install privoxy

vi /usr/local/etc/privoxy/config
listen-address localhost:8118
forward-socks5t / 127.0.0.1:7890 .

brew services start privoxy

ClashX直接开启http端口(废弃)

解决clash的mix端口兼容性问题,但7892http端口依然无效

1
2
3
vi ~/.config/clash/config.yaml
socks-port: 7891
port: 7892

导入全局代理环境变量

1
2
3
4
5
6
# 导入代理环境变量
export https_proxy=http://127.0.0.1:8118 http_proxy=http://127.0.0.1:8118 all_proxy=http://127.0.0.1:8118


# 测试
curl cip.cc

yum单独配代理

1
2
3
4
5
6
vi /etc/yum.conf
proxy=http://127.0.0.1:7890

# 禁用搜索最快镜像,避免卡顿
vi /etc/yum/pluginconf.d/fastestmirror.conf
enabled=0

docker单独配代理

1
2
3
4
5
6
7
8
mkdir -p /etc/systemd/system/docker.service.d
cat << EOF >>/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890" "HTTPS_PROXY=http://127.0.0.1:7890" "NO_PROXY=localhost,127.0.0.1"
EOF

systemctl daemon-reload && systemctl restart docker
systemctl show --property=Environment docker

proxychains强行走代理

1
2
3
4
5
6
7
8
9
10
11
12
# 下载并编译
git clone https://github.com/rofl0r/proxychains-ng
./configure
make && make install && make install-config

# 修改配置文件
vi /usr/local/etc/proxychains.conf
[ProxyList]
socks5 127.0.0.1 7890

# 测试
proxychains4 wget www.baidu.com

localhost.run

https://localhost.run/

前言

部分EasyConnect由于启用了专线模式,在连接成功后,本机会切断互联网连接,且局域网内其它机器也无法访问到本机。
这样一来,使得Windows虚拟机 + 虚拟机内CCProxy + 宿主机Proxifier的连接方式变得不可用。
尝试通过修改路由表的方式,也无法绕开EC专线模式的限制。最近有人制做了EC的Docker镜像,可以将EC运行在容器内,另外顺利绕过了专线模式。

GitHub

启动命令

1
2
3
4
5
# 连接EC
docker run --name ec_xxx --device /dev/net/tun --cap-add NET_ADMIN -ti -p 127.0.0.1:1080:1080 -p 127.0.0.1:8888:8888 -e EC_VER=7.6.3 -e CLI_OPTS="-d https://连接地址 -u 用户名 -p 密码" hagb/docker-easyconnect:cli

# 开启SSH隧道
ssh -o ProxyCommand='nc -x 127.0.0.1:1080 %h %p' -CfNg -D7000 -p2201 root@10.180.248.88

注意: 开通SSH隧道时,可以直接加入-o ProxyCommand参数,使ssh走1080代理。当然也可以在Proxifier上配置规则,强行使10.180.248.88整个网段走代理。
连接不同EC时,需要选择匹配的版本

参考文档

https://www.zsythink.net/archives/1199

流程图

20220927103716

  • PREROUTING 的规则可以存在于:raw表,mangle表,nat表。

  • INPUT 的规则可以存在于:mangle表,filter表,(centos7中还有nat表,centos6中没有)。

  • FORWARD 的规则可以存在于:mangle表,filter表。

  • OUTPUT 的规则可以存在于:raw表mangle表,nat表,filter表。

  • POSTROUTING 的规则可以存在于:mangle表,nat表。

  • raw 表中的规则可以被哪些链使用:PREROUTING,OUTPUT

  • mangle 表中的规则可以被哪些链使用:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING

  • nat 表中的规则可以被哪些链使用:PREROUTING,OUTPUT,POSTROUTING(centos7中还有INPUT,centos6中没有)

  • filter 表中的规则可以被哪些链使用:INPUT,FORWARD,OUTPUT

常用操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 查看规则
iptables --line -nvL
# 查看指定链上的规则
iptables --line -nvL INPUT

# 清空INPUT链中的规则
iptables -F INPUT
# 清空filter表在INUT链中的规则
iptables -t filter -F INPUT

# 插入规则
iptables -t filter -I INPUT -s 10.211.55.101 -j DROP
# 追加规则
iptables -t filter -A INPUT -s 10.211.55.101 -j ACCEPT
# 在第N行前插入规则
iptables -t filter -I INPUT 2 -s 10.211.55.101 -j ACCEPT

# 删除指定行
iptables -t filter -D INPUT 3

# 修改默认策略
iptables -t filter -P FORWARD DROP

# centos7安装iptables-services
yum install iptables-services
systemctl stop firewalld && systemctl disable firewalld #停止firewalld
systemctl start iptables && systemctl enable iptables #启动iptables

# 保存规则
service iptables save
# 保存规则
iptables-save > /etc/sysconfig/iptables
# 还原规则
iptables-restore < /etc/sysconfig/iptables
# 查看规则
cat /etc/sysconfig/iptables


# 条件匹配
-s 10.211.55.0/24 #源地址
-d 10.211.55.10 #目标地址
-p tcp #协议 tcp, udp, udplite, icmp, esp, ah, sctp
-i eth0 #流入网卡 只能用于PREROUTING链、INPUT链、FORWARD链
-o eth1 #流出网卡 只能用于FORWARD链、OUTPUT链、POSTROUTING链
--dport 22 #目标端口22
! --dport 22 #目标端口,非22的
–-dport 22:25 # 目标端口,22到25的
-m multiport --dport 22,36,80 #目标端口,离散的,需要用到扩展模块multiport

# 创建自定义链
iptables -t filter -N IN_WEB
iptables -t filter -I IN_WEB -s 10.211.55.101 -j REJECT
iptables -I IN_WEB -s 10.211.55.102 -j REJECT

# 引用自定义链
iptables -I INPUT -p tcp --dport 80 -j IN_WEB

# 删除自定义链
iptables -D INPUT 1
iptables -t filter -F IN_WEB
iptables -t filter -X IN_WEB

参考文档

Nacos配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
spring:
datasource:
loginTimeout: 20
druid:
filter:
stat:
merge-sql: true
slow-sql-millis: 5000
web-stat-filter:
enabled: true
url-pattern: /*
exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
session-stat-enable: true
session-stat-max-count: 100
stat-view-servlet:
enabled: true
allow: ""
url-pattern: /druid/*
reset-enable: true
login-username: admin
login-password: yourpass
primary:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://10.193.2.8:3306/efpx_dubhe_quality?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: yourpass
driver-class-name: com.mysql.jdbc.Driver
initialSize: 5
maxActive: 20
minIdle: 5
maxWait: 10000
poolPreparedStatements: false
maxPoolPreparedStatementPerConnectionSize: -1
validationQuery: SELECT 'x'
testOnBorrow: false
testOnReturn: false
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 30000
filters: stat,wall,log4j2
warehouse:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://10.193.2.8:4000/warehouse?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: yourpass
initialSize: 5
maxActive: 20
minIdle: 5
maxWait: 10000
poolPreparedStatements: false
maxPoolPreparedStatementPerConnectionSize: -1
validationQuery: SELECT 'x'
testOnBorrow: false
testOnReturn: false
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 30000
filters: stat,wall,log4j2

Bean配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.sdecloud.efpx.quality.biz.config;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
* JdbcTemplate配置类
*
* @author bluexiii
*/
@Configuration
public class JdbcTemplateConfiguration {
@Primary
@Bean(name = "dataSource")
@ConfigurationProperties("spring.datasource.primary")
public DataSource dataSource() {
return DruidDataSourceBuilder.create().build();
}

@Bean(name = "warehouseDataSource")
@ConfigurationProperties("spring.datasource.warehouse")
public DataSource warehouseDataSource() {
return DruidDataSourceBuilder.create().build();
}

@Bean("warehouseJdbcTemplate")
public JdbcTemplate warehouseJdbcTemplate(@Qualifier("warehouseDataSource") DataSource warehouseDataSource) {
return new JdbcTemplate(warehouseDataSource);
}
}