V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  falser101  ›  全部回复第 3 页 / 共 4 页
回复总数  80
1  2  3  4  
@RobinHuuu 果然和 nftables 有关系,如下操作后就行了!

$ sudo nft list ruleset

table inet filter {
chain input {
type filter hook input priority filter; policy drop;
ct state invalid drop comment "early drop of invalid connections"
ct state { established, related } accept comment "allow tracked connections"
iif "lo" accept comment "allow from loopback"
ip protocol icmp accept comment "allow icmp"
meta l4proto ipv6-icmp accept comment "allow icmp v6"
tcp dport 22 accept comment "allow sshd"
iifname "waydroid0" accept comment "Allow incoming network traffic from WayDroid"
meta pkttype host limit rate 5/second burst 5 packets counter packets 1393 bytes 423702 reject with icmpx admin-prohibited
counter packets 36570 bytes 7441045
}

chain forward {
type filter hook forward priority filter; policy drop;
iifname "waydroid0" accept comment "Allow outgoing network traffic from WayDroid"
ct state { established, related } counter packets 0 bytes 0 accept comment "accept established connections"
}
}

# falser @ archlinux in ~/Projects/tongpulsar_console/data on git:feat/logs x [14:26:45]
$ systemctl stop nftable
Failed to stop nftable.service: Unit nftable.service not loaded.

# falser @ archlinux in ~/Projects/tongpulsar_console/data on git:feat/logs x [14:28:05] C:5
$ sudo nft flush ruleset

# falser @ archlinux in ~/Projects/tongpulsar_console/data on git:feat/logs x [14:28:16]
$ sudo nft list ruleset
@RobinHuuu 之前用了 nftable,我装 waydroid 卸载了,装的 iptables

$ sudo iptables -t mangle -nL
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
TP_PRE 0 -- 0.0.0.0/0 0.0.0.0/0

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
TP_OUT 0 -- 0.0.0.0/0 0.0.0.0/0

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
CHECKSUM 17 -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68 CHECKSUM fill

Chain TP_MARK (1 references)
target prot opt source destination
MARK 6 -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x02 MARK or 0x40
MARK 17 -- 0.0.0.0/0 0.0.0.0/0 ctstate NEW MARK or 0x40
CONNMARK 0 -- 0.0.0.0/0 0.0.0.0/0 CONNMARK save

Chain TP_OUT (1 references)
target prot opt source destination
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0 mark match 0x80/0x80
TP_RULE 6 -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match src-type LOCAL dst-type !LOCAL
TP_RULE 17 -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match src-type LOCAL dst-type !LOCAL

Chain TP_PRE (1 references)
target prot opt source destination
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0 mark match ! 0x40/0xc0
TP_RULE 6 -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match src-type !LOCAL dst-type !LOCAL
TP_RULE 17 -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match src-type !LOCAL dst-type !LOCAL
TPROXY 6 -- 0.0.0.0/0 0.0.0.0/0 mark match 0x40/0xc0 TPROXY redirect 127.0.0.1:52345 mark 0x0/0x0
TPROXY 17 -- 0.0.0.0/0 0.0.0.0/0 mark match 0x40/0xc0 TPROXY redirect 127.0.0.1:52345 mark 0x0/0x0

Chain TP_RULE (4 references)
target prot opt source destination
CONNMARK 0 -- 0.0.0.0/0 0.0.0.0/0 CONNMARK restore
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0 mark match 0x40/0xc0
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0
RETURN 0 -- 0.0.0.0/0 0.0.0.0/0
RETURN 0 -- 0.0.0.0/0 192.168.1.0/24
RETURN 0 -- 0.0.0.0/0 192.168.240.0/24
RETURN 0 -- 0.0.0.0/0 192.168.192.0/24
RETURN 0 -- 0.0.0.0/0 172.16.6.0/24
RETURN 0 -- 0.0.0.0/0 192.168.61.0/24
RETURN 0 -- 0.0.0.0/0 192.168.22.0/24
RETURN 0 -- 0.0.0.0/0 127.0.0.0/8
RETURN 0 -- 0.0.0.0/0 0.0.0.0
RETURN 0 -- 0.0.0.0/0 10.0.0.0/8
RETURN 0 -- 0.0.0.0/0 100.64.0.0/10
RETURN 0 -- 0.0.0.0/0 169.254.0.0/16
RETURN 0 -- 0.0.0.0/0 172.16.0.0/12
RETURN 0 -- 0.0.0.0/0 192.0.0.0/24
RETURN 0 -- 0.0.0.0/0 192.0.2.0/24
RETURN 0 -- 0.0.0.0/0 192.88.99.0/24
RETURN 0 -- 0.0.0.0/0 192.168.0.0/16
RETURN 0 -- 0.0.0.0/0 198.51.100.0/24
RETURN 0 -- 0.0.0.0/0 203.0.113.0/24
RETURN 0 -- 0.0.0.0/0 224.0.0.0/4
RETURN 0 -- 0.0.0.0/0 240.0.0.0/4
TP_MARK 0 -- 0.0.0.0/0 0.0.0.0/0

$ sudo iptables -t nat -nL
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE 0 -- 192.168.240.0/24 !192.168.240.0/24
@RobinHuuu $ ip rule show
0: from all lookup local
32765: from all fwmark 0x40/0xc0 lookup 100
32766: from all lookup main
32767: from all lookup default
@churchmice 看本地还是那里?
206 天前
回复了 falser101 创建的主题 问与答 关于关系很好的朋友借钱问题
@kingpo #122 已经拒绝了,让他想下别的办法,不过你有什么更好的说辞吗
208 天前
回复了 falser101 创建的主题 问与答 关于关系很好的朋友借钱问题
已经听劝了,谢谢各位的劝解
208 天前
回复了 falser101 创建的主题 问与答 关于关系很好的朋友借钱问题
@wzy44944 他已经给家里坦白了,借钱也不会借给他,是借给他家人,不过我自己家里也没什么钱,就很普通的家庭
208 天前
回复了 falser101 创建的主题 问与答 关于关系很好的朋友借钱问题
这几天脑子里都是关于这件事让我很烦 他真的是一手好牌打得稀烂 这几年明明过得很不错的 很气 因为真的希望他过得好 谢谢大家的建议和回复 想开了 不管了
208 天前
回复了 falser101 创建的主题 问与答 关于关系很好的朋友借钱问题
他已经给家里坦白了,还想让我帮他从银行贷款,先还网贷......
208 天前
回复了 falser101 创建的主题 问与答 关于关系很好的朋友借钱问题
感谢各位劝,听劝
208 天前
回复了 falser101 创建的主题 问与答 关于关系很好的朋友借钱问题
@CHTuring 确实,给我说这个,让我内心很纠结,一边是多年的朋友,一边是我自己辛苦挣的钱
加了一条解决了
当前路由
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 10 0 0 wlan0
0.0.0.0 192.168.22.1 0.0.0.0 UG 100 0 0 enp3s0
10.0.0.0 192.168.22.1 255.0.0.0 UG 0 0 0 enp3s0
172.16.6.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
192.168.1.0 0.0.0.0 255.255.255.0 U 10 0 0 wlan0
192.168.22.0 0.0.0.0 255.255.255.0 U 100 0 0 enp3s0
192.168.61.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.192.0 0.0.0.0 255.255.255.0 U 0 0 0 ztjlh3ajee
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 10 0 0 wlan0
0.0.0.0 192.168.22.1 0.0.0.0 UG 100 0 0 enp3s0
172.16.6.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
192.168.1.0 0.0.0.0 255.255.255.0 U 10 0 0 wlan0
192.168.22.0 0.0.0.0 255.255.255.0 U 100 0 0 enp3s0

这是我的路由表,是需要删除掉有线的 0.0.0.0 这一条吗
2024-01-25 17:49:17 +08:00
回复了 pdxjun 创建的主题 Go 编程语言 大佬们这段 golang 代码怎么优化,这么多 if 判断
GPT3.5
您可以通过将相似的逻辑整理成一个函数,并使用循环来遍历需要执行的函数,以减少代码的冗余。以下是一个优化后的示例:

go
Copy code
// 定义一个函数类型,用于处理特定的 ColumnFn
type ColumnFuncHandler func(column *Column) string

// 处理 ColumnFn 的函数
func processColumnFn(column *Column, fnName string, fnHandler ColumnFuncHandler) string {
if column.ColumnFn[fnName] != nil {
return fnHandler(column)
}
return ""
}

// 处理所有 ColumnFn 的函数
func processAllColumnFns(column *Column) string {
var result string

// 定义需要处理的函数名列表
fnNames := []string{"primaryKey", "autoIncrement", "default", "notNull", "comment"}

// 遍历函数名列表,执行相应的处理函数
for _, fnName := range fnNames {
result += processColumnFn(column, fnName, column.ColumnFn[fnName])
}

return result
}

// 在你的代码中调用 processAllColumnFns
col := column.typeFn(column.ctype) + processAllColumnFns(column)
通过这种方式,您可以将重复的逻辑整理到函数中,并通过循环来遍历需要执行的函数。这样可以使代码更加清晰、可维护,并减少冗余。同时,如果以后需要添加或删除某个 ColumnFn ,只需在 fnNames 中进行相应的修改,而不必在每个条件语句中进行更改。
@eyebrow WmoxMDIzNTM1NTY5
base64 求拉
@pmx1990 是啊,有工作但是不想继续搞 java
@shank 谢大佬,这样就有学习的方向了
2023-08-07 10:12:01 +08:00
回复了 falser101 创建的主题 程序员 好兄弟们 想搞一个显示器,用来写代码,有没有推荐的啊
@thiswind 在公司用,
2023-08-07 10:11:15 +08:00
回复了 falser101 创建的主题 程序员 好兄弟们 想搞一个显示器,用来写代码,有没有推荐的啊
@talkischeap567 可以的,准备整个 27 的
1  2  3  4  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2735 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms · UTC 07:58 · PVG 15:58 · LAX 23:58 · JFK 02:58
Developed with CodeLauncher
♥ Do have faith in what you're doing.