|
1 | | -# iOSMB-Router |
| 1 | +# iOSMB-Router |
| 2 | + |
| 3 | +Automated message routing and auto-reply service for iOSMB (iOS Message Bridge). Create rules to forward messages from specific senders to multiple recipients or automatically reply to incoming messages. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Message Forwarding** - Redirect messages from specific senders to multiple recipients |
| 8 | +- **Auto-Reply** - Automatically respond to messages based on sender |
| 9 | +- **YAML Configuration** - Easy-to-read and modify rules |
| 10 | +- **Real-time Processing** - Processes messages as they arrive via WebSocket |
| 11 | +- **Docker Support** - Easy deployment with Docker and Docker Compose |
| 12 | +- **Environment Variables** - Configure server connection without modifying code |
| 13 | + |
| 14 | +## Quick Start |
| 15 | + |
| 16 | +### Using Docker Compose (Recommended) |
| 17 | + |
| 18 | +1. **Copy the environment file:** |
| 19 | + ```bash |
| 20 | + cd iOSMB-Router |
| 21 | + cp .env.example .env |
| 22 | + ``` |
| 23 | + |
| 24 | +2. **Edit `.env` with your iOSMB server details:** |
| 25 | + ```bash |
| 26 | + IOSMB_SERVER_IP=192.168.1.100 |
| 27 | + IOSMB_SERVER_PORT=8180 |
| 28 | + IOSMB_SERVER_PASSWORD=your-server-password |
| 29 | + IOSMB_SERVER_SSL=false |
| 30 | + ``` |
| 31 | + |
| 32 | +3. **Create your rules file:** |
| 33 | + ```bash |
| 34 | + cp rules.example.yaml rules.yaml |
| 35 | + # Edit rules.yaml with your custom rules |
| 36 | + ``` |
| 37 | + |
| 38 | +4. **Start the service:** |
| 39 | + ```bash |
| 40 | + docker-compose up -d |
| 41 | + ``` |
| 42 | + |
| 43 | +5. **View logs:** |
| 44 | + ```bash |
| 45 | + docker-compose logs -f |
| 46 | + ``` |
| 47 | + |
| 48 | +### Using Go Directly |
| 49 | + |
| 50 | +1. **Install dependencies:** |
| 51 | + ```bash |
| 52 | + go mod download |
| 53 | + ``` |
| 54 | + |
| 55 | +2. **Create configuration:** |
| 56 | + ```bash |
| 57 | + cp .env.example .env |
| 58 | + cp rules.example.yaml rules.yaml |
| 59 | + # Edit both files |
| 60 | + ``` |
| 61 | + |
| 62 | +3. **Run the service:** |
| 63 | + ```bash |
| 64 | + source .env |
| 65 | + go run main.go |
| 66 | + ``` |
| 67 | + |
| 68 | +## Rules Configuration |
| 69 | + |
| 70 | +Rules are defined in `rules.yaml` using a simple YAML format: |
| 71 | + |
| 72 | +### Redirect Rule Example |
| 73 | + |
| 74 | +Forward all messages from Netflix to multiple phone numbers: |
| 75 | + |
| 76 | +```yaml |
| 77 | +rules: |
| 78 | + - name: "Forward Netflix notifications" |
| 79 | + type: redirect |
| 80 | + from_sender: "Netflix" |
| 81 | + to_receivers: |
| 82 | + - "+33722335544" |
| 83 | + - "+33755442211" |
| 84 | + enabled: true |
| 85 | +``` |
| 86 | +
|
| 87 | +### Auto-Reply Rule Example |
| 88 | +
|
| 89 | +Automatically reply to a specific sender: |
| 90 | +
|
| 91 | +```yaml |
| 92 | +rules: |
| 93 | + - name: "Auto reply to friend" |
| 94 | + type: auto_reply |
| 95 | + from_sender: "+33233556699" |
| 96 | + reply_text: "I will answer you shortly" |
| 97 | + enabled: true |
| 98 | +``` |
| 99 | +
|
| 100 | +### Rule Properties |
| 101 | +
|
| 102 | +| Property | Type | Required | Description | |
| 103 | +|----------|------|----------|-------------| |
| 104 | +| `name` | string | Yes | Descriptive name for the rule | |
| 105 | +| `type` | string | Yes | Rule type: `redirect` or `auto_reply` | |
| 106 | +| `from_sender` | string | Yes | Sender name or number to match (case-insensitive substring) | |
| 107 | +| `to_receivers` | array | For redirect | List of phone numbers to forward to | |
| 108 | +| `reply_text` | string | For auto_reply | Text to send as automatic reply | |
| 109 | +| `enabled` | boolean | Yes | Enable/disable the rule without deleting it | |
| 110 | + |
| 111 | +## Environment Variables |
| 112 | + |
| 113 | +| Variable | Default | Description | |
| 114 | +|----------|---------|-------------| |
| 115 | +| `IOSMB_SERVER_IP` | `192.168.1.100` | iOSMB server IP address | |
| 116 | +| `IOSMB_SERVER_PORT` | `8180` | iOSMB server port | |
| 117 | +| `IOSMB_SERVER_PASSWORD` | - | iOSMB server password | |
| 118 | +| `IOSMB_SERVER_SSL` | `false` | Use WSS instead of WS | |
| 119 | +| `IOSMB_RULES_FILE` | `rules.yaml` | Path to rules configuration file | |
| 120 | + |
| 121 | +## How It Works |
| 122 | + |
| 123 | +1. **Connects** to your iOSMB server via WebSocket (same connection as the web client) |
| 124 | +2. **Authenticates** using the server password |
| 125 | +3. **Listens** for incoming messages in real-time |
| 126 | +4. **Matches** messages against your defined rules |
| 127 | +5. **Executes** actions (forward or auto-reply) when rules match |
| 128 | + |
| 129 | +``` |
| 130 | +┌─────────────┐ ┌─────────────┐ ┌─────────────┐ |
| 131 | +│ iPhone │ ──────> │ iOSMB Server│ ──────> │ iOSMB-Relay │ |
| 132 | +│ (Messages) │ │ (WebSocket)│ │ (Rules) │ |
| 133 | +└─────────────┘ └─────────────┘ └─────────────┘ |
| 134 | + │ |
| 135 | + ▼ |
| 136 | + ┌──────────────────┐ |
| 137 | + │ Forward to phones│ |
| 138 | + │ or Auto-reply │ |
| 139 | + └──────────────────┘ |
| 140 | +``` |
| 141 | +
|
| 142 | +## Use Cases |
| 143 | +
|
| 144 | +### Forward Important Notifications |
| 145 | +```yaml |
| 146 | +- name: "Forward bank alerts" |
| 147 | + type: redirect |
| 148 | + from_sender: "Bank" |
| 149 | + to_receivers: |
| 150 | + - "+33600000001" # Your work phone |
| 151 | + - "+33600000002" # Your partner's phone |
| 152 | + enabled: true |
| 153 | +``` |
| 154 | + |
| 155 | +### Out of Office Auto-Reply |
| 156 | +```yaml |
| 157 | +- name: "Vacation auto-reply" |
| 158 | + type: auto_reply |
| 159 | + from_sender: "work" # Matches any sender with "work" in name |
| 160 | + reply_text: "I'm on vacation until Monday. For urgent matters, call +33600000000" |
| 161 | + enabled: true |
| 162 | +``` |
| 163 | +
|
| 164 | +### Emergency Contact Forwarding |
| 165 | +```yaml |
| 166 | +- name: "Forward urgent messages" |
| 167 | + type: redirect |
| 168 | + from_sender: "urgent" |
| 169 | + to_receivers: |
| 170 | + - "+33600000001" |
| 171 | + enabled: true |
| 172 | +``` |
| 173 | +
|
| 174 | +### Delivery Acknowledgment |
| 175 | +```yaml |
| 176 | +- name: "Confirm delivery notifications" |
| 177 | + type: auto_reply |
| 178 | + from_sender: "UPS" |
| 179 | + reply_text: "Thank you for the delivery update!" |
| 180 | + enabled: false |
| 181 | +``` |
| 182 | +
|
| 183 | +## Docker Production Deployment |
| 184 | +
|
| 185 | +For production with Docker Swarm: |
| 186 | +
|
| 187 | +```yaml |
| 188 | +version: '3.9' |
| 189 | + |
| 190 | +services: |
| 191 | + iosmb-router: |
| 192 | + image: ghcr.io/enzodjabali/iosmb-router:latest |
| 193 | + environment: |
| 194 | + - IOSMB_SERVER_IP=${IOSMB_SERVER_IP} |
| 195 | + - IOSMB_SERVER_PORT=${IOSMB_SERVER_PORT} |
| 196 | + - IOSMB_SERVER_PASSWORD=${IOSMB_SERVER_PASSWORD} |
| 197 | + - IOSMB_SERVER_SSL=${IOSMB_SERVER_SSL} |
| 198 | + configs: |
| 199 | + - source: relay_rules |
| 200 | + target: /app/rules.yaml |
| 201 | + deploy: |
| 202 | + replicas: 1 |
| 203 | + restart_policy: |
| 204 | + condition: on-failure |
| 205 | + |
| 206 | +configs: |
| 207 | + relay_rules: |
| 208 | + file: ./rules.yaml |
| 209 | +``` |
| 210 | +
|
| 211 | +## Building from Source |
| 212 | +
|
| 213 | +```bash |
| 214 | +# Clone the repository |
| 215 | +cd iOSMB-Router |
| 216 | + |
| 217 | +# Build binary |
| 218 | +go build -o iosmb-router . |
| 219 | + |
| 220 | +# Run |
| 221 | +./iosmb-router |
| 222 | +``` |
| 223 | + |
| 224 | +## Troubleshooting |
| 225 | + |
| 226 | +### Connection Issues |
| 227 | +- Verify `IOSMB_SERVER_IP` and `IOSMB_SERVER_PORT` are correct |
| 228 | +- Ensure the iOSMB server is running and accessible |
| 229 | +- Check if SSL is required (`IOSMB_SERVER_SSL=true`) |
| 230 | + |
| 231 | +### Rules Not Matching |
| 232 | +- The `from_sender` field uses case-insensitive substring matching |
| 233 | +- Example: `"Netflix"` will match "netflix", "NETFLIX", "Netflix Support" |
| 234 | +- Check logs to see incoming message details |
| 235 | + |
| 236 | +### Messages Not Sending |
| 237 | +- Verify phone numbers include country code (e.g., `+33...`) |
| 238 | +- Check that the iOSMB server allows message sending |
| 239 | +- View logs for error messages |
| 240 | + |
| 241 | +## Logs |
| 242 | + |
| 243 | +The service provides detailed logging: |
| 244 | + |
| 245 | +``` |
| 246 | +iOSMB-Router starting... |
| 247 | +Server: 192.168.1.100:8180 (SSL: false) |
| 248 | +Loaded 5 rules from rules.yaml |
| 249 | +Connecting to ws://192.168.1.100:8180... |
| 250 | +Connected to iOSMB server |
| 251 | +[NEW MESSAGE] From: Netflix | Text: Your payment was successful... |
| 252 | +Rule matched: Forward Netflix notifications |
| 253 | +Redirecting to +33722335544 |
| 254 | +Redirecting to +33755442211 |
| 255 | +Message sent successfully |
| 256 | +``` |
| 257 | + |
| 258 | +## License |
| 259 | + |
| 260 | +MIT License |
| 261 | + |
| 262 | +## Credits |
| 263 | + |
| 264 | +Part of the iOSMB (iOS Message Bridge) ecosystem. |
0 commit comments