メール本文とDBの照合による自動判定・転送フロー¶
本ページでは、ロボシュタインで受信した依頼メールの本文から「ホスト名」と「ポート番号」を抽出し、PCローカル内のSQLiteデータベースに登録されたホワイトリスト(許可リスト)と自動で照合・仕分けを行うサンプルフローを解説します。
定常的な依頼や対応済みの通知を自動で「対応終了」としてクローズし、未登録のイレギュラーなメールだけを人間の元へ「AWS SES」で転送する、実務直結のフィルタリングシステムです。
サンプルフローのインポート¶
ご利用のロボシュタイン(Node-REDコア)のバージョン環境に合わせて、以下のいずれかのJSONデータをコピーしてインポートを実行してください。
💡 フローのグループ機能について
本フローでは、複数のノードを役割ごとに四角い枠で囲んで視覚的に整理できる「グループ機能」を採用しています。フローが大規模になった際、どのブロックが何の処理をしているのかが一目で判別できるようになり、開発やメンテナンスの効率が向上します。
⚠️ インポート時にエラーが表示される場合
もしJSONデータを読み込んだときに、画面に以下のエラーが表示された場合の解決方法です。
「認識できない型が読み込まれました: sqlite, sqlitedb」
このエラーは、ロボシュタインの中にデータベース(SQLite)を動かすための部品が足りていないことが原因です。以下の簡単な手順で部品を追加すれば、エラーが出なくなります。
- ロボシュタイン画面の右上にある メニューアイコン(三本線のマーク) をクリックします。
- メニューの中から 「パレットの管理」 を選んでクリックします。
- 開いた画面の上側にある 「ノードを追加」 というタブに切り替えます。
- 検索ボックスに
node-red-node-sqliteと入力します。 - 表示された部品の右側にある 「ノードを追加」 ボタンをクリックしてインストールします。
インストールが終わったら、もう一度JSONデータのインポートを試してください。
グループ機能対応版(v1.3以降向け)¶
Node-RED v1.3以降の「グループ化機能」に対応した環境向けのJSONです。ノードが処理ブロックごとに枠線で視覚的に整理されて展開されます。
サンプルフローのJSONコードを展開する
json
[
{
"id": "d04ff5df9582e88d",
"type": "tab",
"label": "受信メール・DB照合自動判定フィルタ",
"disabled": false,
"info": "",
"env": []
},
{
"id": "d69b8e6433d65506",
"type": "group",
"z": "d04ff5df9582e88d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"841abdb866c4d9c1",
"dfa8695b176640cc",
"0b8a820d3a14bcce",
"167330cccd07396e",
"9b0941814e072aa9",
"fb381d93521c0936",
"6170f7dfde309799",
"6bb32b7a1818cbec",
"f0d2e578a3555011",
"d6521dc8772d42f6",
"20d6617485c2d070",
"1f99ae09c36abd56",
"6161e44e6a75d83e",
"5310da3522b11f4d",
"7353cc60e655b832"
],
"x": 14,
"y": 19,
"w": 1492,
"h": 262
},
{
"id": "e77873164f3822de",
"type": "group",
"z": "d04ff5df9582e88d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"1d6e942799849e63",
"32936b4c1c197a8e",
"6b7244fee2cda7ca",
"6331d01bb8fa200b",
"92df9e177c7278e7",
"9c27a6d644176971",
"958ed266dbca81fb",
"479aff680d6e37a6",
"ccb2a825497be8a9",
"d2379e257d9b9894",
"445c2fbbc8e1ca15",
"47286d26eceeeac6",
"7d88104aa6e1b1f1",
"3acd624452b7b286",
"29ccef12bab7af2d",
"7af1ec770a2c40c1",
"74b8d92f1e865335",
"e6104ea47feb1818",
"157442fa1c971ef0",
"0a7fb27784c0471b",
"eb0caf7877cf3bf0",
"96c2cc2c5e5218a1",
"6e6e4092e08b0bbb",
"ebb3138d2224c16f",
"214d0000dd469402"
],
"x": 14,
"y": 319,
"w": 1572,
"h": 402
},
{
"id": "8ebcc040c928d3d4",
"type": "group",
"z": "d04ff5df9582e88d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"1c6a3a8d786561b2",
"dcf0c36d3081d71c",
"e5619b26517bf397",
"7e49d696b4701bb7",
"9b8e93189c0dfd7c",
"e91e967552f08838",
"0b011fc688e9c37e",
"71ca2d3591034d0d",
"8ec657def0fe1635",
"e05adf419b7652cb"
],
"x": 14,
"y": 759,
"w": 1112,
"h": 202
},
{
"id": "e5619b26517bf397",
"type": "sqlite",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"mydb": "494938546e25ebb6",
"sqlquery": "msg.topic",
"sql": "",
"name": "テーブル削除",
"x": 490,
"y": 920,
"wires": [
[
"7e49d696b4701bb7"
]
]
},
{
"id": "7e49d696b4701bb7",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 650,
"y": 920,
"wires": []
},
{
"id": "9b8e93189c0dfd7c",
"type": "function",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "SQL構文",
"func": "msg.topic = \"drop table hostPortListTable;\";\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 920,
"wires": [
[
"e5619b26517bf397"
]
]
},
{
"id": "dcf0c36d3081d71c",
"type": "inject",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "テーブル削除",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 150,
"y": 920,
"wires": [
[
"9b8e93189c0dfd7c"
]
]
},
{
"id": "e91e967552f08838",
"type": "comment",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "作成済みのリスト情報のテーブルを削除します.",
"info": "",
"x": 920,
"y": 920,
"wires": []
},
{
"id": "841abdb866c4d9c1",
"type": "comment",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "HostとPortを組み合わせたリスト情報の事前登録",
"info": "",
"x": 220,
"y": 60,
"wires": []
},
{
"id": "dfa8695b176640cc",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "リスト情報の入力(全角スペース区切り)",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "H-E1-G03F09 1/1/9\nH-E1-G04F01 1/1/18\nH-E1-G05F01 1/1/15",
"output": "str",
"x": 400,
"y": 240,
"wires": [
[
"fb381d93521c0936"
]
]
},
{
"id": "0b8a820d3a14bcce",
"type": "inject",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "リスト更新",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 140,
"y": 240,
"wires": [
[
"dfa8695b176640cc"
]
]
},
{
"id": "167330cccd07396e",
"type": "sqlite",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"mydb": "494938546e25ebb6",
"sqlquery": "fixed",
"sql": "CREATE TABLE IF NOT EXISTS hostPortListTable (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n hostName TEXT NOT NULL UNIQUE,\n port TEXT NOT NULL\n);",
"name": "テーブル作成",
"x": 330,
"y": 120,
"wires": [
[
"9b0941814e072aa9"
]
]
},
{
"id": "9b0941814e072aa9",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 490,
"y": 120,
"wires": []
},
{
"id": "fb381d93521c0936",
"type": "split",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "改行ごとに分割",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 680,
"y": 240,
"wires": [
[
"6bb32b7a1818cbec"
]
]
},
{
"id": "6170f7dfde309799",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1410,
"y": 240,
"wires": []
},
{
"id": "6bb32b7a1818cbec",
"type": "change",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "hostとportの抽出",
"rules": [
{
"t": "set",
"p": "hostName",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "change",
"p": "hostName",
"pt": "msg",
"from": "^(\\S+) (\\S+)$",
"fromt": "re",
"to": "$1",
"tot": "str"
},
{
"t": "set",
"p": "setPort",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "change",
"p": "setPort",
"pt": "msg",
"from": "^(\\S+) (\\S+)$",
"fromt": "re",
"to": "$2",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 890,
"y": 240,
"wires": [
[
"f0d2e578a3555011"
]
]
},
{
"id": "f0d2e578a3555011",
"type": "function",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "SQL構文",
"func": "msg.topic = `INSERT OR IGNORE INTO hostPortListTable `;\nmsg.topic += `(hostName, port) `;\nmsg.topic += `VALUES ('${msg.hostName}', '${msg.setPort}');`;\nreturn msg;`",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1080,
"y": 240,
"wires": [
[
"7353cc60e655b832"
]
]
},
{
"id": "d6521dc8772d42f6",
"type": "inject",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "テーブル一覧",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 150,
"y": 180,
"wires": [
[
"20d6617485c2d070"
]
]
},
{
"id": "20d6617485c2d070",
"type": "function",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "SQL構文",
"func": "msg.topic = \"SELECT * FROM sqlite_master WHERE type='table' AND name='hostPortListTable'\";\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 180,
"wires": [
[
"1f99ae09c36abd56"
]
]
},
{
"id": "1f99ae09c36abd56",
"type": "sqlite",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"mydb": "494938546e25ebb6",
"sqlquery": "msg.topic",
"sql": "tables",
"name": "デーブルリスト",
"x": 500,
"y": 180,
"wires": [
[
"6161e44e6a75d83e"
]
]
},
{
"id": "6161e44e6a75d83e",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 670,
"y": 180,
"wires": []
},
{
"id": "5310da3522b11f4d",
"type": "inject",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"name": "テーブル作成",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 150,
"y": 120,
"wires": [
[
"167330cccd07396e"
]
]
},
{
"id": "7353cc60e655b832",
"type": "sqlite",
"z": "d04ff5df9582e88d",
"g": "d69b8e6433d65506",
"mydb": "494938546e25ebb6",
"sqlquery": "msg.topic",
"sql": "",
"name": "データ追加",
"x": 1250,
"y": 240,
"wires": [
[
"6170f7dfde309799"
]
]
},
{
"id": "1d6e942799849e63",
"type": "comment",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "メール受信後の処理",
"info": "",
"x": 130,
"y": 360,
"wires": []
},
{
"id": "32936b4c1c197a8e",
"type": "corobo-awsses",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"email": "hig_hal_rstask@robodevelop.pc-corobo.net",
"msgout": "payload",
"msgoutType": "msg",
"msgoutraw": false,
"name": "",
"x": 140,
"y": 420,
"wires": [
[
"96c2cc2c5e5218a1"
]
]
},
{
"id": "6b7244fee2cda7ca",
"type": "inject",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "テスト",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 130,
"y": 480,
"wires": [
[
"openeb0caf7877cf3bf0"
]
]
},
{
"id": "6331d01bb8fa200b",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "メール(一致パターン)",
"field": "payload.text",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "テストメール\nホスト名H-E1-G03F09\nポート1/1/9",
"output": "str",
"x": 460,
"y": 480,
"wires": [
[
"96c2cc2c5e5218a1"
]
]
},
{
"id": "92df9e177c7278e7",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "メール(不一致パターン)",
"field": "payload.text",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "テストメール\nホスト名H-E1-G03F09\nポート1/1/18",
"output": "str",
"x": 470,
"y": 520,
"wires": [
[]
]
},
{
"id": "9c27a6d644176971",
"type": "change",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "ホストとポートの抽出",
"rules": [
{
"t": "set",
"p": "mailBody",
"pt": "msg",
"to": "payload.text",
"tot": "msg"
},
{
"t": "change",
"p": "mailBody",
"pt": "msg",
"from": "\\r?\\n|\\r",
"fromt": "re",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "targetHost",
"pt": "msg",
"to": "mailBody",
"tot": "msg"
},
{
"t": "change",
"p": "targetHost",
"pt": "msg",
"from": ".*(H-E\\d-G\\d+F\\d+).*",
"fromt": "re",
"to": "$1",
"tot": "str"
},
{
"t": "set",
"p": "targetPort",
"pt": "msg",
"to": "mailBody",
"tot": "msg"
},
{
"t": "change",
"p": "targetPort",
"pt": "msg",
"from": ".*(\\d+/\\d+/\\d+).*",
"fromt": "re",
"to": "$1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 220,
"y": 620,
"wires": [
[
"29ccef12bab7af2d"
]
]
},
{
"id": "958ed266dbca81fb",
"type": "sqlite",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"mydb": "494938546e25ebb6",
"sqlquery": "msg.topic",
"sql": "msg.topic = `SELECT * FROM hostPortListTable WHERE hostName = '${msg.targetHost}' AND port = '${msg.targetPort}'`;\nreturn msg;`",
"name": "一致するレコードの問い合わせ",
"x": 650,
"y": 620,
"wires": [
[
"7af1ec770a2c40c1"
]
]
},
{
"id": "479aff680d6e37a6",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "メール(入ってないパターン)",
"field": "payload.text",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "テストメール\nホスト名testtest\nポートtesttest000",
"output": "str",
"x": 480,
"y": 560,
"wires": [
[]
]
},
{
"id": "ccb2a825497be8a9",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1470,
"y": 640,
"wires": []
},
{
"id": "d2379e257d9b9894",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1290,
"y": 440,
"wires": []
},
{
"id": "445c2fbbc8e1ca15",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "デバッグメッセージ(無関係)",
"field": "debug",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "無関係なメール.\n転送します.",
"output": "str",
"x": 1080,
"y": 440,
"wires": [
[
"d2379e257d9b9894"
]
]
},
{
"id": "47286d26eceeeac6",
"type": "switch",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "ホスト名は含まれる?",
"property": "payload.text",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": ".*(H-E\\d-G\\d+F\\d+).*",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 600,
"y": 420,
"wires": [
[
"7d88104aa6e1b1f1"
],
[
"3acd624452b7b286"
]
]
},
{
"id": "7d88104aa6e1b1f1",
"type": "switch",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "ポートは含まれる?",
"property": "payload.text",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": ".*(\\d+/\\d+/\\d+).*",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 830,
"y": 400,
"wires": [
[
"6e6e4092e08b0bbb"
],
[
"445c2fbbc8e1ca15"
]
]
},
{
"id": "3acd624452b7b286",
"type": "switch",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "ポートは含まれる?",
"property": "payload.text",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": ".*(\\d/\\d/\\d).*",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 830,
"y": 440,
"wires": [
[
"445c2fbbc8e1ca15"
],
[
"445c2fbbc8e1ca15"
]
]
},
{
"id": "29ccef12bab7af2d",
"type": "function",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "SQL構文",
"func": "msg.topic = `SELECT * FROM hostPortListTable WHERE hostName = '${msg.targetHost}' AND port = '${msg.targetPort}'`;\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 420,
"y": 620,
"wires": [
[
"958ed266dbca81fb"
]
]
},
{
"id": "7af1ec770a2c40c1",
"type": "switch",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "一致するレコードは存在した?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "empty"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 950,
"y": 620,
"wires": [
[
"74b8d92f1e865335"
],
[
"e6104ea47feb1818"
]
]
},
{
"id": "74b8d92f1e865335",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "デバッグメッセージ(対応終了)",
"field": "debug",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "対応終了",
"output": "str",
"x": 1250,
"y": 600,
"wires": [
[
"157442fa1c971ef0"
]
]
},
{
"id": "e6104ea47feb1818",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "デバッグメッセージ(転送)",
"field": "debug",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "!パターンマッチ\nhost : {{targetHost}}\nPort : {{targetPort}}",
"output": "str",
"x": 1230,
"y": 640,
"wires": [
[
"ccb2a825497be8a9"
]
]
},
{
"id": "157442fa1c971ef0",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1470,
"y": 600,
"wires": []
},
{
"id": "0a7fb27784c0471b",
"type": "awsses-send",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "メール転送",
"from": "hig_hal_rstask@robodevelop.pc-corobo.net",
"to": "",
"toType": "str",
"detailSettings": false,
"cc": "",
"ccType": "str",
"bcc": "",
"bccType": "str",
"inReplyTo": "",
"inReplyToType": "str",
"replyTo": "",
"replyToType": "str",
"references": "",
"referencesType": "str",
"subject": "subject",
"subjectType": "msg",
"format": "text",
"body": "mailText",
"bodyType": "msg",
"files": [],
"x": 1490,
"y": 680,
"wires": [
[]
]
},
{
"id": "eb0caf7877cf3bf0",
"type": "template",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "sub",
"field": "payload.subject",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "0525依頼テスト",
"output": "str",
"x": 270,
"y": 480,
"wires": [
[
"479aff680d6e37a6",
"6331d01bb8fa200b",
"92df9e177c7278e7"
]
]
},
{
"id": "96c2cc2c5e5218a1",
"type": "change",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "メール本文と件名の保存",
"rules": [
{
"t": "set",
"p": "mailText",
"pt": "msg",
"to": "payload.text",
"tot": "msg"
},
{
"t": "set",
"p": "subject",
"pt": "msg",
"to": "payload.subject",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 350,
"y": 420,
"wires": [
[
"47286d26eceeeac6"
]
]
},
{
"id": "6e6e4092e08b0bbb",
"type": "link out",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "link out 20",
"mode": "link",
"links": [
"ebb3138d2224c16f"
],
"x": 975,
"y": 380,
"wires": []
},
{
"id": "ebb3138d2224c16f",
"type": "link in",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "link in 21",
"links": [
"6e6e4092e08b0bbb"
],
"x": 65,
"y": 620,
"wires": [
[
"9c27a6d644176971"
]
]
},
{
"id": "214d0000dd469402",
"type": "awsses-send",
"z": "d04ff5df9582e88d",
"g": "e77873164f3822de",
"name": "メール転送",
"from": "hig_hal_rstask@robodevelop.pc-corobo.net",
"to": "",
"toType": "str",
"detailSettings": false,
"cc": "",
"ccType": "str",
"bcc": "",
"bccType": "str",
"inReplyTo": "",
"inReplyToType": "str",
"replyTo": "",
"replyToType": "str",
"references": "",
"referencesType": "str",
"subject": "subject",
"subjectType": "msg",
"format": "text",
"body": "mailText",
"bodyType": "msg",
"files": [],
"x": 1310,
"y": 480,
"wires": [
[]
]
},
{
"id": "0b011fc688e9c37e",
"type": "sqlite",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"mydb": "494938546e25ebb6",
"sqlquery": "fixed",
"sql": "select * from hostPortListTable;",
"name": "データ参照",
"x": 310,
"y": 860,
"wires": [
[
"71ca2d3591034d0d"
]
]
},
{
"id": "71ca2d3591034d0d",
"type": "debug",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 470,
"y": 860,
"wires": []
},
{
"id": "8ec657def0fe1635",
"type": "inject",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "データ参照",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 140,
"y": 860,
"wires": [
[
"0b011fc688e9c37e"
]
]
},
{
"id": "e05adf419b7652cb",
"type": "comment",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "登録済みのリスト情報を参照します.",
"info": "",
"x": 880,
"y": 860,
"wires": []
},
{
"id": "1c6a3a8d786561b2",
"type": "comment",
"z": "d04ff5df9582e88d",
"g": "8ebcc040c928d3d4",
"name": "テーブル操作",
"info": "",
"x": 110,
"y": 800,
"wires": []
},
{
"id": "494938546e25ebb6",
"type": "sqlitedb",
"db": "/data/sqlite-host-port-list",
"mode": "RWC"
}
]
上記をインポートすると、ノード群が枠で囲まれた以下のようなフローが展開されます。

② 標準版(グループ機能非対応環境向け)¶
ご利用のエージェント環境において、グループ機能読み込みに伴うインポートエラー(TypeError等)を回避したい場合はこちらを使用してください(データは上記のものと変わりません)。
サンプルフローのJSONコードを展開する
[
{
"id": "5b69332a.b44a3c",
"type": "tab",
"label": "受信メール・DB照合自動判定フィルタ",
"disabled": false,
"info": ""
},
{
"id": "f33965a9.aca86",
"type": "sqlite",
"z": "5b69332a.b44a3c",
"mydb": "f962418.f8bd8c",
"sqlquery": "msg.topic",
"sql": "",
"name": "テーブル削除",
"x": 490,
"y": 920,
"wires": [
[
"778fef28.b1a498"
]
]
},
{
"id": "778fef28.b1a498",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 650,
"y": 920,
"wires": []
},
{
"id": "4dbfca42.4e64ac",
"type": "function",
"z": "5b69332a.b44a3c",
"name": "SQL構文",
"func": "msg.topic = \"drop table hostPortListTable;\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 320,
"y": 920,
"wires": [
[
"f33965a9.aca86"
]
]
},
{
"id": "cb14041c.1c00c8",
"type": "inject",
"z": "5b69332a.b44a3c",
"name": "テーブル削除",
"topic": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 150,
"y": 920,
"wires": [
[
"4dbfca42.4e64ac"
]
]
},
{
"id": "46768d92.21cefc",
"type": "comment",
"z": "5b69332a.b44a3c",
"name": "作成済みのリスト情報のテーブルを削除します.",
"info": "",
"x": 920,
"y": 920,
"wires": []
},
{
"id": "565c1566.d5776c",
"type": "comment",
"z": "5b69332a.b44a3c",
"name": "HostとPortを組み合わせたリスト情報の事前登録",
"info": "",
"x": 220,
"y": 60,
"wires": []
},
{
"id": "2b7a50a8.2e6678",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "リスト情報の入力(全角スペース区切り)",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "H-E1-G03F09 1/1/9\nH-E1-G04F01 1/1/18\nH-E1-G05F01 1/1/15",
"output": "str",
"x": 400,
"y": 240,
"wires": [
[
"f0142396.9c9838"
]
]
},
{
"id": "8478271f.b782c8",
"type": "inject",
"z": "5b69332a.b44a3c",
"name": "リスト更新",
"topic": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 140,
"y": 240,
"wires": [
[
"2b7a50a8.2e6678"
]
]
},
{
"id": "c830971f.91f5a8",
"type": "sqlite",
"z": "5b69332a.b44a3c",
"mydb": "f962418.f8bd8c",
"sqlquery": "fixed",
"sql": "CREATE TABLE IF NOT EXISTS hostPortListTable (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n hostName TEXT NOT NULL UNIQUE,\n port TEXT NOT NULL\n);",
"name": "テーブル作成",
"x": 330,
"y": 120,
"wires": [
[
"7b7eb26f.f8d824"
]
]
},
{
"id": "7b7eb26f.f8d824",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 490,
"y": 120,
"wires": []
},
{
"id": "f0142396.9c9838",
"type": "split",
"z": "5b69332a.b44a3c",
"name": "改行ごとに分割",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 680,
"y": 240,
"wires": [
[
"18966493.386dab"
]
]
},
{
"id": "6f7b520a.d4364c",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1410,
"y": 240,
"wires": []
},
{
"id": "18966493.386dab",
"type": "change",
"z": "5b69332a.b44a3c",
"name": "hostとportの抽出",
"rules": [
{
"t": "set",
"p": "hostName",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "change",
"p": "hostName",
"pt": "msg",
"from": "^(\\S+) (\\S+)$",
"fromt": "re",
"to": "$1",
"tot": "str"
},
{
"t": "set",
"p": "setPort",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "change",
"p": "setPort",
"pt": "msg",
"from": "^(\\S+) (\\S+)$",
"fromt": "re",
"to": "$2",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 890,
"y": 240,
"wires": [
[
"84ad53ab.a0277"
]
]
},
{
"id": "84ad53ab.a0277",
"type": "function",
"z": "5b69332a.b44a3c",
"name": "SQL構文",
"func": "msg.topic = `INSERT OR IGNORE INTO hostPortListTable `;\nmsg.topic += `(hostName, port) `;\nmsg.topic += `VALUES ('${msg.hostName}', '${msg.setPort}');`;\nreturn msg;`",
"outputs": 1,
"noerr": 0,
"x": 1080,
"y": 240,
"wires": [
[
"82c888ab.5babc"
]
]
},
{
"id": "451b143e.c38364",
"type": "inject",
"z": "5b69332a.b44a3c",
"name": "テーブル一覧",
"topic": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 150,
"y": 180,
"wires": [
[
"29946c53.1db8dc"
]
]
},
{
"id": "29946c53.1db8dc",
"type": "function",
"z": "5b69332a.b44a3c",
"name": "SQL構文",
"func": "msg.topic = \"SELECT * FROM sqlite_master WHERE type='table' AND name='hostPortListTable'\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 320,
"y": 180,
"wires": [
[
"b0623eb8.3d687"
]
]
},
{
"id": "b0623eb8.3d687",
"type": "sqlite",
"z": "5b69332a.b44a3c",
"mydb": "f962418.f8bd8c",
"sqlquery": "msg.topic",
"sql": "tables",
"name": "デーブルリスト",
"x": 500,
"y": 180,
"wires": [
[
"5829cadb.70ea3c"
]
]
},
{
"id": "5829cadb.70ea3c",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 670,
"y": 180,
"wires": []
},
{
"id": "d6324d4.1a2203",
"type": "inject",
"z": "5b69332a.b44a3c",
"name": "テーブル作成",
"topic": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 150,
"y": 120,
"wires": [
[
"c830971f.91f5a8"
]
]
},
{
"id": "82c888ab.5babc",
"type": "sqlite",
"z": "5b69332a.b44a3c",
"mydb": "f962418.f8bd8c",
"sqlquery": "msg.topic",
"sql": "",
"name": "データ追加",
"x": 1250,
"y": 240,
"wires": [
[
"6f7b520a.d4364c"
]
]
},
{
"id": "20b60697.40c1ca",
"type": "comment",
"z": "5b69332a.b44a3c",
"name": "メール受信後の処理",
"info": "",
"x": 130,
"y": 360,
"wires": []
},
{
"id": "ab8c925a.96fd4",
"type": "corobo-awsses",
"z": "5b69332a.b44a3c",
"email": "hig_hal_rstask@robodevelop.pc-corobo.net",
"msgout": "payload",
"msgoutType": "msg",
"msgoutraw": false,
"name": "",
"x": 140,
"y": 420,
"wires": [
[
"b9db1aad.054188"
]
]
},
{
"id": "3fcca9e5.14c2c6",
"type": "inject",
"z": "5b69332a.b44a3c",
"name": "テスト",
"topic": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 130,
"y": 480,
"wires": [
[]
]
},
{
"id": "38b357b5.12395",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "メール(一致パターン)",
"field": "payload.text",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "テストメール\nホスト名H-E1-G03F09\nポート1/1/9",
"output": "str",
"x": 460,
"y": 480,
"wires": [
[
"b9db1aad.054188"
]
]
},
{
"id": "10fe0a30.1c4346",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "メール(不一致パターン)",
"field": "payload.text",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "テストメール\nホスト名H-E1-G03F09\nポート1/1/18",
"output": "str",
"x": 470,
"y": 520,
"wires": [
[]
]
},
{
"id": "b1bfd691.6420b",
"type": "change",
"z": "5b69332a.b44a3c",
"name": "ホストとポートの抽出",
"rules": [
{
"t": "set",
"p": "mailBody",
"pt": "msg",
"to": "payload.text",
"tot": "msg"
},
{
"t": "change",
"p": "mailBody",
"pt": "msg",
"from": "\\r?\\n|\\r",
"fromt": "re",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "targetHost",
"pt": "msg",
"to": "mailBody",
"tot": "msg"
},
{
"t": "change",
"p": "targetHost",
"pt": "msg",
"from": ".*(H-E\\d-G\\d+F\\d+).*",
"fromt": "re",
"to": "$1",
"tot": "str"
},
{
"t": "set",
"p": "targetPort",
"pt": "msg",
"to": "mailBody",
"tot": "msg"
},
{
"t": "change",
"p": "targetPort",
"pt": "msg",
"from": ".*(\\d+/\\d+/\\d+).*",
"fromt": "re",
"to": "$1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 220,
"y": 620,
"wires": [
[
"9db5a705.a88418"
]
]
},
{
"id": "499b6632.05d11",
"type": "sqlite",
"z": "5b69332a.b44a3c",
"mydb": "f962418.f8bd8c",
"sqlquery": "msg.topic",
"sql": "msg.topic = `SELECT * FROM hostPortListTable WHERE hostName = '${msg.targetHost}' AND port = '${msg.targetPort}'`;\nreturn msg;`",
"name": "一致するレコードの問い合わせ",
"x": 650,
"y": 620,
"wires": [
[
"c4c1992f.942ba"
]
]
},
{
"id": "6e5b415d.924858",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "メール(入ってないパターン)",
"field": "payload.text",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "テストメール\nホスト名testtest\nポートtesttest000",
"output": "str",
"x": 480,
"y": 560,
"wires": [
[]
]
},
{
"id": "954957a1.7eb9",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1470,
"y": 640,
"wires": []
},
{
"id": "63408358.ffd944",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1290,
"y": 440,
"wires": []
},
{
"id": "5e7494e1.abc6fc",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "デバッグメッセージ(無関係)",
"field": "debug",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "無関係なメール.\n転送します.",
"output": "str",
"x": 1080,
"y": 440,
"wires": [
[
"63408358.ffd944"
]
]
},
{
"id": "4811b067.33311",
"type": "switch",
"z": "5b69332a.b44a3c",
"name": "ホスト名は含まれる?",
"property": "payload.text",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": ".*(H-E\\d-G\\d+F\\d+).*",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 600,
"y": 420,
"wires": [
[
"e5c83fe8.83ece8"
],
[
"df55ab.8d4e8258"
]
]
},
{
"id": "e5c83fe8.83ece8",
"type": "switch",
"z": "5b69332a.b44a3c",
"name": "ポートは含まれる?",
"property": "payload.text",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": ".*(\\d+/\\d+/\\d+).*",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 830,
"y": 400,
"wires": [
[
"d88b1238.911318"
],
[
"5e7494e1.abc6fc"
]
]
},
{
"id": "df55ab.8d4e8258",
"type": "switch",
"z": "5b69332a.b44a3c",
"name": "ポートは含まれる?",
"property": "payload.text",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": ".*(\\d/\\d/\\d).*",
"vt": "str",
"case": false
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 830,
"y": 440,
"wires": [
[
"5e7494e1.abc6fc"
],
[
"5e7494e1.abc6fc"
]
]
},
{
"id": "9db5a705.a88418",
"type": "function",
"z": "5b69332a.b44a3c",
"name": "SQL構文",
"func": "msg.topic = `SELECT * FROM hostPortListTable WHERE hostName = '${msg.targetHost}' AND port = '${msg.targetPort}'`;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 420,
"y": 620,
"wires": [
[
"499b6632.05d11"
]
]
},
{
"id": "c4c1992f.942ba",
"type": "switch",
"z": "5b69332a.b44a3c",
"name": "一致するレコードは存在した?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "empty"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 950,
"y": 620,
"wires": [
[
"f55cff54.70345"
],
[
"9af443cf.36e328"
]
]
},
{
"id": "f55cff54.70345",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "デバッグメッセージ(対応終了)",
"field": "debug",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "対応終了",
"output": "str",
"x": 1250,
"y": 600,
"wires": [
[
"198be578.cc1053"
]
]
},
{
"id": "9af443cf.36e328",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "デバッグメッセージ(転送)",
"field": "debug",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "!パターンマッチ\nhost : {{targetHost}}\nPort : {{targetPort}}",
"output": "str",
"x": 1230,
"y": 640,
"wires": [
[
"954957a1.7eb9"
]
]
},
{
"id": "198be578.cc1053",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1470,
"y": 600,
"wires": []
},
{
"id": "314c88e4.155ff",
"type": "awsses-send",
"z": "5b69332a.b44a3c",
"name": "メール転送",
"from": "hig_hal_rstask@robodevelop.pc-corobo.net",
"to": "",
"toType": "str",
"subject": "subject",
"subjectType": "msg",
"format": "text",
"body": "mailText",
"bodyType": "msg",
"files": [],
"x": 1490,
"y": 680,
"wires": [
[]
]
},
{
"id": "c5895b2c.abbca8",
"type": "template",
"z": "5b69332a.b44a3c",
"name": "sub",
"field": "payload.subject",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "0525依頼テスト",
"output": "str",
"x": 270,
"y": 480,
"wires": [
[
"6e5b415d.924858",
"38b357b5.12395",
"10fe0a30.1c4346"
]
]
},
{
"id": "b9db1aad.054188",
"type": "change",
"z": "5b69332a.b44a3c",
"name": "メール本文と件名の保存",
"rules": [
{
"t": "set",
"p": "mailText",
"pt": "msg",
"to": "payload.text",
"tot": "msg"
},
{
"t": "set",
"p": "subject",
"pt": "msg",
"to": "payload.subject",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 350,
"y": 420,
"wires": [
[
"4811b067.33311"
]
]
},
{
"id": "d88b1238.911318",
"type": "link out",
"z": "5b69332a.b44a3c",
"name": "link out 20",
"links": [
"528df559.20d4c4"
],
"x": 975,
"y": 380,
"wires": []
},
{
"id": "528df559.20d4c4",
"type": "link in",
"z": "5b69332a.b44a3c",
"name": "link in 21",
"links": [
"d88b1238.911318"
],
"x": 65,
"y": 620,
"wires": [
[
"b1bfd691.6420b"
]
]
},
{
"id": "b9ce3580.df5f68",
"type": "awsses-send",
"z": "5b69332a.b44a3c",
"name": "メール転送",
"from": "hig_hal_rstask@robodevelop.pc-corobo.net",
"to": "",
"toType": "str",
"subject": "subject",
"subjectType": "msg",
"format": "text",
"body": "mailText",
"bodyType": "msg",
"files": [],
"x": 1310,
"y": 480,
"wires": [
[]
]
},
{
"id": "59c19823.a8f518",
"type": "sqlite",
"z": "5b69332a.b44a3c",
"mydb": "f962418.f8bd8c",
"sqlquery": "fixed",
"sql": "select * from hostPortListTable;",
"name": "データ参照",
"x": 310,
"y": 860,
"wires": [
[
"4f1fcc7.04767b4"
]
]
},
{
"id": "4f1fcc7.04767b4",
"type": "debug",
"z": "5b69332a.b44a3c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 470,
"y": 860,
"wires": []
},
{
"id": "418db5b.a8caccc",
"type": "inject",
"z": "5b69332a.b44a3c",
"name": "データ参照",
"topic": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 140,
"y": 860,
"wires": [
[
"59c19823.a8f518"
]
]
},
{
"id": "319d53ab.c1f584",
"type": "comment",
"z": "5b69332a.b44a3c",
"name": "登録済みのリスト情報を参照します.",
"info": "",
"x": 880,
"y": 860,
"wires": []
},
{
"id": "955ef14a.b5fc8",
"type": "comment",
"z": "5b69332a.b44a3c",
"name": "テーブル操作",
"info": "",
"x": 110,
"y": 800,
"wires": []
},
{
"id": "f962418.f8bd8c",
"type": "sqlitedb",
"db": "/data/sqlite-host-port-list",
"mode": "RWC"
}
]
上記をインポートすると、以下のようなフローが展開されます。

フローの処理構造¶
本システムは、定常的な「通信許可依頼メール」を自動判定し、人間の運用コストを削減するソリューションです。フローは大きく分けて以下の3つの役割(グループ)で設計されています。
1. リスト情報の事前登録ブロック(上段グループ)¶
判定の基準となる「安全なホスト名とポート番号の組み合わせ」を内部データベース(SQLite)へ事前に流し込み、ホワイトリストを構築するフェーズです。
- テーブル作成:初回稼働時にデータベース内部へ保存用テーブル(
hostPortListTable)を自動生成します。 - リスト更新:全角スペースで区切られたテキスト情報をノード内でパースし、データベースへ重複を無視(
INSERT OR IGNORE)して一括インサートします。
2. メール受信後の自動判定・転送ブロック(中段メイングループ)¶
実際にメールを受信した際、その本文を解析して自動仕分けを行うメインロジックです。
- 情報の抽出:届いたメール本文から、正規表現(Regex)を用いて「ホスト名(
H-E...)」と「ポート番号(.../.../...)」の文字列を自動で切り出します。 - DB照合と条件分岐:切り出した組み合わせがデータベースのテーブル内に存在するかSQL文で問い合わせます。
- データが存在した場合(合致):すでに承認済みの安全な通信と判断し、人間の手を煩わせることなく「対応終了(クローズ)」とします。
- データが存在しない、または無関係なメールの場合:イレギュラーな新規案件、あるいはパターンの異なる重要メールと判断し、指定の運用保守アドレスへ「メール転送(AWS SES)」を実行します。
3. テーブルメンテナンスブロック(下段グループ)¶
運用の中で、ホワイトリストに現在登録されている内容を確認・リセットするための管理用フェーズです。
- データ参照:現在保存されているリスト情報をデバッグログに一覧出力します。
- テーブル削除:古いリスト情報をデータベースから一括で綺麗にクリア(
drop table)します。
設定・書き換えが必要な箇所¶
サンプルフローのインポート後、実環境で動作させるには以下のノードの設定を変更してください。
① メール受信設定¶
- 「corobo-awsses(メール受信)」ノード プロパティ内の「受信メールアドレス」を、実際に利用するメールアドレスへと変更してください。
② 転送先メールアドレスの設定¶
- 「メール転送(AWS SES)」ノード 「送信元(From)」および「送信先(To)」を、ご自身の認証済みAWS SES環境に合わせた正規のメールアドレスへ書き換えてください。
技術解説:正規表現による本文のパースと二重登録防止¶
正規表現によるデータの切り出し¶
中段の「ホストとポートの抽出」ノードでは、メール本文内から特定のターゲット文字列を見つけ出すため、以下の正規表現パターンを利用しています。
- ホスト名の検出:
.*(H-E\d-G\d+F\d+).*(「H-E」から始まり、特定の規則を持つ文字列をキャプチャ) - ポート番号の検出:
.*(\d+/\d+/\d+).*(数字がスラッシュで区切られた通信ポート書式をキャプチャ)
INSERT OR IGNORE による重複防止¶
上段の登録処理では、同一のホスト名が何度も重複してデータベースへ登録され、容量を圧迫したりパフォーマンスが低下したりするのを防ぐため、SQLの IGNORE 構文を採用しています。
これにより、すでに登録済みのホスト情報が流れてきた場合はSQL側で自動的にインサートがスキップされる安全な設計となっています。