当前位置: 首页 > news >正文

【Docker】iptables命令的使用

iptables是一个非常强大的Linux防火墙工具,你可以使用它来控制网络流量的访问和转发。

前面已经学习了iptables的基本原理,四表五链的基本概念,也已经安装好了iptables,下面我们主要学习iptables命令的基本使用。

在这里插入图片描述

可以使用iptables -h来查看帮助:

$ iptables -h
iptables v1.6.1Usage: iptables -[ACD] chain rule-specification [options]iptables -I chain [rulenum] rule-specification [options]iptables -R chain rulenum rule-specification [options]iptables -D chain rulenum [options]iptables -[LS] [chain [rulenum]] [options]iptables -[FZ] [chain] [options]iptables -[NX] chainiptables -E old-chain-name new-chain-nameiptables -P chain target [options]iptables -h (print this help information)Commands:
Either long or short options are allowed.--append  -A chain            Append to chain--check   -C chain            Check for the existence of a rule--delete  -D chain            Delete matching rule from chain--delete  -D chain rulenumDelete rule rulenum (1 = first) from chain--insert  -I chain [rulenum]Insert in chain as rulenum (default 1=first)--replace -R chain rulenumReplace rule rulenum (1 = first) in chain--list    -L [chain [rulenum]]List the rules in a chain or all chains--list-rules -S [chain [rulenum]]Print the rules in a chain or all chains--flush   -F [chain]          Delete all rules in  chain or all chains--zero    -Z [chain [rulenum]]Zero counters in chain or all chains--new     -N chain            Create a new user-defined chain--delete-chain-X [chain]          Delete a user-defined chain--policy  -P chain targetChange policy on chain to target--rename-chain-E old-chain new-chainChange chain name, (moving any references)
Options:--ipv4      -4              Nothing (line is ignored by ip6tables-restore)--ipv6      -6              Error (line is ignored by iptables-restore)
[!] --protocol  -p proto        protocol: by number or name, eg. `tcp'
[!] --source    -s address[/mask][...]source specification
[!] --destination -d address[/mask][...]destination specification
[!] --in-interface -i input name[+]network interface name ([+] for wildcard)--jump -j targettarget for rule (may load target extension)--goto      -g chainjump to chain with no return--match       -m matchextended match (may load extension)--numeric     -n              numeric output of addresses and ports
[!] --out-interface -o output name[+]network interface name ([+] for wildcard)--table       -t table        table to manipulate (default: `filter')--verbose     -v              verbose mode--wait        -w [seconds]    maximum wait to acquire xtables lock before give up--wait-interval -W [usecs]    wait time to try to acquire xtables lockdefault is 1 second--line-numbers                print line numbers when listing--exact       -x              expand numbers (display exact values)
[!] --fragment  -f              match second or further fragments only--modprobe=<command>          try to insert modules using this command--set-counters PKTS BYTES     set the counter during insert/append
[!] --version   -V              print package version.

iptables的命令语法通常如下:

iptables [-t 表名] 管理选项 [链名] [匹配条件] [-j 动作]iptables -t 表名 <-A/I/D/R> 链名 [规则号] <-i/o 网卡名> -p 协议名 <-s 源IP/源子网> --sport 源端 <-d 目标IP/目标子网> --dport 目标端口 -j 动作

这里的各个部分解释如下:

  • -t 表名:这是可选的,用于指定你要操作的表。如果没有指定,默认是“filter”表。其他可用的表包括“nat”,“mangle”和“raw”。
  • 管理选项:这是你要执行的操作,比如添加(-A)或删除(-D)一条规则,插入一条规则(-I),替换一条规则(-R),清空链(-F)等。
  • 匹配条件:这是可选的,用于指定匹配条件。比如,你可以匹配源或目标IP地址,源或目标端口,输入或输出接口等。
  • -j 动作:这是规则的动作,当匹配条件满足时,执行的操作。比如,你可以接受(ACCEPT)数据包,拒绝(DROP)数据包,记录(LOG)数据包,或者跳转到另一个链(JUMP)。

规则的管理

规则的查询

查看当前防火墙规则:

$ sudo iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)pkts bytes target     prot opt in     out     source               destinationChain INPUT (policy ACCEPT 0 packets, 0 bytes)pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 0 packets, 0 bytes)pkts bytes target     prot opt in     out     source               destinationChain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)pkts bytes target     prot opt in     out     source               destination

选项:

  • -n:将地址和端口显示为数字
  • -t table:指定表名,默认为filter
  • -v:显示更为详细的信息
  • --line-numbers:显示规则的ID

规则的添加

向表的链中添加规则:

$ sudo iptables -t filter -A INPUT -p icmp -j REJECT$ sudo iptables -t filter -nvL
Chain INPUT (policy ACCEPT 44 packets, 2912 bytes)pkts bytes target     prot opt in     out     source               destination0     0 REJECT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachableChain FORWARD (policy ACCEPT 0 packets, 0 bytes)pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 33 packets, 2508 bytes)pkts bytes target     prot opt in     out     source               destination

这条规则的含义就是在filter表的INPUT链上增加一条拒绝所有icmp请求的规则,这样所有的ping请求将无法通讯:

$ ping 172.29.142.35 -c 3
PING 172.29.142.35 (172.29.142.35) 56(84) bytes of data.--- 172.29.142.35 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2044ms

再添加一条规则:

$ sudo iptables -t filter -A INPUT -p tcp -j ACCEPT$ sudo iptables -t filter -nvL --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        6   588 REJECT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
2       96  5568 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 49 packets, 3724 bytes)
num   pkts bytes target     prot opt in     out     source               destination

-A选项表示在尾部规则链中进行追加。

如果想在规则链的指定位置插入规则,可以使用-I选项,需要指定插入到规则链的哪个位置,默认为1。

$ sudo iptables -t filter -I INPUT 2 -p udp -j ACCEPT$ sudo iptables -t filter -nvL --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        6   588 REJECT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
2        0     0 ACCEPT     udp  --  *      *       0.0.0.0/0            0.0.0.0/0
3      327 19308 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 51 packets, 3876 bytes)
num   pkts bytes target     prot opt in     out     source               destination

规则的替换

使用-R选项进行规则的替换。

$ sudo iptables -t filter -R INPUT 1 -p icmp -j ACCEPT$ sudo iptables -t filter -nvL --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0
2        0     0 ACCEPT     udp  --  *      *       0.0.0.0/0            0.0.0.0/0
3      473 27740 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 6 packets, 488 bytes)
num   pkts bytes target     prot opt in     out     source               destination

规则的删除

使用-D选项进行规则的删除,可以根据规则的ID进行删除,也是根据整个规则进行删除。

$ sudo iptables -t filter -D INPUT 2$ sudo iptables -t filter -D INPUT -p tcp -j ACCEPT$ sudo iptables -t filter -nvL --line-numbers
Chain INPUT (policy ACCEPT 8 packets, 464 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 5 packets, 388 bytes)
num   pkts bytes target     prot opt in     out     source               destination

可以使用-F来删除所有的规则:

$ sudo iptables -t filter -F$ sudo iptables -t filter -nvL --line-numbers
Chain INPUT (policy ACCEPT 8 packets, 464 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 5 packets, 380 bytes)
num   pkts bytes target     prot opt in     out     source               destination

可以使用-Z选项让规则的计数器从0重新开始:

$ sudo iptables -t filter -Z

匹配条件

iptables可以根据不同的匹配条件来过滤网络数据包。iptables的匹配条件可以分为通用匹配条件和扩展匹配条件两种。

通用匹配条件:

  • -p:指定协议类型,如TCP、UDP、ICMP等。
  • -s:指定源IP地址或地址段。
  • -d:指定目标IP地址或地址段。
  • –sport:指定源端口号。
  • –dport:指定目标端口号。
  • -i:指定数据包进入的网络接口。
  • -o:指定数据包输出的网络接口。

扩展匹配条件:除了通用匹配条件其余可用于匹配的条件称为扩展配条件,这些扩展匹配条件在netfilter中以模块的形式存在,如果想使用这些条件,则需要依赖对应的拓展模块。

扩展匹配条件包括:

  • –mac-source:指定源MAC地址。
  • –mac-destination:指定目标MAC地址。
  • –state:指定连接状态,如NEW、ESTABLISHED、RELATED等。
  • –tcp-flags:指定TCP标志位。
  • –icmp-type:指定ICMP类型。
  • –limit:限制匹配规则的匹配次数。
  • –comment:为匹配规则添加注释。

处理动作

iptables规则的处理动作是指对匹配到的数据包所采取的操作。

常见的处理动作包括:

  • ACCEPT:允许数据包通过
  • DROP:直接丢弃数据包,不给任何回应信息。。
  • REJECT:拒绝数据包通过,必要时会给数据发送端一个相应的信息,客户端刚请求就会收到拒绝的信息。
  • SNAT:源地址转换,解决内网用户用同一个公网地址上网的问题。
  • MASQUERADE:是SNAT的一种特殊形式,适用于动态的、临时会变的IP上。
  • DNAT:目标地址转换
  • REDIRECT:在本机做端口映射。
  • LOG:在/var/log/mesages文件中记录日志信息,然后将数据包传递给下一条规则。即除了记录外不对数据包做任何其他操作,仍然让下一条规则进行匹配

自定义链

在iptables中,可以创建自定义链(Custom Chains)来组织和管理防火墙规则。

自定义链可以以更高层次和更好的可读性来管理规则,使配置和维护更加简单。

创建链mychain

$ sudo iptables -N MYCHAIN$ sudo iptables -t filter -nvL
Chain INPUT (policy ACCEPT 201 packets, 12360 bytes)pkts bytes target     prot opt in     out     source               destinationChain FORWARD (policy ACCEPT 0 packets, 0 bytes)pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 127 packets, 9820 bytes)pkts bytes target     prot opt in     out     source               destinationChain MYCHAIN (0 references)pkts bytes target     prot opt in     out     source               destination

此时filter表中多了一条MYCHAIN链。

添加规则到自定义链:

$ sudo iptables -t filter -A MYCHAIN -s 192.168.1.0/24 -j DROP

禁止192.168.1.0/24的网段访问本机,丢弃源地址的流量。

调用自定义链:

$ sudo iptables -t filter -A INPUT -p tcp --dport 80 -j MYCHAIN$ sudo iptables -t filter -nvL --line-numbers
Chain INPUT (policy ACCEPT 6 packets, 348 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 MYCHAIN    tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:80Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain OUTPUT (policy ACCEPT 4 packets, 304 bytes)
num   pkts bytes target     prot opt in     out     source               destinationChain MYCHAIN (1 references)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 DROP       all  --  *      *       192.168.1.0/24       0.0.0.0/0

将所有传入TCP端口80的流量传递到MYCHAIN自定义链进行处理。如果不调用自定义的规则链,则自定义的规则链无效。

清空链中的规则:

$ iptables -F MYCHAIN

删除指定的自定义链:

$ iptables -X MYCHAIN

删除所有的的自定义链:

$ iptables -X

相关文章:

【Docker】iptables命令的使用

iptables是一个非常强大的Linux防火墙工具&#xff0c;你可以使用它来控制网络流量的访问和转发。 前面已经学习了iptables的基本原理&#xff0c;四表五链的基本概念&#xff0c;也已经安装好了iptables&#xff0c;下面我们主要学习iptables命令的基本使用。 可以使用iptable…...

Flex bison 学习好代码

计算机的重要课程编译原理很难学吧&#xff0c; 但是要会用flex &bison的话&#xff0c;容易理解一些。 有些好的项目可以帮助我们&#xff0c;比如 https://github.com/jgarzik/sqlfun 可以帮我们&#xff0c;下载 下来。 在cygwin 下面或者linux 运行&#xff1a; …...

学习Nginx配置

1.下载地址 官网地址&#xff1a;NGINX - 免费试用、软件下载、产品定价 (nginx-cn.net) 我这边选择NGINX 开源版 nginx: download 2.nginx的基本配置 配置文件语法 配置文件组成&#xff1a;注释行&#xff0c;指令块配置项和一系列指令配置项组成。 单个指令组成&#x…...

怎么批量获取文件名,并保存到excel?

怎么批量获取文件名&#xff1f;什么叫批量获取文件名&#xff0c;其实也非常好理解&#xff0c;就是面对大量文件是可以一次性的获取所有文件名称&#xff0c;这项技术的应用也是非常常见的&#xff0c;为什么这么说呢&#xff1f;现在很多的文档管理人员或者公司的文员&#…...

数据结构: unordered_map与unordered_set

目录 1.框架 2.结构 unordered_map unordered_set 3.对HashTable的修改 更改模板参数 4.增加迭代器 a.结构 b.运算符重载 c.HashTable封装迭代器 d.unordered_map与unordered_set的迭代器 1.框架 1.复用HashTable ~~> 增加模板参数KeyOfT 来获取 Key值 unorder…...

WebDAV之π-Disk派盘 + PassStore

大家常用的qq,手机微信,新浪微博等。假如各个网址都设成同样的帐号和登陆密码,一旦某一帐户泄漏了,别的平台上的账户密码都有被撞库攻击的风险。在不一样的站点设定不一样的高韧性登陆密码才算是最安全可靠的确保,殊不知这般繁多的帐户密码是难以记得的。因而,有着一款安…...

OpenCV实现手势虚拟拖拽

前言&#xff1a; Hello大家好&#xff0c;我是Dream。 今天来学习一下如何使用OpenCV实现手势虚拟拖拽&#xff0c;欢迎大家一起前来探讨学习~ 一、主要步骤及库的功能介绍 1.主要步骤 要实现本次实验&#xff0c;主要步骤如下&#xff1a; 导入OpenCV库。通过OpenCV读取摄…...

深圳市宝安区委常委、宣传部部长周学良一行莅临联诚发考察调研

11月9日&#xff0c;深圳市宝安区组织开展主题教育“大走访、大座谈、大起底”行动和调查研究、“基层调研服务日”活动。当日上午&#xff0c;区委常委、宣传部部长周学良率调研组莅临联诚发LCF总部考察调研。区委宣传部副部长孙箫韵&#xff0c;区文化广电旅游体育局党组成员…...

Presentation Prompter 5.4.2(mac屏幕提词器)

Presentation Prompter是一款演讲辅助屏幕提词器软件&#xff0c;旨在帮助演讲者在公共演讲、主持活动或录制视频时更加流畅地进行演讲。以下是Presentation Prompter的一些特色功能&#xff1a; 提供滚动或分页显示&#xff1a;可以将演讲稿以滚动或分页的形式显示在屏幕上&a…...

9 网关的作用

1、总结&#xff1a; 1.如果离开本局域网&#xff0c;就需要经过网关&#xff0c;网关是路由器的一个网口。 2.路由器是一个三层设备&#xff0c;里面有如何寻找下一跳的规则 3.经过路由器之后 MAC 头要变&#xff0c;如果 IP 不变&#xff0c;相当于不换护照的欧洲旅游&#…...

计算机网络实验

计算机网络实验 使用软件PT7.0按照上面的拓扑结构建立网络&#xff0c;进行合理配置&#xff0c;使得所有计算机之间能够互相通信。并且修改各交换机的系统名称为&#xff1a;学号_编号&#xff0c;如你的学号为123&#xff0c;交换机Switch0的编号为0&#xff0c;则系统名称为…...

九凌网络分享外贸快车实现迅速出口的目标

随着全球化进程的不断加速&#xff0c;外贸行业也越来越繁荣。但如何在这个竞争激烈的市场中迅速出口&#xff0c;成为了很多外贸企业家们面临的难题。为此&#xff0c;很多企业开始寻求新的帮助&#xff0c;其中一种办法就是通过专业的外贸快车来提高自己的出口速度。九凌网络…...

分享66个Python管理系统源代码总有一个是你想要的

分享66个Python管理系统源代码总有一个是你想要的 源码下载链接&#xff1a;https://pan.baidu.com/s/1FGmE9Q_NE1-cjjoxU540BQ?pwd8888 提取码&#xff1a;8888 项目名称 automobile-sales-management-system汽车销售管理系统 Python Vue BNUZ教务系统认证爬虫Python语言…...

python 删除特定字符所在行

嗨喽&#xff0c;大家好呀~这里是爱看美女的茜茜呐 查询文件中含有特殊字符串的行 #!/usr/bin/python # -*- coding:utf-8 -*- import re file1 open(test.txt,r) istxt re.compile(r.*if.*,re.I) for line in file1.readlines():line line.strip()ifstr re.findall(istxt…...

邮箱哪家强?哪个牌子邮箱好用

邮箱在国内外使用情况不太一样&#xff0c;国内一般都是工作中需要用邮箱&#xff0c;直接使用公司发的企业邮箱就可以了&#xff0c;个人一般自己需要使用邮箱频率比较少&#xff0c;大多是用来注册其他平台信息&#xff0c;接受验证码、电子发票等等&#xff0c;使用不频繁。…...

关于DDD的贫血模型和充血模型到底是什么区别?

贫血模型和充血模型是两种不同的设计模式&#xff0c;用于处理复杂的业务逻辑和数据操作。 贫血模型是指将业务逻辑和数据操作分离&#xff0c;业务逻辑在服务层处理&#xff0c;数据操作在数据访问层处理。这种设计模式的优点是易于维护和测试&#xff0c;但是在处理复杂的业…...

让BI自动生成零售数据分析报表?用模板

不知道BI零售数据分析怎么做&#xff1f;用模板。 没时间去整理数据、计算零售数据分析指标&#xff1f;用模板。 不知道怎么做出炫酷直观的零售数据分析报表&#xff1f;用模板。 …… 奥威BI零售数据分析模板全新上线&#xff0c;数据分析模型、数据可视图表、关键指标以…...

以吉祥物宣传片实力出圈!吉祥物三维动画宣传片怎么制作?

首届学青会吉祥物“壮壮”、“美美”在宣传片中展示了举重、打羽毛球、游泳等运动姿态&#xff0c;靠着可爱的虚拟形象萌出圈&#xff01; *图片源于网络 在数字化时代&#xff0c;吉祥物三维动画宣传片已成为众多大型活动、品牌宣发、文旅城市宣传的一大途径&#xff0c;如学…...

TensorFlow(1):深度学习的介绍

1 深度学习与机器学习的区别 学习目标&#xff1a;知道深度学习与机器学习的区别 区别&#xff1a;深度学习没有特征提取 1.1 特征提取方面 机器学习的特征工程步骤是要靠手动完成的&#xff0c;而且需要大量领域专业知识深度学习通常由多个层组成&#xff0c;它们通常将更简…...

C# 如何优雅的写代码[进阶篇]

文章目录 前言相关文章如何让代码优雅知识点补充enum枚举类型?null判定 前言 我之前发布过一些篇章&#xff0c;是专门关于代码优化的&#xff0c;距离我上一次[如何优雅的写C#]已经过去半年时间了&#xff0c;最近我又研究出了一些新东西。 相关文章 如何优雅的写C#&#x…...

【人工智能】神经网络的优化器optimizer(二):Adagrad自适应学习率优化器

一.自适应梯度算法Adagrad概述 Adagrad&#xff08;Adaptive Gradient Algorithm&#xff09;是一种自适应学习率的优化算法&#xff0c;由Duchi等人在2011年提出。其核心思想是针对不同参数自动调整学习率&#xff0c;适合处理稀疏数据和不同参数梯度差异较大的场景。Adagrad通…...

23-Oracle 23 ai 区块链表(Blockchain Table)

小伙伴有没有在金融强合规的领域中遇见&#xff0c;必须要保持数据不可变&#xff0c;管理员都无法修改和留痕的要求。比如医疗的电子病历中&#xff0c;影像检查检验结果不可篡改行的&#xff0c;药品追溯过程中数据只可插入无法删除的特性需求&#xff1b;登录日志、修改日志…...

【网络安全产品大调研系列】2. 体验漏洞扫描

前言 2023 年漏洞扫描服务市场规模预计为 3.06&#xff08;十亿美元&#xff09;。漏洞扫描服务市场行业预计将从 2024 年的 3.48&#xff08;十亿美元&#xff09;增长到 2032 年的 9.54&#xff08;十亿美元&#xff09;。预测期内漏洞扫描服务市场 CAGR&#xff08;增长率&…...

相机从app启动流程

一、流程框架图 二、具体流程分析 1、得到cameralist和对应的静态信息 目录如下: 重点代码分析: 启动相机前,先要通过getCameraIdList获取camera的个数以及id,然后可以通过getCameraCharacteristics获取对应id camera的capabilities(静态信息)进行一些openCamera前的…...

C++.OpenGL (10/64)基础光照(Basic Lighting)

基础光照(Basic Lighting) 冯氏光照模型(Phong Lighting Model) #mermaid-svg-GLdskXwWINxNGHso {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-GLdskXwWINxNGHso .error-icon{fill:#552222;}#mermaid-svg-GLd…...

使用Matplotlib创建炫酷的3D散点图:数据可视化的新维度

文章目录 基础实现代码代码解析进阶技巧1. 自定义点的大小和颜色2. 添加图例和样式美化3. 真实数据应用示例实用技巧与注意事项完整示例(带样式)应用场景在数据科学和可视化领域,三维图形能为我们提供更丰富的数据洞察。本文将手把手教你如何使用Python的Matplotlib库创建引…...

消息队列系统设计与实践全解析

文章目录 &#x1f680; 消息队列系统设计与实践全解析&#x1f50d; 一、消息队列选型1.1 业务场景匹配矩阵1.2 吞吐量/延迟/可靠性权衡&#x1f4a1; 权衡决策框架 1.3 运维复杂度评估&#x1f527; 运维成本降低策略 &#x1f3d7;️ 二、典型架构设计2.1 分布式事务最终一致…...

使用SSE解决获取状态不一致问题

使用SSE解决获取状态不一致问题 1. 问题描述2. SSE介绍2.1 SSE 的工作原理2.2 SSE 的事件格式规范2.3 SSE与其他技术对比2.4 SSE 的优缺点 3. 实战代码 1. 问题描述 目前做的一个功能是上传多个文件&#xff0c;这个上传文件是整体功能的一部分&#xff0c;文件在上传的过程中…...

电脑桌面太单调,用Python写一个桌面小宠物应用。

下面是一个使用Python创建的简单桌面小宠物应用。这个小宠物会在桌面上游荡&#xff0c;可以响应鼠标点击&#xff0c;并且有简单的动画效果。 import tkinter as tk import random import time from PIL import Image, ImageTk import os import sysclass DesktopPet:def __i…...

qt+vs Generated File下的moc_和ui_文件丢失导致 error LNK2001

qt 5.9.7 vs2013 qt add-in 2.3.2 起因是添加一个新的控件类&#xff0c;直接把源文件拖进VS的项目里&#xff0c;然后VS卡住十秒&#xff0c;然后编译就报一堆 error LNK2001 一看项目的Generated Files下的moc_和ui_文件丢失了一部分&#xff0c;导致编译的时候找不到了。因…...