admin 发布的文章

总结,设置代理要用小写字母:

export http_proxy=http://127.0.0.1:10809
export https_proxy=http://127.0.0.1:10809

测试过程非常曲折。先说明我这个代理是全局代理。
1,首先我都是用大写来设置的:

export HTTP_PROXY=http://127.0.0.1:10809
export HTTPS_PROXY=http://127.0.0.1:10809

结果curl http://cip.cc 返回真实IP
结果curl https://cip.cc 返回代理IP

2,这次尝试curl -x http://127.0.0.1:10809 http://cip.cc
这次返回的是代理IP
说明本地搭的代理是没问题的。
设置的代理变量HTTP_PROXY失效了。

3, 重新用小写设置一次,

export http_proxy=http://127.0.0.1:10809

这次curl http://cip.cc
终于返回了代理的IP。

但是此时环境变量里面有3个代理设置:

HTTPS_PROXY=http://127.0.0.1:10809
HTTP_PROXY=http://127.0.0.1:10809
http_proxy=http://127.0.0.1:10809

也就是说此时:
HTTPS_PROXY是生效的。
HTTP_PROXY是不生效的。
http_proxy是生效的。

后来经过测试:
https_proxy也是可以生效的。

所以,为了统一,还是都用小写的吧。于是有了开头结论:

export http_proxy=http://127.0.0.1:10809
export https_proxy=http://127.0.0.1:10809

后记:
测试WINDOWS,正好相反。WINDOWS只认大写,不认小写。WINDOWS命令:

set HTTPS_PROXY=http://127.0.0.1:10809
set HTTP_PROXY=http://127.0.0.1:10809

上述测试环境:
Ubuntu 22.04.1 LTS
Debian 10
Windows 11 专业版

一直都不是很熟悉。今天误操作了一下。记录一下:
清空iptables
iptables -F

备份iptables
iptables-save > iptables_bak.txt

恢复
iptables-restore < iptables_bak.txt

允许某个特定IP访问某个端口,常见于反代。

iptables -A INPUT -p tcp --dport 8999 -s V.P.S.IP -j ACCEPT  //允许VPS的IP访问
iptables -A INPUT -p tcp --dport 8999 -j DROP  //不允许其他机器的访问

-A Append,追加在最后。但是如果最后一条是REJECT ALL。那么当添加ACCEPT的时候,就要添加在前面规则的中间,
这时候就要用-I insert。插入到中间。

基本操作就是:
iptables -A|I

搞了个行车记录仪。
双击批处理,自动把今天录得,拷贝到指定目录。省得我自己每天去翻目录,备份了。

@echo off
setlocal enabledelayedexpansion

set "targetDirectory=E:\DCIM\100MEDIA"
set "baseDestinationDirectory=D:\SARGO\2023"

REM 获取今天的日期
for /f "usebackq tokens=1 delims=" %%a in (`wmic os get localdatetime ^| findstr /r [0-9]`) do (
    set "datetime=%%a"
)

set "today=!datetime:~0,8!"
set "destinationDirectory=%baseDestinationDirectory%\%today%"

REM 创建以今天日期命名的目标目录
if not exist "%destinationDirectory%" (
    mkdir "%destinationDirectory%"
)

REM 遍历目标目录中的文件
for %%F in ("%targetDirectory%\*.*") do (
    REM 获取文件的修改时间
    echo "%%F"
    for /f "usebackq tokens=1-3 delims=/ " %%i in (`dir /t:w "%%F" ^| findstr "^[0-9]"`) do (
        set "fileDate=%%i%%j%%k"
    )

    REM 判断文件是否是今天创建的
    if "!fileDate!"=="!today!" (
        echo Moving %%~nxF to the destination directory.
        move "%%F" "%destinationDirectory%\"
        echo "move" "%%F" "%destinationDirectory%\"
    )
)

echo All today's files have been moved to the destination directory (%today%).