使用便宜的4g模块 配合docker来转发你的短信 libgammu smsforwarder golang

为什么会有这篇文章

刚开始一直在用SmsFordarder在安卓手机上进行短信转发,长期占用安卓手机,老化的电池也不放心,咸鱼发现有便宜可用的支持短信的4g模块,顺带研究一下相关的内容,就自己用golang写了相关服务。

我自己的硬件配置

主板 orange pi5 max 很不错的板子,我在上面跑frigate、jellyfin 能解码,能跑图像识别。
cpu rk3588 x86和arm64都可以
系统 ubuntu server22.04 因为还在跑redroid,需要5.10内核,所有没用24.04系统
4g模块 移远的EC200T-CN 咸鱼10块钱,cat4速率,但是我不需要用它上网,便宜,有短信,有通话接口就行。
usb转4g板子 咸鱼搜 mini pcie转4g模块 20块钱
天线 2根 IPEX一代接口
sim卡信息 中国联通 没其他卡,没测试移动和电信

软件配置

  • docker就行了。
  • 相关代码:
  • 我用golang写的一份读取短信和来电的服务gammu-web
  • 配合golang的通知服务ForwardSMS

准备转发配置文件forward.yaml

# 如果有all这个配置,就是默认所有短信都会转发给这个企业微信机器人,建议发送给管理员,或者直接删除关闭
all:
    rule: all
    type: all
    notify: wechat
    url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxx

# 从上到下依次为 项目名称、规则(使用关键字匹配)
测试:
    rule: 测试DDD
    type: keyword
    notify: wechat
    url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxx

# 正则匹配规则
工单号:
    rule: "\\d{8}" # 匹配8位数字
    type: regex
    notify: gotify
    url: https://gotify.example.com
    token: your_app_token

# 转发给ios用它。
bark:
    notify: bark
    type: all
    rule: all
    url: "https://api.day.app/xxxx"

# 转发给安卓用它。
gtify:
    notify: gotify
    type: all
    rule: all
    url: "https://gotify.example.com"
    token: "your_app_token"

# emm邮箱转发
email:
    notify: email
    type: all
    rule: all
    smtp_host: "smtp.qq.com"
    smtp_port: "587"
    username: "[email protected]"
    password: "授权码"
    from: "[email protected]"
    to: "[email protected]"

配置docker-compose.yaml (支持x86和arm64)

version: "3"
services:
  # https://github.com/scjtqs2/ForwardSMS
  forwardsms:
    image:  ghcr.io/scjtqs2/forwardsms/forwardsms:latest
    environment:
      - FORWARD_SECRET=your_shared_secret_here
      - TZ=Asia/Shanghai
      - HTTP_PORT=8080
    volumes:
      # 挂载上面配置的推送文件
      - ./forward.yaml:/data/config/forward.yaml
    restart: always
    expose:
      - 8080

  # https://github.com/scjtqs2/gammu-web
  gammu-web:
    image: ghcr.io/scjtqs2/gammu-web:latest
    environment:
        - FORWARD_ENABLED=1
        # 写死
        - FORWARD_URL=http://forwardsms:8080/api/v1/sms/receive
        # 和forwardsms里面的要一致。
        - FORWARD_SECRET=your_shared_secret_here
        - TZ=Asia/Shanghai
        # 转发通知携带的标识。
        - PHONE_ID=SMS1_186xxxxxxxx
        - ATCONNECTION=at9600
        # ec200t-cn 默认的管理接口就是/dev/ttyUSB1(能同时收发短信,还能读取来电显示数据用来达到转发来电通知)。根据实际情况自行调整。
        - USB_PORT=/dev/ttyUSB1
        - API_PORT=21234
        # web网页访问用到。
        - API_TOKEN=your_shared_token_here
        - GAMMU_DEBUG=false
        - DEBUG=0
        - CALL_FORWARD_ENABLED=true
        - CALL_FORWARD_URL=http://forwardsms:8080/api/v1/call/receive
    volumes:
      - ./data:/data
    # 加了这个,就不用挨个去映射 /dev/ttyUSBx了
    privileged: true
    restart: always
    ports:
      - 21234:21234

浏览全部

tailscale 旁路模式配置组网

环境说明

老家的路由器是ac68u,内存小,cpu性能也不太行,在上面跑一个小猫咪就内存耗尽了,没多余的内存跑tailscale了。因此我将tailscale装到了一个linux虚拟机系统上面(ubuntu 24.04)。
  1. 主路由ac68u,网段 192.168.0.0/24
  2. ubuntu虚拟机(也可以是树莓派等arm的开发版,甚至是n1),ip:192.168.0.128(需要固定,可以在主路由的dhcp分配静态ip)
  3. 对端组网的网段:192.168.50.0/24,192.168.200.0/24

浏览全部

ubuntu 22.04 上配置 postfix + cyrus sasl 实现smtp relay server。用来给其他服务器中转使用

目前很多云服务器都封死了25端口的out流量。无法发送邮件,如果要搭建邮局,就需要一个能发smtp的服务器做中转。

安装必备的包

sudo apt-get install postfix libsasl2-2 sasl2-bin libsasl2-modules db-util procmail libsasl2-modules-gssapi-heimdal

配置中转smtp用的端口

vim /etc/services
# 找到 `smtp  25/tcp mail`
# 在下面添加一行
smtp2           41067/tcp       mail

浏览全部

在老旧的asus设备(ac68u)上 安装 tailscale 客户端

题外话

我这台ac68u确实太老了,已经快10个年头了。 即便刷了梅林系统,386版本,软件中心也没有tailscale的app。 这个老旧的软件中心,已经很多年没更新维护过了,因此要安装tailscale只能自己想办法了。

新方式:koolshare应用中心离线包(推荐)

https://github.com/scjtqs2/merlin_tailscale_arm384

前置要求

  • 一台华硕的路由器,这里用的armhf的ac68U,官方固件、梅林固件都可以。
  • 有足够的jffs剩余空间,armhf版本的版本的tailscale+tailscaled要吃掉40M的空间。不够的可以上usb。当然,可以随意存在哪,不是非得jffs,脚本的绝对路径能找到就行。
  • 一个tailscale.sh脚本,用来启动tailscaled和tailscale。

浏览全部

来自民间的 nvidia的 vgpu 授权服务 fastapi-dls

转载来自

fastapi源码

FastAPI-DLS

Minimal Delegated License Service (DLS).

Compatibility tested with official DLS 2.0.1.

This service can be used without internet connection. Only the clients need a connection to this service on configured port.

Official Links

  • https://git.collinwebdesigns.de/oscar.krause/fastapi-dls (Private Git)
  • https://gitea.publichub.eu/oscar.krause/fastapi-dls (Public Git)
  • https://hub.docker.com/r/collinwebdesigns/fastapi-dls (Docker-Hub collinwebdesigns/fastapi-dls:latest)

All other repositories are forks! (which is no bad – just for information and bug reports)

浏览全部

gen8 给 debian/ubuntu 安装 hp-ams (Agentless Management Service)

hpe 安装完 debian/ubuntu 系的linux系统后,会发现 ilo 里面的 ams(Agentless Management Service) 是不可用状态。而且官方的驱动页面也仅仅提供centos系的rpm包下载。因此,我们要自己想办法。

wget https://downloads.linux.hpe.com/SDR/repo/mcp/pool/non-free/hp-ams_2.8.3-3056.1ubuntu16_amd64.deb
sudo dpkg -i hp-ams_2.8.3-3056.1ubuntu16_amd64.deb

这样就装上了。

oracle cloud 的ubuntu系统下ufw 防火墙规则不生效处理

前言

  • 因为 oracle cloud的 linux 都是默认使用了iptables的防火墙规则,导致了ufw的规则不生效。
  • 如果你喜欢Iptables规则方式配置防火墙,使用Iptables就行。

干掉预制的Iptables规则

sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F
# 切换到超级用户
sudo -i
# 删除规则
rm -rf /etc/iptables
# 重启生效
reboot

云服务器 对外访问25端口被封 ? 利用iptables 绕过 被封的 output 25 port。

用 iptables 将 25出去的流量,转发到其他端口出去。

iptables -t nat -A OUTPUT -p tcp --dport 25 -j DNAT --to 10.0.0.10:10025
这里 将 25 端口出去的流量转发到了1025端口。 这里 10.0.0.10 为 代理服务器 的ip地址。

找一台正常发送25端口的服务器,配置成代理服务器。

  1. 安装postfix
sudo apt-get install postfix

sudo tee /etc/postfix/main.cf<<EOF
inet_interfaces = all
#inet_interfaces = localhost
mynetworks = 0.0.0.0/0
EOF

sudo systemctl restart postfix
  1. 配置被允许代理的服务器的ip。
sudo tee smtp-proxy.sh<<EOF
#!/bin/bash
# 被允许的ip
IPS=(
129.1.1.1
132.2.2.2
132.3.3.3
)
for IP in {IPS[@]}
do
iptables -t nat -A PREROUTING -p tcp -s{IP} --dport 10025 -j REDIRECT --to-ports 25
iptables -A INPUT -p tcp -s ${IP} --dport 25 -j ACCEPT
done
EOF

sudo chmod +x smtp-proxy.sh
./smtp-proxy.sh
  1. 配好防火墙:
sudo ufw default  deny
sudo ufw allow 10025
sudo ufw allow  from 129.1.1.1
sudo ufw allow  from 132.2.2.2
sudo ufw allow  from 132.3.3.3