{"id":7396,"date":"2015-05-27T23:07:10","date_gmt":"2015-05-27T14:07:10","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=7396"},"modified":"2018-11-14T16:33:48","modified_gmt":"2018-11-14T07:33:48","slug":"sstp%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9fchatwork%e3%81%ae%e3%82%bf%e3%82%b9%e3%82%af%e7%a2%ba%e8%aa%8d","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2015\/05\/27\/sstp%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9fchatwork%e3%81%ae%e3%82%bf%e3%82%b9%e3%82%af%e7%a2%ba%e8%aa%8d\/","title":{"rendered":"SSTP\u3092\u4f7f\u3063\u305fChatwork\u306e\u30bf\u30b9\u30af\u78ba\u8a8d"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002\u30a4\u30f3\u30d5\u30e9\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u4e95\u4e0a\u3067\u3059\u3002<\/p>\n<p>\u666e\u6bb5\u306fWindows\u4e0a\u3067Chatwork\u306e\u65b0\u7740\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30bf\u30a4\u30e0\u30e9\u30b0\u306a\u304f\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306bChrome\u306e\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u305f\u3060\u3001\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u7aef\u672b\u3068\u3057\u3066Linux\u306eX\u3092\u4f7f\u3046\u3053\u3068\u304c\u3042\u308b\u305f\u3081\u3001\u3053\u306e\u624b\u6bb5\u304c\u5fc5\u305a\u3057\u3082\u6709\u52b9\u3067\u306f\u306a\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3068\u601d\u3044\u304b\u3089\u3001Chatwork API\u3068SSTP\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u306a\u3093\u3068\u304b\u3057\u3066\u307f\u3088\u3046\u3068\u8003\u3048\u305f\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u4eca\u3068\u306a\u3063\u3066\u306f\u77e5\u3089\u306a\u3044\u65b9\u3082\u591a\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u304c\u300110\u5e74\u4ee5\u4e0a\u524d\u304b\u3089\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30de\u30b9\u30b3\u30c3\u30c8\u3067\u3042\u308b\u300c\u4f3a\u304b\u300d\uff08\u300c\u4f55\u304b\u300d\u3068\u547c\u3076\u30b1\u30fc\u30b9\u3082\u3042\u308b\uff09\u3068\u3044\u3046\u3082\u306e\u304c\u5b58\u5728\u3057\u307e\u3059\u3002\u5f53\u521d\u306e\u30a2\u30d7\u30ea\u306f\u3059\u3067\u306b\u958b\u767a\u304c\u3068\u307e\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u306f\u4eca\u3082\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u3067\u3001\u958b\u767a\u304c\u7d9a\u3044\u3066\u3044\u307e\u3059\u3002\u6700\u8fd1\u307e\u3067\u306fPython\u3067\u958b\u767a\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u3001Ruby\u3078\u306e\u79fb\u690d\u3082\u59cb\u307e\u3063\u3066\u304a\u308a\u5229\u7528\u8005\u304c\u623b\u3063\u3066\u304f\u308b\u3068\u3044\u3044\u306a\u3068\u601d\u3044\u307e\u3059\u3002\u8208\u5473\u304c\u306a\u3044\u4eba\u306b\u3068\u3063\u3066\u306f\u95a2\u308f\u308a\u304c\u306a\u3055\u305d\u3046\u306a\u30a2\u30d7\u30ea\u3067\u3059\u304c\u3001Linux\u306a\u3069\u3092\u4f7f\u308f\u308c\u308b\u30e6\u30fc\u30b6\u306e\u74b0\u5883\u306b\u306f\u3001\u3053\u306e\u6b8b\u6ed3\u304c\u6b8b\u3063\u3066\u3044\u307e\u3059\u3002\u304a\u3082\u3080\u308d\u306b\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u3066<\/p>\n<p><strong>grep sstp \/etc\/service<\/strong><\/p>\n<p>\u3068\u6253\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\u3059\u308b\u3068\u7d50\u679c\u304c\u8fd4\u3063\u3066\u304f\u308b\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001\u307e\u3055\u3057\u304f\u3053\u308c\u304c\u3001\u300c\u4f3a\u304b\u300d\u306e\u305f\u3081\u306e\u30d7\u30ed\u30c8\u30b3\u30eb\u7528\u30dd\u30fc\u30c8\u5b9a\u7fa9\u3067\u3059\u3002\u3053\u306e\u756a\u53f7\u306e\u4e88\u7d04\u306f\u304d\u3061\u3093\u3068IANA\u306b\u3082\u3042\u308a\u3001\u793e\u4f1a\u8a8d\u77e5\u3055\u308c\u3066\u3044\u308b\u3068\u79c1\u306f\u4fe1\u3058\u3066\u3044\u307e\u3059\u3002\u3067\u306f\u3001\u672c\u984c\u306b\u3002<\/p>\n<p>\u307e\u305a\u3001\u300c\u4f3a\u304b\u300d\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306bninix-aya\u3092\u5165\u308c\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3068\u306a\u308b\u30b4\u30fc\u30b9\u30c8\u3068\u30d0\u30eb\u30fc\u30f3\u3092\u30d7\u30e9\u30b0\u30a4\u30f3\u7684\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308c\u3070\u8d77\u52d5\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002\u8d77\u52d5\u3055\u305b\u3066\u307c\u30fc\u3063\u3068\u773a\u3081\u3066\u3044\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306e\u76ee\u7684\u306f\u300cChatwork\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u66f4\u65b0\u3092\u77e5\u308a\u305f\u3044\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306e\u3067\u3001\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3078\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308b\u624b\u7acb\u3066\u3092\u7528\u610f\u3057\u307e\u3059\u3002\u5b9a\u578b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u5272\u3068\u7c21\u5358\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u3092\u898b\u306a\u304c\u3089\u3060\u3068\u3059\u3050\u66f8\u3051\u307e\u3059\u3002Ruby\u3060\u3068\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059(\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f9801\u756a\u30dd\u30fc\u30c8\u306b\"SEND SSTP\/1.1\"(\u56fa\u5b9a\uff09,\"Sender\",\"Charset\",\"Script\"\uff08\u7bb1\u3068\u5185\u5bb9\uff09\u3092\u9001\u308b\u3063\u3066\u3053\u3068\u3067\u3059\uff09\u3002<\/p>\n<pre class=\"lang:java decode:true\">\r\nrequire 'socket'\r\n\r\ns = TCPSocket.open('localhost', 9801)\r\n\r\nMSG_HEADERS ={\r\n  'Sender' => 'sstp_test_prog',  'Charset' => 'UTF-8'\r\n}\r\n\r\nMSG_BREAK = \"\\r\\n\"\r\nh = ['SEND SSTP\/1.1']\r\n\r\nMSG_SAKURA = \"\\\\h\" + ARGV[0]\r\nMSG_UNYU = \"\\\\u\u307e\u3041\u3001\u60f3\u5b9a\u901a\u308a\u3060\u306a\\\\n\u306f\u305f\u3089\u3051\u3001\u306f\u305f\u3089\u3051\u3002\u3002\u3002\"\r\n\r\nMSG = MSG_SAKURA + MSG_UNYU\r\nheaders = MSG_HEADERS.clone.update('Script' => MSG)\r\nh << headers.map{|k, v| \"#{k}: #{v}\"}\r\nmessage = h.join(MSG_BREAK).concat(MSG_BREAK * 2)\r\n\r\ns.write(message)\r\n<\/pre>\n<p>\u300cruby \u30b9\u30af\u30ea\u30d7\u30c8\u540d SSTP\u30c6\u30b9\u30c8\u300d\u3068\u30c6\u30b9\u30c8\u3067\u5b9f\u884c\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306e\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<div id=\"attachment_7427\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/SSTP_success.jpg\" rel=\"facebox\" rel=\"attachment wp-att-7427\"><img aria-describedby=\"caption-attachment-7427\" loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/SSTP_success-300x186.jpg\" alt=\"sstp_msg_recieved\" width=\"300\" height=\"186\" class=\"size-medium wp-image-7427\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/SSTP_success-300x186.jpg 300w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/SSTP_success.jpg 932w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-7427\" class=\"wp-caption-text\">SSTP\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d7\u3051\u53d6\u3063\u3066\u3044\u308b<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>\u3053\u3053\u307e\u3067\u3067\u3001\u8868\u793a\u74b0\u5883\u306f\u6574\u3044\u307e\u3057\u305f\u3002\u3042\u3068\u306f\u3001Chatwork\u304b\u3089\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u3068\u3063\u3066\u304f\u308b\u3060\u3051\u3067\u3059\u3002<br \/>\n\u5b9f\u306f\u3001\u300c\u4f3a\u304b\u300d\u3092\u4f7f\u3063\u3066Chatwork\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3068\u3044\u3046\u306e\u306f\u3001Chatwork\u516c\u5f0f\u30d6\u30ed\u30b0\u3067\u3082\u6271\u308f\u308c\u3066\u3044\u307e\u3059\u3002\u308f\u308a\u3068\u96e3\u3057\u3044\u3053\u3068\u3092\u3057\u3066\u5b9f\u73fe\u3055\u308c\u3066\u3044\u307e\u3059\uff08SSTP\/Fluentd + fluent-plugin-sstp\/Chatwork API)\u3002<br \/>\n\u3082\u3061\u308d\u3093\u3001\u4f7f\u3048\u308b\u3082\u306e\u306f\u4f7f\u304a\u3046\u3068\u601d\u3044\u3001\u79c1\u3082\u8a66\u3057\u57fa\u672c\u52d5\u4f5c\u307e\u3067\u78ba\u8a8d\u3057\u307e\u3057\u305f\u304c\u3001\u5c0e\u5165\u304c\u5927\u5909\u3067\u3001\u30de\u30b7\u30f3\u30d1\u30ef\u30fc\u3082\u308f\u308a\u3068\u5fc5\u8981\u3060\u3063\u305f\u305f\u3081\u3001\u3082\u3063\u3068\u7c21\u5358\u306a\u6a5f\u80fd\u3078\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\u305d\u308c\u304c\u300c<strong>\u30b9\u30af\u30ea\u30d7\u30c8(+jq\u30b3\u30de\u30f3\u30c9)\uff0b Chatwork API + SSTP + cron<\/strong>\u300d\u306b\u3088\u308b\u7c21\u5358\u30bf\u30b9\u30af\u78ba\u8a8d\u3067\u3059\u3002Chatwork\u306eAPI\u306e\u4f7f\u3044\u65b9\u306f\u66f4\u65b0\u30b5\u30a4\u30c8\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u307e\u304b\u305b\u3066\u3001\u5b9f\u969b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u516c\u958b\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u5148\u307b\u3069\u516c\u958b\u3057\u305fruby\u30b9\u30af\u30ea\u30d7\u30c8(st.rb)\u3092\u305d\u306e\u307e\u307e\u6d41\u7528\u3059\u308b\u3053\u3068\u3053\u3067\u3001\u5b9a\u671f\u7684\u306b\u305d\u306e\u6642\u306e\u6700\u65b0\u30bf\u30b9\u30af1\u4ef6\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\uff08curl\u3067\u547c\u3093\u3067\u3044\u308bURL\u4e2d\u306e\u30b3\u30e1\u30f3\u30c8\u306f\u8aad\u307f\u66ff\u3048\u3066\u304f\u3060\u3055\u3044\uff09\u3002<\/p>\n<pre class=\"lang:java decode:true\">\r\n#!\/bin\/bash\r\n\r\nDATE=`date +'%Y\/%m\/%d_%H:%M'`\r\ntask=`curl -X GET -H \"X-ChatWorkToken: \u3053\u3053\u306fChatwork API\u30ad\u30fc\" \"https:\/\/api.chatwork.com\/v1\/rooms\/\u3053\u3053\u306f\u30eb\u30fc\u30e0ID\/tasks?account_id=\u3053\u3053\u306f\u30a2\u30ab\u30a6\u30f3\u30c8ID&assigned_by_account_id=\u3053\u3053\u306f\u30a2\u30ab\u30a6\u30f3\u30c8ID&status=open\"|jq .[0].body|head -1|sed s\/\\\"\/\/g`\r\n\r\nSEND_MSG=\"\u73fe\u5728\u6700\u65b0\u30bf\u30b9\u30af:$task:($DATE)\"\r\n\r\nruby \/root\/ninix\/st.rb $SEND_MSG\r\n<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3053\u308c\u3092\u5b9f\u884c\u3057\u3066\u307f\u305f\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\u3053\u308c\u3092cron\u306b\u4e0a\u624b\u306b\u767b\u9332\u3059\u308c\u3070\u3001\u6700\u65b0\u30bf\u30b9\u30af\u306e\u78ba\u8a8d\u306f\u53ef\u80fd\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<div id=\"attachment_7433\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/cw_get_task.jpg\" rel=\"facebox\" rel=\"attachment wp-att-7433\"><img aria-describedby=\"caption-attachment-7433\" loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/cw_get_task-300x218.jpg\" alt=\"CW\u306e\u30bf\u30b9\u30af\u3092\u8868\u793a\" width=\"300\" height=\"218\" class=\"size-medium wp-image-7433\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/cw_get_task-300x218.jpg 300w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/05\/cw_get_task.jpg 900w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-7433\" class=\"wp-caption-text\">\u30c1\u30e3\u30c3\u30c8\u30ef\u30fc\u30af\u4e0a\u306e\u6700\u65b0\u30bf\u30b9\u30af\u304c\u8868\u793a\u3067\u304d\u3066\u3044\u308b<\/p><\/div>\n<p>\u4eca\u56de\u306f\u7c21\u5358\u306a\u65b9\u6cd5\u306e\u307f\u306e\u5b9f\u73fe\u3067\u3057\u305f\u304c\u3001\u767a\u5c55\u304c\u3042\u308c\u3070\u3001\u307e\u305f\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002\u30a4\u30f3\u30d5\u30e9\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u4e95\u4e0a\u3067\u3059\u3002<\/p>\n<p>\u666e\u6bb5\u306fWindows\u4e0a\u3067Chatwork\u306e\u65b0\u7740\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30bf\u30a4\u30e0\u30e9\u30b0\u306a\u304f\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306bChrome\u306e\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2015\/05\/27\/sstp%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9fchatwork%e3%81%ae%e3%82%bf%e3%82%b9%e3%82%af%e7%a2%ba%e8%aa%8d\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[200,87,23,24],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/7396"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=7396"}],"version-history":[{"count":37,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/7396\/revisions"}],"predecessor-version":[{"id":7482,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/7396\/revisions\/7482"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=7396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=7396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=7396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}