Honoä¸ã«ã¹ãã¬ã¼ã¸ã¬ã¹ãªãã°ã¤ã³ã»ãã·ã§ã³ç®¡çãå®è£ ãã¦ã¿ã
ã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ãªãã§ãã°ã¤ã³ã»ãã·ã§ã³ãç¶æããä»çµã¿ãä½ã£ãã®ã§ãç°¡åã«ç´¹ä»ãã¾ãã
å æ¥oidc-authã¨ããHonoã®ããã«ã¦ã§ã¢ãå®è£ ãã¦3rd-party middlewareã¨ãã¦æ¡ç¨ãã¦ããã ãã¾ãããããã¯å¤é¨IDãããã¤ãã¼ã§èªè¨¼ãè¡ãªããèªåçºè¡ããJWTãæ¯ãªã¯ã¨ã¹ãæ¤è¨¼ãããã¨ã§ããµã¼ãå´ã§ã»ãã·ã§ã³IDãè¨é²ãããã¨ãªããã°ã¤ã³ã»ãã·ã§ã³ãç¶æãããã®ã§ãã
ãã®ã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ä¸è¦ã¨ããç¹å¾´ã¯CDNã¨ãã¸ã¨è¦ªåæ§ãé«ãããã¨ãã°Cloudflare Pagesã§æä¾ããéçã³ã³ãã³ãã«Googleèªè¨¼ãã¤ãããã¨ãã£ããã¨ãã¨ãã¸ã®CPUã ãã§å®ç¾ã§ãã¾ããå ãã¦ãHonoã®ãã¼ã¿ããªãã£ã®ãããã§Deno Deployã§ãåãä»çµã¿ã使ããããã¾ãã
å人çã«ã¯å®ç¨æ§ã¨ã»ãã¥ãªãã£ã両ç«ããé¢ç½ããã®ãä½ããã¨èãã¦ãã¾ãããã»ãã¥ãªãã£é¢ã§ä¸å®ãæãã人ãããã¨æãã®ã§è§£èª¬è¨äºãæ¸ãã¦ã¿ã¾ãã
ã¨ãã¸ã³ã³ãã¥ã¼ãã£ã³ã°ã¨ã¯
æ¬é¡ã«å ¥ãåã«ãã¨ãã¸ã³ã³ãã¥ã¼ãã£ã³ã°ã«ã¤ãã¦ç°¡åã«ç´¹ä»ãã¾ãã
Webã®æèã§ã¨ãã¸ã³ã³ãã¥ã¼ãã£ã³ã°ã¨è¨ã£ãå ´åãããçæéã ãåããããªå¦çãCDNã¨ãã¸ãµã¼ããªã©ã¦ã¼ã¶ã¼ã®è¿æã§åä½ãããä»çµã¿ãæãã¨æãã¾ããCloudflare WorkersãLambda@EdgeãVercelãªã©ããã®ä»£è¡¨æ ¼ã¨è¨ããã§ãããã
ããããç°å¢ã®åä½ç°å¢ã¨ãã¦JavaScriptã¨ã³ã¸ã³ãå¤ãæ¡ç¨ããã¦ãããããã¨ãã¸ä¸ã§åããã¹ã¯ãªããã¯åºæ¬çã«JavaScriptãTypeScriptã§è¨è¿°ãããã¨ã«ãªãã¾ã1ã
ã¦ã¼ã¹ã±ã¼ã¹ã¨ãã¦ã¯ç°¡åãªå¦çãåæã¨ãã¦ãããã¨ãå¤ããã©ã®ç°å¢ã§ãå®è¡æéã®ä¸éã¯å³ããã§ããä¾ãã°Cloudflare Workersã¯å®è¡æéã®ä¸éã50ms2ã§ãã
ããå¤ãææ¸ã§ããã@yusukebeããã®ãCDNã®ã¨ãã¸ã§å®è¡ããç³»ãé¢ç½ãããèªãã¨èæ¯ãã¦ã¼ã¹ã±ã¼ã¹ããã詳ããç解ã§ããã¨æãã¾ãã
ãã®ã¨ãã¸ã³ã³ãã¥ã¼ãã£ã³ã°ã§ãããç¹ã«Webããã³ãã¨ã³ãçéã®æ¹ã ã«æ¯æããã¦ããå°è±¡ãããã¾ããç§ã¯éå¤æ¼¢ãªã®ã§æ³åã«ãªãã¾ãããå©ç¨è¨èªã®è¦ªåæ§ã¨å®éã®ãã¼ãºã¨ä¸¡æ¹ãåã¿åã£ã¦ããã¨ãããã¨ãªã®ã§ããããç¹ã«ãã¨ãã¸ã§SSRããçµæãä¸å®æéãã£ãã·ã¥ãã¦ãããããªä½¿ãæ¹ã¯ã¡ãªããã大ãããã§ãã
Honoã®ç´¹ä»ã¨oidc-authã®å©ç¨ä¾
Honoã¯@yusukebeãããä½ããã¦ããTypeScript製ã®Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ãã
Honoã®ç¹å¾´ãä¸è¨ã§èª¬æããã¨ããäºæ¥è ãã¨ã®å·®åã大ããã¨ãã¸å¦çã«ãã¼ã¿ããªãã£ãæä¾ããã¨ãã¸ç¨ãã¬ã¼ã ã¯ã¼ã¯ãã¨ãªãã¾ã3ãå社ã®ã¨ãã¸ã³ã³ãã¥ã¼ãã£ã³ã°ç°å¢ã¯åºæ¬çã«JavaScript/TypeScriptã§è¨è¿°ãããã®ãå¤ãã®ã§ãããããããã®å·®åãããªã大ãããè¤æ°ç¤¾ã®ç°å¢ã§åå 容ã®å¦çãæ¸ãã ãã§ãæå¤ã¨è¦å´ããå°è±¡ã§ããHonoã§æ¸ããã¨ã§å°ããå¤æ´ã§å¥ã®ç°å¢ã§ãåãããã¨ãã§ãã¾ãã
è«ãã証æ ã§ãä»åç§ãä½æããoidc-authã使ã£ã¦éçãã¼ã¸ã«OpenID Connectã§èªè¨¼ã»èªå¯ãã¤ããã³ã¼ããè¦ã¦ã¿ã¾ããããCloudflare Pagesã®å ´åã¯ä¸è¨ã®ããã«ãªãã¾ãã
import { Hono } from 'hono' import { oidcAuthMiddleware, getAuth } from '@hono/oidc-auth' const app = new Hono() app.use('*', oidcAuthMiddleware()) app.use('*', async (c, next) => { // Authorize user with email address const auth = await getAuth(c) if (!auth?.email.endsWith('@gmail.com')) { return c.text('Unauthorized', 401) } await next() }) app.get('*', async (c) => { const response = await c.env.ASSETS.fetch(c.req.raw); // clone the response to return a response with modifiable headers const newResponse = new Response(response.body, response) return newResponse }); export default app
èªè¨¼ç¨ã®URLãã¯ã©ã¤ã¢ã³ãIDãã·ã¼ã¯ã¬ãããªã©ã¯ç°å¢å¤æ°çµç±ã§æ¸¡ãã¦ãã¾ããä¸è¨ã®å ´åã§ããã°Googleèªè¨¼ãçµç±ãã¦@gmail.comã®ã¢ãã¬ã¹ã ã£ãå ´åã ãéçãã¼ã¸ãé²è¦§ã§ãã¾ãã
次ã«Deno Deployçãè¦ã¦ã¿ã¾ãããã
import { Hono } from 'npm:hono' import { serveStatic } from 'npm:hono/deno' import { oidcAuthMiddleware, getAuth } from 'npm:@hono/oidc-auth'; const app = new Hono() app.use('*', oidcAuthMiddleware()) app.use('*', async (c, next) => { // Authorize user with email address const auth = await getAuth(c) if (!auth?.email.endsWith('@gmail.com')) { return c.text('Unauthorized', 401) } await next() }) app.use('*', serveStatic({ root: 'public/' })) Deno.serve(app.fetch)
ç°ãªãç°å¢ã§ä¼¼ãã³ã¼ããåããã¨ããããã¨æãã¾ãã
å®éã®æåãã½ã¼ã¹ã³ã¼ãã確èªãããæ¹ã¯ä¸è¨ãªã³ã¯ãã試ãã¦ã¿ã¦ãã ããã
ãèªèº«ã§åä½ç¢ºèªãããå ´åãç°å¢å¤æ°ãæä½5ã¤è¨å®ããä¸ã§IDãããã¤ãå´ã«ã³ã¼ã«ããã¯URLãç»é²ããå¿ è¦ãããã¾ãã詳細ã¯@hono/oidc-authãã確èªãã ããã
JWTã«ããã»ãã·ã§ã³ç®¡çã®å®è£
ããããæ¬é¡ã§ããoidc-authã®å®è£ ãç´¹ä»ãã¾ãã
ã·ã¼ã±ã³ã¹å³ãè¦ãã¨å°ãè¤éã«è¦ãã¾ãããIDãããã¤ãããIDãã¼ã¯ã³ãåãåºãã¨ããã¾ã§ã¯æ®éã®OpenID Connectã®èªè¨¼ããã¼ã§ãã
ãã®å¾ãåãåºããIDãã¼ã¯ã³ãå ã«èªåã§JWTãä½ãã¾ãããã®JWTã«ã¯ã¦ã¼ã¶ã¼ID4ãeã¡ã¼ã«ã¢ãã¬ã¹ããªãã¬ãã·ã¥ãã¼ã¯ã³ããªãã¬ãã·ã¥æéï¼ããã©ã«ã15åï¼ã¨ã»ãã·ã§ã³æéï¼ããã©ã«ã1æ¥ï¼ãå«ã¾ãã¦ãããHS256ã§ç½²åãã¦ãã¾ãã
ãã®JWTãSet-Cookieãããã§ãã©ã¦ã¶ã«è¿ãããã©ã¦ã¶ããéä¿¡ãããJWTãæ¯ãªã¯ã¨ã¹ãæ¤è¨¼ãã¾ããJWTã®ç½²åæ¤è¨¼ããã¹ãã¦JWTå ã®ã»ãã·ã§ã³æéãçµéãã¦ããªããã°ã»ãã·ã§ã³ãæå¹ã¨ãããã¨ã«ãªãã¾ãã
ä¸è¨ã®èª¬æãããããããã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ã使ã£ã¦ããªãã®ãããããã¨æãã¾ããæ¬æ¥ãªãã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ã«ããã¹ãæ å ±ãç½²åä»ãã§ãã©ã¦ã¶ã®ã¯ããã¼ã«ä¿åããæ¯åç½²åæ¤è¨¼ãè¡ãªã£ã¦ããããã§ãã
ã»ãã¥ãªãã£ã«ãé æ ®ãã¦å®è£ ãã¦ãã¾ããoidc-authã§ã¯oauth4webapiã¨ãããã©ã¦ã¶åãã®OAuthã¯ã©ã¤ã¢ã³ãå®è£ ãå©ç¨ãã¦ãããOpenID Connectã®å®è£ ã§å¿ è¦ã¨ãããã»ãã¥ãªãã£å¯¾çã¯å ¨ã¦å®æ½ãã¦ãã¾ã5ãã¾ããã¯ããã¼ã®Secureå±æ§ãHttpOnlyå±æ§ãã¡ããã¨æå®ãã¦ãã¾ãã
JWTãã»ãã·ã§ã³ã¨ãã¦ä½¿ããã¨ã®æ¯éã«ã¤ãã¦
5å¹´ã»ã©åã«ãSPAãªã©ã®æèã§JWTãã»ãã·ã§ã³ç®¡çã«ä½¿ãã®ãããã®ãæªãã®ããè°è«ã«ãªã£ããã¨ãããã¾ãããã¨ãã°ãã©ããã¦ãªã¹ã¯ã¢ã»ã¹ã¡ã³ãããã« JWT ãã»ãã·ã§ã³ã«ä½¿ã£ã¡ããããï¼ããªã©ãèªãã¨å½æã®è°è«ããããã¾ãã
ç§ã®ç解ã§ã¯ãã»ãã·ã§ã³ç®¡çã«JWTã使ãã¹ããããªãæ´¾ã®ä¸»å¼µã¯æ¬¡ã®ããã«ã¾ã¨ãããã¾ãã
- ä¸ä¸JWTãæ¼æ´©ããã¨ãã«ã»ãã·ã§ã³ãç¡å¹åããæ段ããªããJWTã®æå¹æéåããå¾ ã¤ãããªã
- ãã°ã¢ã¦ãæã«å½è©²JWTãç¡å¹åã§ããªãï¼ããããå®è£ ãå¤ãï¼
- å é¨ç¯ãJWTç½²åç¨ã®å ±ééµãæªç¨ããã¨ä»»æã®JWTãä½ã£ã¦èªè¨¼ãåé¿ã§ãã
- JWTã¯å·¨å¤§ãã¤æ¤è¨¼ã³ã¹ããé«ãã®ã§ãããã¯ã¼ã¯ã¨CPUã®ç¡é§é£ãã§ãã
- JWTãæ¡ç¨ããã¨ã»ãã·ã§ã³IDæ¹å¼ããè¤é度ãä¸ãã£ã¦ãã°ãä½ãããã
ãããã®ææã®ãã¡ãç¹ã«æåã®ãã®ã¯è´å½çãªåé¡ç¹ã¨è¨ãã¾ããä¸å®è¦æ¨¡ã®çµç¹ã§ã®éç¨ãèããå ´åãå©ç¨è ãPCãç´å¤±ãã¦JWTãæªæãã第ä¸è ã«æ¸¡ãã·ããªãªã¯ç¾å®çãªè å¨ã§ããä¸æ¹ãJWTã¯ç½²åæ¤è¨¼ããã¹ããã°JWTã®ä¸èº«ãä¿¡ç¨ããä»çµã¿ãªã®ã§ãJWTãæ¼æ´©ããå ´åã§ã管çè ãç¡å¹åã§ããªãã®ã§ãã
ãã®åé¡ã«å¯¾å¿ãããããä»åå®è£ ããoidc-authã§ã¯JWTå ã«ãªãã¬ãã·ã¥ãã¼ã¯ã³ãæ ¼ç´ããæ¯è¼ççãã¹ãã³ï¼ããã©ã«ã15åï¼ã§æé»çã«ãã¼ã¯ã³åçºè¡ãè¡ã£ã¦ãã¾ããJWTæ¼æ´©ã®æããããå ´åã管çè ãå½è©²ã¦ã¼ã¶ã¼ã®ãªãã¬ãã·ã¥ãã¼ã¯ã³ãç¡å¹åããã°15å以å ã«ã¢ã¯ã»ã¹ã§ããªããªãã¨ããããã§ãã管çè ããªãã¬ãã·ã¥ãã¼ã¯ã³ãç¡å¹åã§ãããã©ããã¯IDãããã¤ãã¼ã«ããã¨æãã¾ãããGoogle WorkspaceãAuth0ãAWS Cognitoãªã©ã§ã¯ç¡å¹åå¯è½ã§ãã
ã¾ãã2ã¤ç®ã®ææç¹ã¸ã®å¯¾å¿ã¨ãã¦ãã°ã¢ã¦ãæã«JWTã«å«ã¾ãããªãã¬ãã·ã¥ãã¼ã¯ã³ãç¡å¹åãã¦ãã¾ã6ãããã«ãããJWTãä»®ã«æ¼æ´©ããã¨ãã¦ã次åã®ãã¼ã¯ã³ãªãã¬ãã·ã¥ã«å¤±æãã¦JWTèªä½ãç¡å¹ã«ãªãä»çµã¿ã«ãªã£ã¦ãã¾ãããã§ã«èª¬æããéãã»ãã·ã§ã³ç¡å¹åã試ã¿ã¦ããä¸å®æéï¼ããã©ã«ã15åï¼ã®ã¿ã¤ã ã©ã°ã許容ããåæãªã®ã§ãã¿ã¤ã ã©ã°1åã§ã許ããªãå ´åã¯ãã®ä»çµã¿èªä½ãæ¡ç¨ã§ããªããã¨ã«ãªãã¾ãã
3ã¤ç®ã®ææç¹ãæ·±å»ãªå 容ã ã¨ç§ã¯èãã¦ãã¾ãã対çã¨ãã¦ã¯å®æçã«éµããã¼ãã¼ãããããããããªãã¨æãã¾ãããç¾ç¶ã ã¨éç¨è ãé å¼µããããªãã®ã§ãoidc-authå´ã§ãä½ãä»çµã¿åãããã¨ããã§ãã
4ã¤ç®ã¯å¤§å¤ããã£ã¨ãã ã¨æãã®ã§ãããã¨ãã¸ã³ã³ãã¥ã¼ãã£ã³ã°ç°å¢ã ã¨ãããã¯ã¼ã¯è»¢ééã¨ã¨ãã¸ã®CPUã¯å®ä¾¡ãªãªã½ã¼ã¹ã§ãããã»ãã·ã§ã³ã¹ãã¬ã¼ã¸ã¯ç¸å¯¾çã«é«ä¾¡ãªã®ã§è¨±ãã¦ã»ãããã¨ããã®ãç§ã®ä¸»å¼µã§ãã
5ã¤ç®ãæ¬å½ã«ãã®éãã§ãã»ãã¥ãªãã£ã®å°éæ§ãä½ãå°äºç®ã®ãã¼ã ãJWTã使ã£ãã»ãã·ã§ã³ç®¡çãèªåå®è£ ããã®ã¯ä¸è¬è«ã¨ãã¦å±éºã ã¨æãã¾ããã¨ã¯ãããä»åç§ã¯ä¸å®ä»¥ä¸æ¤è¨ãã¦ä½ã£ãã¤ããã§ãããOSSã®å½¢ã§ã¿ããªã§å©ãã¦ããã°å®å ¨ãªãã®ãã§ããã®ã§ã¯ãªãã§ããããããããããã¦ãã¦ãèç©ã§ããç°å¢ã¨ãã¦Honoã¯ç´ æ´ããããã©ãããã©ã¼ã ã ã¨æã£ã¦ãã¾ãã
ã¾ã¨ã
OpenID Connectã®ãã°ã¤ã³ã»ãã·ã§ã³ç¶æããã©ã¦ã¶ã¯ããã¼ã ãã§å®ç¾ãããããªHonoã®ããã«ã¦ã§ã¢oidc-authãå®è£ ãã¾ãããCDNã¨ãã¸ã¨ç¸æ§ãè¯ããå®ä¾¡ã«èªè¨¼ã»èªå¯ãå®ç¾ã§ãã¦ä¾¿å©ã ã¨æãã¾ããã¾ãã»ãã¥ãªãã£ã«ã¤ãã¦ãèæ ®ãã¦ããã¤ããã§ãã
ã¨ã¯ããoidc-authã«ã©ã®ç¨åº¦ã®ãã¼ãºããããä½è èªèº«ãããããã£ã¦ãã¾ããã®ã§ã使ã£ã¦ã¿ã¦ã®ææ³ããæè¦ãããã ããã¨å¬ããã§ãã
æå¾ã«ãï¼ããããå¾ä½ã®ãããªãç¶æ ã§ï¼oidc-authãHonoã®3rd-party middlewareã¨ãã¦æ¡ç¨ããã ãã@yusukebeããã«æè¬ãããã¾ãããã®è¨äºãå ã«READMEã«è¿½è¨ãã¦ãããå°ãå®å¿ãã¦ä½¿ããç¶æ ã«ãããã¨æãã¾ãã
- ç°å¢ã«ãã£ã¦ã¯Rustãªã©ã§è¨è¿°ãã¦WebAssemblyã§åä½ããããã¨ãã§ãã¾ãããææåã®é¸æè¢ã¨ã¯è¨ããªãæ°ããã¾ã↩
- ããªã¼ãã©ã³ã ã¨10msã¨ããã«å¶ç´ãå³ãããªãã¾ããã¾ãã50msããé·æé使ããå¥ãã©ã³ãæä¾ããã¦ãã¾ãã↩
- ããã¾ã§ç§ã®è§£éãªã®ã§ãéã£ãå©ç¹ã«çç®ãã¦ããã¦ã¼ã¶ã¼ãå¤ãã¨æãã¾ã↩
- IDãã¼ã¯ã³ã®subãã£ã¼ã«ã↩
- oauth4webapièªä½ãå©ç¨è ãå¤ãç¶ç¶çã«ã¡ã³ããã³ã¹ããã¦ããã©ã¤ãã©ãªã§ãOpenID Connectã§å¿ é ã¨ãããstateãã©ã¡ã¼ã¿ãnonceãã©ã¡ã¼ã¿ãcode_challengeãã©ã¡ã¼ã¿ã®3ã¤ã®æ¤è¨¼ãæ¨æºã§ãµãã¼ããã¦ãã¾ããã¾ããalg:noneãæå¦ãããªã©ã»ãã¥ãªãã£è¦³ç¹ã®ãã¹ããã©ã¯ãã£ã¹ãå®è£ ããã¦ããããã«æãã¾ãã↩
- æ¬ç¨¿ãµã³ãã«ã³ã¼ããã·ã¼ã±ã³ã¹å³ã§ã¯ãã°ã¢ã¦ãå¦çãçç¥ãã¦ãã¾ãããã¡ããã¨å®è£ ãã¦ããã¾ã↩
ãã¤ãã³è£½ã¨ã¢ã³ã³ã®ãªã¢ã³ã³ãã«ãã¼ã3Dããªã³ã¿ã§èªä½ãã
çè ã¯èªå® ã®ãã¤ãã³è£½ã¨ã¢ã³ã³ã®ãªã¢ã³ã³ãã«ãã¼ã3Dããªã³ã¿ã§èªä½ãã¾ãããããã§ãªã¢ã³ã³ãè¡æ¹ä¸æã«ãªãçæ´»ã¨ã¯ãããã°ã§ãã
ãã®STLãã¡ã¤ã«ã¯Thingiverseã«ã¢ãããã¼ããã¦ããã¾ãï¼Wall mounted Daikin AC remote control holder by hnw - Thingiverseï¼ãå¿ è¦ãªæ¹ã¯åèªããªã³ããã¦ã¿ã¦ãã ããã
ããããªè©±é¡ã§ãããåãæ©ã¿ãæã£ã¦ãã人åãã«ããå°ã説æãã¾ãã
ãã¤ãã³è£½ã¨ã¢ã³ã³ã¯ãªã¢ã³ã³ãã«ãã¼ãå¥å£²ã§å°ã£ã
çè ã¯æè¿å¼ã£è¶ãããã§ãããå¼ã£è¶ãå ã®åãä»ãã¨ã¢ã³ã³ããã¤ãã³è£½ã§ããã
å¼ã£è¶ãã¦ããæ°ã¥ãããã§ããããã¤ãã³ã£ã¦ã¨ã¢ã³ã³ã®å£æããªã¢ã³ã³ãã«ãã¼ãå¥å£²ãªãã§ãããä¸æ¹ã§çè ã¯ãªã¢ã³ã³ãè¡æ¹ä¸æã«ããç¹æãæã£ã¦ããã®ã§ããªã¢ã³ã³ãå®ä½ç½®ã«ãªãã¨æ¬å½ã«ä¸ä¾¿ãªãã§ããã
åé¡è§£æ±ºã®ããå¥å£²ã®ãªã¢ã³ã³ãã«ãã¼ãè²·ãããã¨ãæã£ããã§ãããç´æ£ã®ãªã¢ã³ã³ãã«ãã¼ã¯å£ã«ãã¸æ¢ãããåæã ã£ãã®ã§è²·ãã®ãããã¾ãããç©ä»¶ã®è³è²¸å¥ç´ã®ã«ã¼ã«ã¨ãã¦å£ã«ç©´ãéãã¡ããã¡ãªãã§ãã
å «æ¹å¡ããã®ç¶æ³ã§ãããåãæ©ã¿ãæ±ãã¦ãã人ãæ¥æ¬ä¸ã«æ°ç¾äººãããããããããªãã§ããããã
ä»äººã®ä½ã£ããªã¢ã³ã³ãã«ãã¼ã®è¨è¨å³ãæ¢ãã¦ã¿ã
ä»åã®ãããªå®çæ´»ã®ããããªæ©ã¿ã解決ããä¸ã§ã3Dããªã³ã¿ã¯é常ã«ä¾¿å©ãªéå ·ã§ããä»»æã®å½¢ç¶ã®ãã©ã¹ããã¯è£½ãã¼ããå®ç¨æ§ã®ãã強度ã§ä½æã§ãã¾ãã
ã¾ãã大æµã®æ©ã¿ã¯ä¸çä¸ã®èª°ããæ¢ã«è§£æ±ºãã¦ããã®ã§ã欲ãããã®ãããã°è¨è¨å³ï¼STLãã¡ã¤ã«ï¼ãæ¢ãã¦ã¿ãã®ãè¯ãã§ãããããã¾ãããã°ä»äººã®è¨è¨å³ã3Dããªã³ãããã ãã§åé¡è§£æ±ºã¨ããããã§ãã
å®éããdaikin remote holder 3dããªã©ã§æ¤ç´¢ããã¨STLãã¡ã¤ã«ãä½åãè¦ã¤ãããã§ãããæ®å¿µãªããçè ã®ãã¼ãºã«åããã®ã¯è¦ã¤ããã¾ããã§ããã
çè ã®ãã¼ãºã¯æ¬¡ã®éãã§ãã
- ãã«ãã¼ã両é¢ãã¼ãã§å£ã«åºå®ã§ãã
- ãªã¢ã³ã³ãå£ã«ãããã¾ã¾ã§ãªã¢ã³ã³æä½ãå¯è½
- å½¢ç¶ã¯ç®±åã§ã¯ãªãããã¯
3çªç®ã®ããã¯å½¢ç¶ã¨ããã®ãè£è¶³ããã¨ã対象ã®ãªã¢ã³ã³ã¯è£å´ã«ããã¯ã§å¼ã£æããããã®å¹ã¿ããããã§ãããããã§å¼ã£æãã¦ä½¿ããããã¨ãããã¨ã§ãã
ãªããã°ä½ããï¼ãªã¢ã³ã³ãã«ãã¼ãèªä½
ä»äººã®è¨è¨å³ãè¦ã¤ãããªãã£ãå ´åã«ã¯èªåã§3Dã¢ããªã³ã°ãããã¨ã«ãªãã¾ããã¨ã¯ãããå¿ ãããã¼ãããä½ãå¿ è¦ã¯ããã¾ãããä»äººã®ä½åãæ¹é ãã¦ä½ããã¨ãã§ãã¾ãã
çè ãæããä½åãæ¹é ãã¦èªåã®æ¬²ãããã®ãä½ã£ã¦ã¿ã¾ãããçè ã¯ã¢ããªã³ã°ç´ 人ãªã®ã§ã¼ãããä½ãã®ã¯å³ãããã§ãããæ¹é ãªãé°å²æ°ã§ä½ã¨ããªãã¾ããã
åºé¢ãçãã®ã§ããªã³ãé£æ度ãå°ãé«ãããããã¾ãããã注æãã ããã
使ã£ã¦ã¿ã¦ã®ææ³
試è¡é¯èª¤ã®ç²æãã£ã¦ãèªåã®ãã¼ãºã«ããããããã®ãã§ãã¾ãããã¬ãã¥ã¼ãè¦ãã¨ç´æ£ãã«ãã¼ã§ããªã¢ã³ã³ãå£ããæµ®ãã¦ãã¾ããããªã®ã§ãç´æ£åããå®ç¨æ§ãé«ãæ°ããã¾ãããã¤ãã³è£½ã¨ã¢ã³ã³ããæã¡ã®æ¹ã¯æ¯éã試ããã ããã
3Dããªã³ããããã«ãã¼ãå£ã«åºå®ãã両é¢ãã¼ãã¯ä»¥ä¸ã®è£½åã便å©ã§ãã
*1:New Daikin AC remote wall hanger by gmarcell / CC-BY
èªå® ã®PCç°å¢ãæ¹åãããååè©ãæ²»ã£ã話
ã³ããã®å½±é¿ãããããã®3å¹´ã»ã©ã§å¨å® å¤åã®ä¼ç¤¾ãããå¤ããªã£ãå°è±¡ãããã¾ãã ããã«ä¼´ããèªå® ã®PCç°å¢ãæ¹åãã人ã£ã¦å¤ãããããªãã§ããããã ãå¤åã«æ¼ããç§ãPCç°å¢æ¹åãè¡ãã¾ãã¦ãä¸è¨ã®ãããªç°å¢ãæ®æ®µä½¿ãã®ç°å¢ã«ãªãã¾ããã
ä¸è¦ãããµããç°å¢ã«è¦ããããããã¾ããããç§ã¯ãã®ç°å¢ãæã«å ¥ãã¦ãããããã¾ã§æ©ãã§ããååè©ã®çç¶ã大ããæ¹åãã¾ããã
æ¬ç¨¿ã§ã¯ããã®ç°å¢ã«è³ã£ãçµç·¯ã¨è³¼å ¥ãã製åãç´¹ä»ãã¦ããã¾ããåãæ©ã¿ãæã¤æ¹ã¯ãã¡ãããååè©ã»äºåè©äºåè»ã®æ¹ãåèã«ãã¦é ããã°ã¨æãã¾ãã
ãã¼ãã¼ãç°å¢ã®ç´¹ä»
ä¸è¨ã®åçã ã¨ããã人ã«ããããããªãã¨æãã®ã§ãå®éã®ä½¿ãæ¹ãç´¹ä»ãã¾ãã
ã³ã³ãã¯ããã¼ãã¼ãï¼HHKBï¼2å°ã1ã¤ã®PCã«æ¥ç¶ããå·¦å³åå²ãã¼ãã¼ãã®ããã«å©ç¨ãã¦ãã¾ãã
ãã¦ã¹ãã¤ã³ã¿ã¼ãåããããæã¯çãä¸ã®ãã©ãã¯ãã¼ã«ã使ãã¾ãããã©ãã¯ãã¼ã«ã®ä½ç½®ãç°å¸¸ã«è¦ããããããã¾ããããæ £ããã¨é常ã«ä½¿ããããã§ãã
ã¾ãããªã¹ãã¬ã¹ãã¨èªä½ã®ãã¼ãã¼ãã«ãã¼ã«ããããã¼ã ãã¸ã·ã§ã³ã«æ»ããããããã«å·¥å¤«ãã¦ãã¾ãã
ã¡ãªã¿ã«HHKBã2å°è²·ãã¨ç¸å½ãªãå¤æ®µã«ãªããã§ãããå½æã®ç§ã¯ååè©è§£æ¶ã®ãããªãå ¨ç¶æãããªãã¨æã£ã¦ãã¾ããããããããååè©ãã¹ãã¬ã¹ã ã£ããã§ãããã
ååè©ã¨ã¯
ååè©ãååã ãã¯èãããã¨ããã人ãå¤ãã¨æããã§ãããã©ãããç¶æ ããã³ã¨ãã人ã¯å¤ããªãã®ã§ã¯ãªãã§ããããã
ç§ã®ç解ã§ã¯ãååè©ã¨ã¯è©é¢ç¯ã®å¯ååãçããªããå¯ååã®ãªã®ãªä»è¿ã§è©ã®çã¿ãåºã¦ãããããªçç¶ã®ç·ç§°ã§ãã æåã®ãã¡ã¯è©ãä¸ããã«ãããªï¼ãããã®æè¦ãªãã§ãããæªåãã¦ããã¨é«ãæ£ã®ãã®ãåã£ããYã·ã£ãã«çæ¿ããããããã³ã«çã¿ã§æ³£ãããã«ãªãã¾ãã ã¾ããæªãæ¹ã®è©ãä¸ã«ãã¦å¯è¿ããæã¤ã¨çãã¨ããã®ãå ¸åççç¶ã§ãããã®ã¬ãã«ã¾ã§æªåããã¨ããç ããªãã¦ã¤ãããã§ãããã
ç§ã¯å¨å® å¤åéå§å¾ã«ååè©ãçºçãã¦ã©ãã©ãæªããªã£ã¦ããã¾ããã ä»ã«ãã¦æãã°å¨å® å¤åã«ãªã£ã¦æºãæ¤ åãå¤ãã£ããã¨ã§å§¿å¢ãæªããªãè©ã¸ã®è² æ ã大ãããªã£ã¦ãããã ã¨æãã¾ãããå½åã¯èªå® ç°å¢ã«åé¡ãããã¨ã¯å¤¢ã«ãæãã¾ããã§ãããä»ã¾ã§ãåæ¥ã«åãç°å¢ã§ä½æ¥ãã¦ããã®ã§ããããè¯ãç°å¢ã ã¨ããæãè¾¼ã¿ããã£ãããããã¾ããã
ãã®å¾ãããªãæªåãã¦ããç é¢ã«ãããã¾ãããä¸ã è¯ããªãããèã«ããããæãã§ä½æ¥ç°å¢ã®æ¹åã«æè³ãã¦ã¿ãã¨ããç®ã«è¦ãã¦ååè©ãæ¹åããã¨ããããã§ãã
ãããããç§ã®å ´åã¯å·»ãè©ãã¯ã»ã«ãªã£ã¦ãã¦ååè©ãæªåãã¦ããã®ããè©ã極端ã«éããã¸ã·ã§ã³ã«ãããã¨ã§ãã¾ãç¯æ£ã§ããã¨ãããã¨ã§ãããã
ãã¡ããããã¼ãã¼ããå¤ããã ãã§ååè©ãæ²»ãä¿è¨¼ã¯ããã¾ãããè©ã«ç³ç°ãã§ããã¿ã¤ãã®ååè©ãããããã§ããã®å ´åã¯æè¬ãæè¡ã§ãªãã¨æ²»ããªãã§ãããã念ã®ããè£è¶³ã§ããã
æºã®é«ãæ°cmã®èª¿æ´ãéè¦
ãããå¾ããæ°ã¥ãããã¨ã§ãããå ã 使ã£ã¦ããæºã¯ç§ã®åº§é«ã«å¯¾ãã¦é«ããã§ãããå°æãªç·æ§ã女æ§ã«ã¨ã£ã¦ãå¸è²©ã®æºã¯ãã¼ãã¼ãä½æ¥ã«ã¯é«ããããã¨ãå¤ãããã§ãã
æ¤ åã¨æºã®é©åãªé«ãã¯ä¸è¨ãµã¤ããªã©ã§èª¿ã¹ããã¾ããç§ã®å ´åã¯ãã¨ãã¨ä½¿ã£ã¦ããæºãæé©ãªé«ããã5cmé«ããã¨ããããã¾ããããããååè©ãæªåãããåå ã ã£ãããã«æãã¾ãã
ç§ã¯HHKBã¨åææã«é»åã¹ã¿ã³ãã£ã³ã°ãã¹ã¯ãè³¼å ¥ãã¾ããããã®ãã¹ã¯ã0.1cmå»ã¿ã§æ°è»½ã«é«ã調æ´ã§ããç¹ãååè©æ¹åã«å½¹ç«ã£ãããã«æãã¾ããã¾ããæ¤ åã«åº§ã姿å¢ã¨ç«ã£ã姿å¢ã¨ãé »ç¹1ã«åãæ¿ãããã¨ã§è©ãåããããããªãå©ç¹ãããã¾ããã
ã¾ã¨ã
è©ãéããã¸ã·ã§ã³ã§ãã¼ãã¼ãä½æ¥ãè¡ããã¨ãã¾ãæºã®é«ããé©åã«èª¿æ´ãããã¨ã§ååè©ãæ¹åããä½é¨è«ãç´¹ä»ãã¾ãããåãæ©ã¿ãæ±ãã¦ããæ¹ã®åèã«ãªãã°å¹¸ãã§ãã
ç§ã®å ´åã¯ååè©ã®è¦ãã¿ããéãããä¸å¿ã§é«é¡ãªååãè²·ã£ã¦ãã¾ãã¾ããããããã¾ã§ãéã使ããªãã¦ãè¯ãã£ãã®ããããã¾ãããã¨ã¯ãããHHKBãé»åã¹ã¿ã³ãã£ã³ã°ãã¹ã¯ãè¯ãè²·ãç©ã ã£ãã¨å人çã«ã¯æãã¦ãã¾ãã
FAQ
Q1: HHKBã2å°è²·ããªãã»ãã¬ã¼ãåãã¼ãã¼ãã§è¯ããªãï¼
A1: ããã¨æãã¾ãï¼ãã ãç§ã¯å³æã§6ãã¿ã¤ããããæ´¾ã§å¸è²©åã®ã»ãã¬ã¼ãåãã¼ãã¼ãã ã¨é¸æè¢ãå°ãªãã£ããã¨ãã¾ãèªä½ãã¼ãã¼ãç³»ã¯æ²¼ã£ã½ãã®ã§é æ ®ããçµæãè²·ã£ã¦ã絶対ããºã¬ã®ãªãHHKBãé¸æãã¾ããã
Q2: ãã¼ãã¼ãã2å°ä½¿ãã¹ã¿ã¤ã«ã ã¨Ctrl+pã¨ããæã¦ãªããªãï¼
A2: Macã ã¨HHKB2å°ãå¥ãã¼ãã¼ãæ±ãã«ãªãã2å°ã«ã¾ããã£ãã¿ã¤ããå®ç¾ããã«ã¯ãã¼ãã¼ãã«ã¹ã¿ãã¤ãºã½ãããå¿ é ã§ããKarabiner-Elementsãå ¥ãã¾ããããWindowsã®å ´åã¯ä½ãããªãã¦ãåããããã§ãã 2å°ã«ã¾ããã£ã¦Fnãã¼ã使ããªãã®ã¯äºå®ã ã¨æãã¾ãããç§ã¯Emacsãã¤ã³ãã£ã³ã°ã ãã§çãã¦ããã®ã§å¹³æ°ã§ããã
Q3: åçã«åã£ã¦ãMacBook Proã¨Mac miniãã©ã£ã¡ã使ã£ã¦ãã®ï¼
A3: MacBook Proã ããä¼ç¤¾ã®è²¸ä¸åã§ãæ¥åæéãã©ããã§ä½¿ãåãã¦ãã¾ããKVMåãæ¿ãæ©ã ã¨USB Type-C 2å ¥åã«å¯¾å¿ã§ããªãã®ã§HHKBã¯é½åº¦å·®ãæ¿ãã¦ãã¾ããé½åº¦å·®ãæ¿ããã®ã¯ã¤ã±ã¦ãªãã§ããâ¦
Q4: ãã£ã¹ãã¬ã¤ã¯ä½ã使ã£ã¦ãã®ï¼
A4: Acerã®34ã¤ã³ãUWQHD(3440Ã1440)ãã£ã¹ãã¬ã¤ãã¨ã«ã´ããã³ã®ã¢ãã¿ã¼ã¢ã¼ã ã§åã£ã¦ãã¾ãã
- å¹³åããã¨1æ¥ã«10åãããã¯ç«ã£ãã座ã£ããåãæ¿ãã¦ããæ°ããã¾ã↩
PHPerKaigi2022ã§PHPããGoogle Assistantã使ã話ããã¾ãã
ããªãæéã空ãã¦ãã¾ãã¾ããããå æè¡ãããPHPerKaigi 2022ã«ã¦ããPHPerã ã£ã¦PHPãããOKã°ã¼ã°ã«ããããï¼ãã¨ããã¿ã¤ãã«ã§çºè¡¨ãã¾ããã
çºè¡¨ã®å 容ã¨ãã¦ã¯PHPããgRPCã使ã£ã¦Google Assistant APIãå©ãã¨ãããã®ã§ããããã¬ã¼ã³ã®æå¾ã«PHPãããå ¨é¨æ¶ãã¦ãã¨ããå½ä»¤ãæãã¦èªåã®é¨å±ãçã£æã«ãããã¢ãå®æ½ããã®ã§ãããç¡äºæåãã¦ã¦ã±ãã®ã§æºè¶³ã§ãã
ä»åã®ã³ã¼ãã¯ä¸è¨URLã§å ¬éãã¦ãã¾ããçãããOKã°ã¼ã°ã«ãã¦ã¿ã¦ãã ããã
PHP+gRPC 仲éãå°ãªããã¦ããã©ãåé¡
ä»åã®çºè¡¨å 容ã¯ãããã°ã§ããã§ãããã¨ããã¬ãã«ã®è©±ã«è¦ããã¨æããã§ãããå®ã¯åããã¾ã§ã«ããªãè¦å´ãã¾ãããgRPCãªã®ã§ä½¿ããããªã¯ã©ã¹ãå¼æ°ã®åå®ç¾©ãªã©ã¯èªåçæãããã®ã§ãããèªåã®ãããããã¨ãå®ç¾ããã®ã«ä½ãã©ãå¼ã³åºããã®ããã¥ã¡ã³ãããªããããªãã®è©¦è¡é¯èª¤ãå¿ è¦ã§ãããä»ã®è¨èªã®å®è£ ãåèã«ãã¦ããã®ã§ãããè¨èªãå¤ããã¨ã¤ã³ã¿ã¼ãã§ã¼ã¹ãå¤ãã£ã¦ãã¾ãã®ã§ãããã«æããããã¨ãããããã¾ãã
ããããPHPããGoogle Assistant APIãå©ããã®ã¯ç§ãä¸çã§åãã¦ã ã£ãå¯è½æ§ãããããã§ãå°ãªãã¨ãGitHubä¸ã§ã¯ä»²éã¯è¦ã¤ããã¾ããã§ããï¼ãã¾æ¤ç´¢ãã¦ãè¦ã¤ããã®ã¯ç§ãä¸ãããã®ã ãã§ãï¼ã
ã¾ããPHP+gRPCã§SSLæ¥ç¶ããæ¹æ³ã調ã¹ã¦ããããåå¹´åã¾ã§ä¸å¯è½ã ã£ãã®ãä¿®æ£ãããï¼ã¨ããè¨äºãçºè¦ãã¦è¡æãåãã¾ãããçããSSLãªãã§ã©ããã£ã¦å©ç¨ãã¦ããã§ããï¼ã¨ããã¬ãã«ã®è©±ã«è¦ãã¾ãã
ããããPHP+gRPCã®è¨äºèªä½ãããä¸ã§ãã¾ãè¦ãªããã§ããããPHPã«ã¤ãã¦ããã¨gRPCã¯ã©ã¤ã¢ã³ãã¯ä½ãããã©gRPCãµã¼ãã¯ä½ããªãè¨èª1ãªã®ã§ãPHPã¦ã¼ã¶ã¼ã®ä¸ã§gRPCãæµè¡ã£ã¦ãªãã¨ããã®ã¯ããããã§ãããããã«ããã£ã¦æ å ±ãå°ãªãããå°è±¡ã§ãã
PHP+gRPCãå©ç¨ãã¦ããä¼ç¤¾ããã¯ãããã工夫ãè¦å´ãããã¨æãã¾ãã®ã§ãå°ãã¿ã§ãå ¬éãã¦é ããã¨çéãçãä¸ããããã«æãã¾ãã
gRPCã®ææ
ç§ã¯gRPCèªä½åä½é¨ã ã£ãã®ã§ããã®ææãå°ãç´¹ä»ãã¾ãã
gRPCã®ç¹å¾´çãªç¹ã¯ãåè¨èªã®ã©ã¤ãã©ãªã»ã¢ã¸ã¥ã¼ã«ã¬ãã«ã§èªåçæãè¡ãããç¹ã ã¨æãã¾ããã
ãã¨ãã°Goã®å ´åã¯gRPCã®èªåçæã³ã¼ããGitãªãã¸ããªã¨ãã¦å ±æããã°ãã®ã¾ã¾ã©ã¤ãã©ãªã¨ãã¦å©ç¨ãããã¨ãã§ãã¾ãï¼åç §ï¼https://github.com/googleapis/go-genprotoï¼ã大éã®APIã大人æ°ã«ä½¿ã£ã¦è²°ããããªç¶æ³ã§ããã°ãgRPCãæ¡ç¨ãããã¨ã§ã©ã¤ãã©ãªã®ã¡ã³ããã³ã¹ã³ã¹ããä¸ãããããã§ããã
PHPã®å ´åãå¤ãã®ã¯ã©ã¹ãèªåçæãããã®ã§ã誰ãæ¸ãã¦ãåãã³ã¼ãã«ãªããããã大人æ°éçºã§ã¯ç¹ã«ã¡ãªããã大ãããã§ãã
ãã®ä»£åã¨ããããã§ã¯ãªãã§ãããããä»çµã¿ãè¤éããã¦ãã¼ãã«ãé«ãããã«æãã¾ãããç§ã¯ç°å¢ã»ããã¢ããã§å¿ãæãããã¾ããã
PHPerKaigi 2022ã«ã¤ãã¦
ä»åã®PHPerKaigi 2022ã¯ä¼å ´åå ãã§ããããªã¢ã¼ãåå ãã§ããããã¤ããªããéå¬ã§ãããç§ã¯åæ¥ã¯ä¼å ´ã«è¡ãã2æ¥ç®ã¯ãªã¢ã¼ãåå ãã¦ããã®ã§ããã好ããªæ¹ãé¸ã¹ãã®ã¯åå ã®å¹ ãåºãããã¦è¯ãã§ããã
çºè¡¨å 容ãå¤å²ã«ããã£ã¦ãã¦é¢ç½ããã®ã°ããã§ãä¹ ã ã«åºæ¿ããããã¾ãããã¯ãããããã¯ããéå¶ã®çæ§ãæ¬å½ã«ãããã¨ããããã¾ããã
-
ããªãé å¼µãã°ã§ããã¨ãã説ãããã¾ãããå®ç¨çãã¯çåã§ã↩
PHPerKaigi 2021ã§PHPã®ä¸å¤é åãé«éãã¤çã¡ã¢ãªã ã¨ãã話ããã¾ãã
ãã®3/26ã3/28ã«PHPerKaigi 2021 ã¨ããåå¼·ä¼ããããç§ã¯ãPHP7ããä¸å¤é åãOPcacheã«ä¹ãã®ã§KVSãç½®ãæãããããããããªãã¨ãã話ãã¨ããã¿ã¤ãã«ã§çºè¡¨ãã¾ããã
æ¹ãã¦è¦ç´ãã¦ã¿ãã¨çºè¡¨ã¿ã¤ãã«ã¡ãã£ã¨ä½è¨ã£ã¦ããåãããªãã§ãããè¨ãããã£ããã¨ã¨ãã¦ã¯ãPHP5ã¾ã§ã¯PHPåä½ããKVSã使ã£ãæ¹ãæç¶ãã·ãªç¶æ³ããã£ããã©ãPHP7+OPcacheãªãKVSã«åã¦ããã¨ãããã¨ãªãã§ãããå ¨ç¶ä¼ãããªãã¿ã¤ãã«ã«ãªã£ã¦ãã¾ãããâ¦ãåçã§ãã
å 容ã¨ãã¦ã¯OPcahceæå¹ã®ã¨ãã«éãPHPã³ã³ãã¤ã«æã«å ¨è¦ç´ ã確å®ã§ããé åï¼ä¸å¤é åï¼ãç¹å¥æ±ãããã¦ããããé«éãã¤çã¡ã¢ãªã§ãã¨ãã話ãç´¹ä»ãã¾ããã
æ¬ããã°ã®è¨äºãPHP7ããå®æ°é åãOPcacheã«ä¹ãã®ã§å·¨å¤§é åã使ãæ¾é¡ã¨ãã話ãã®ç¼ãç´ãã§ã¯ãããã§ãããæ°ãã«èª¿ã¹ãå 容ãããããã¨ãã°ä»¥ä¸ã®ã°ã©ãã¯æ°ä½ã§ãã
ä»åããã¬ã¼ã³ããå¾ã«ä½åã質åãããã®ã§ããããã«ã¤ãã¦è£è¶³ãã¾ãã
Q1: ã³ã¬ã©ãããã¦ã¼ã¹ã±ã¼ã¹ãæ³å®ãã¦ãã®ï¼
çºè¡¨ããå 容ã¯å®éã«æ´»ç¨ãã¦ãã®ï¼ã¨è¤æ°åèããã¾ãããç§ã®èº«è¿ã§ã¯è¿ãå©ç¨æ³ããã¦ããããã¸ã§ã¯ããããã®ã§ãããæ´æ°ãä½é »åº¦ã§å·¨å¤§ãªãã¹ã¿ã¼ãã¼ã¿ãæ±ãã¨ããã®ã¯çãããã¼ãºããããã¾ããã
ç§ã®ä¼ç¤¾ã¯ã¹ãã¼ããã©ã³ã²ã¼ã ã®éçºããã¦ããã®ã§ãããã¹ãã¼ããã©ã³ã²ã¼ã ã§ã¯ãã©ã³ãã¼è·ã®æ¹ã巨大ãªãã¹ã¿ã¼ãã¼ã¿ãä½ããã¨ããããã§ãããä»åã39ä¸è¦ç´ ã®é åãä¾ã«åºãã¾ãããã©ãé·æéå¶ã¿ã¤ãã«ã ã¨æ¬å½ã«ãããããã®è¦æ¨¡ã«ãªã£ãããã¾ã1ãããã«ããããããã¼ã¿ã¯ãµã¼ãã ãã§ãªãã¢ããªã«ãçµã¿è¾¼ããã¨ããããæ´æ°ã®é »åº¦ã¯ããã¾ã§é«ãããã¾ããã
ãããªããã§ããã¨ãã°ECãµã¤ãã¨ãã§ã¯ãã¾ã使ãéããªãããã§ãããæã ã®åæ¥ä»ç¤¾ããã ã¨è¿ããã¼ãºãããããã«æãã¾ãã
Q2: OPcacheç¡ãã®ã¨ãä¸å¤é åã®æ±ãã¯ã©ããªãã®ï¼
OPcacheæ¡å¼µãæå¹ã«ãªã£ã¦ããªãå ´åãå ¨ã¦ã®é åã¯å¾æ¥éãopcodeåã«ã³ã³ãã¤ã«ãããã®ã§é度é¢ã®ã¡ãªããã¯ããã¾ãããä¸å¤é åã®å¤å®ã¨æ§ç¯ã¯OPcacheã®æé©åãã§ã¼ãºã§è¡ããã¦ãããPHPæ¬ä½ã®ã³ã³ãã¤ã«å¦çã§ã¯ä¸å¤é åã«é¢ããç¹å¥ãªå¦çã¯ä½ããªãã®ã§ãã
Q3: ä¸å¤é åãçéã«ãªãã®ã£ã¦2åç®ä»¥éã®ã¢ã¯ã»ã¹ã§ããï¼
ãã®éãã§ãã説æããµãã£ã¦ã¾ããã
1åç®ã®ã¢ã¯ã»ã¹ã¯OPcacheã«ä¹ã£ã¦ããªãã®ã§ãPHPã¹ã¯ãªããã®ã³ã³ãã¤ã«ããã¦OPcahceã®æé©åå¦çãèµ°ã£ã¦å ±æã¡ã¢ãªä¸ã«é åãæ§ç¯ããå¿ è¦ãããã®ã§ãããªãé ãã§ããæ¬æ°ã§ä½¿ããªãpreloadingã¨opcache_compile_file()ã®å©ç¨ãæ¤è¨ããæ¹ãããã§ãããã
éã«2åç®ã¢ã¯ã»ã¹ã§ã¯ãã£ãã·ã¥ããåãåºããopcodeåã®æç¹ã§ä¸å¤é åãåç §ãã¦ããã®ã§ããããéãããã¨ããçå±ã§ãã
ææ³ãªã©
ä»å¹´ã®PHPerKaigiã¯ãªã³ã©ã¤ã³ã§ããããé常ã«é¢ç½ãã£ãã§ããè¬æ¼ã¯äºååé²ã§ããããèªåã®åé²ãè¦ãªããDiscordã§åºã質åã«çããã¨ããä½é¨ã®ã¯æ°é®®ã§ããã
ã¾ãã飽ããããªããããªä»æããå¤ãã®ãè¯ãã£ãã¨æãã¾ããè¬æ¼ä¸ã«ãã³ãã³ã§ã³ã¡ã³ããæµãã¦ããã®ãè¯ãã£ãã§ãããä¼ã¿æéã«Discordã§éè«ãã¯ãã¾ã£ãããZoomã§ã¢ã³ã«ã³ãã¡ã¬ã³ã¹ãéå¬ããã¦ãããã§ããªãã©ã¤ã³ã¨ã¯éã£ãé¢ç½ããæãã¾ããã
æå¾ã«ãªãã¾ãããã¹ã¿ããã®çæ§ãä»å¹´ããã¤ãããã¾ã§ãããããã»ã©ã®è¦æ¨¡ã«ãªãã¨éå¶ã¯æ¬å½ã«å¤§å¤ã ã¨æãã¾ãããæ¥å¹´ãæå¾ ãã¦ããã¾ãã®ã§ãããããé¡ããããã¾ãã
-
縦ã ãã§ãªã横ã«ãé·ããã¨ãå¤ãã§ã↩
ç¹å®ãã¹ãåã®éä¿¡ã ãVPNçµç±ã«ããã«ã¼ã¿è¨å®ï¼OpenWrtç·¨ï¼
èªå® ã®ã«ã¼ã¿ã¼ã®è¨å®ã§ãæ®æ®µã®éä¿¡ã¯ããã©ã«ãã²ã¼ãã¦ã§ã¤ã使ããããã©ãä¸é¨ã®ãã¹ãåã®éä¿¡ã ãã¯VPNãã³ãã«ã¤ã³ã¿ã¼ãã§ã¼ã¹ã使ããããã¨ããç¶æ³ãã¾ãã«ããã¾ããä¸è¬çãªãã¼ãºã§ã¯ãªãã¨æãã¾ãããå°ãªãã¨ãç§ã«ã¯ãããããã¼ãºãããã¾ããã
IPã¢ãã¬ã¹ãã¨ã«å¤åãã¤ã³ã¿ã¼ãã§ã¼ã¹ãåãæ¿ãããã®ã§ããã°iptablesã®è¨å®ã ãã§å®ç¾ã§ãã¾ããä¸æ¹ã§ããã¹ãåã«ãã£ã¦ã¤ã³ã¿ã¼ãã§ã¼ã¹ãåãæ¿ããã®ã¯ä¸è¬çã«ã¯å°é£ã§ãï¼ãã¹ãåã®è§£æ±ºã¯ã¢ããªã±ã¼ã·ã§ã³å±¤ã§è¡ãããã®ã«å¯¾ããiptablesã¯ãããã¯ã¼ã¯å±¤ã»ãã©ã³ã¹ãã¼ã層ã§ã®å¦çã«ãªãããï¼ããã®ãããªå ´åã«ãIPsetçµç±ã§dnsmasqã¨iptablesãé£æºãã¦ã«ã¼ãã£ã³ã°ãåãæ¿ããæ¹æ³ãããã¾ããæ¬ç¨¿ã§ã¯ãã®ããæ¹ã説æãã¾ãã
OpenWrtã¨ã¯
OpenWrtã¯çµã¿è¾¼ã¿ç¨éã®Linuxãã£ã¹ããªãã¥ã¼ã·ã§ã³ã§ã家åºç¨ã®æç·LANã«ã¼ã¿ã»Wi-Fiã«ã¼ã¿ã®ãã¡ã¼ã ã¦ã§ã¢ãç½®ãæãããã¨ã§æ©è½è¿½å ããããã«ã¹ã¿ãã¤ãºæ§ãé«ããããããã¨ããããã¸ã§ã¯ãã§ããã«ã¼ã¿ã®æã¤åºæ¬çãªæ©è½ï¼PPPoEããã¡ã¤ã¢ã¦ã©ã¼ã«ã®è¨å®ï¼ã«å ããDDNSã»VPNã»VLANã»QoSãªã©ã®è¨å®ãGUIããå¯è½ã«ãªãã¾ããã¾ããã«ã¼ã¿ã«sshã§ãã°ã¤ã³ã§ããããã«ãªãã®ã§ããã©ãã«ã®åãåããããããããªãã¡ãªãããããã¾ããèªå® ã®ãããã¯ã¼ã¯ã§è²ã éã³ãã人ã«ã¯ãå§ãã®é¸æè¢ã§ãã
å¿ è¦ããã±ã¼ã¸ã®è¿½å
ã§ã¯OpenWrtã§ã®è¨å®ãè¦ã¦ããã¾ããããã¾ãã¯å¿ è¦ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¾ãã
# opkg update # opkg install ipset kmod-ipt-ipset dnsmasq-full luci-app-mwan3
dnsmasqã¯æåããã¤ã³ã¹ãã¼ã«ããã¦ãããã®ã§ã¯æ©è½ä¸è¶³ã§ãfullçã«å·®ãæ¿ããå¿ è¦ãããã¾ãã
DNSæ£å¼ãã®ãã°åºå
ä»åã®ãããªå®é¨çãªåãçµã¿ãè¡ãå ´åãåä½ç¢ºèªããã©ãã«å¯¾å¿ã®ããã«DNSã¯ã¨ãªããã°ã«åºãã¦ããã¨ä¾¿å©ã§ãã
Web管çç»é¢ï¼LuCIï¼ãããNetworkããDHCP and DNSããGeneral SettingsããLog queriesãããã§ãã¯ããã¨ãã°ã«å
¨DNSã¯ã¨ãªããã°ã«æ®ãã¾ãããã°ã¯ logread
ã³ãã³ãã§ç¢ºèªã§ãã¾ãã
# logread ï¼ç¥ï¼ Mon Feb 22 10:09:02 2021 daemon.info dnsmasq[2794]: 173859 192.168.2.101/24828 query[A] android.googleapis.com from 192.168.2.101 Mon Feb 22 10:09:02 2021 daemon.info dnsmasq[2794]: 173859 192.168.2.101/24828 forwarded android.googleapis.com to 192.168.1.1 Mon Feb 22 10:09:02 2021 daemon.info dnsmasq[2794]: 173859 192.168.2.101/24828 reply android.googleapis.com is 172.217.24.138
IPsetã®ã»ããä½æã»åä½ç¢ºèª
IPsetã¨ã¯ãIPã¢ãã¬ã¹ããã®ä»ã®ãããã¯ã¼ã¯æ å ±ãé«éã«æ¤ç´¢ã§ããLinuxä¸ã®ãªã³ã¡ã¢ãªãã¼ã¿ãã¼ã¹ã§ããiptablesã¨çµã¿åããã¦ä½¿ãåæã®ä»çµã¿ã§ãiptablesã§å¤§éã®ã«ã¼ã«ãæ±ãã®ã«å©ç¨ããããä»åã®ããã«å¥ãã¼ã«ã¨çµã¿åããã¦ä½¿ã£ããã§ãã¾ãã
IPsetã§ã¯1ã¤ã®ãã¼ã¿ãã¼ã¹ãã»ããã¨ãã³ãã»ããã«å¯¾ãã¦IPã¢ãã¬ã¹ããããã¯ã¼ã¯ç¯å²ã追å ã»åé¤ãããã¨ãã§ãã¾ããä»åã¯force_usã¨ããã»ãããä½ãã¾ãã
# ipset create force_us hash:ip
次ã«ã/etc/config/dhcp
ãç´æ¥å¤æ´ãã¦ãç¹å®ãã¹ãåãDNSæ£å¼ãããã¨ãã®IPã¢ãã¬ã¹ãforce_usã»ããã«è¿½å ãããããã«ãã¾ãã
config dnsmasq ï¼ç¥ï¼ list ipset '/api.example.com/api2.example.com/force_us'
ãã®ããã«ãã¹ã©ãã·ã¥åºåãã§è¤æ°ã®ãã¹ãåãæå®ã§ãã¾ããã¾ãããã¹ãåã®å¾æ¹ä¸è´ã§ãã¡ã¤ã³åãæå®ãããã¨ãã§ãã¾ãã
æå¾ã« dnsmasq
ãåèµ·åãã¦åä½ç¢ºèªããã¾ããDNSæ£å¼ãããçµæãã»ããã«è¿½å ããã¦ããã°æåã§ãã
# kdig a api.example.com +short 192.0.2.32 # ipset list force_us Name: force_us Type: hash:ip Revision: 6 Header: family inet hashsize 1024 maxelem 65536 Size in memory: 368 References: 1 Number of entries: 1 Members: 192.0.2.32
mwan3ã®è¨å®
mwan3ã¯å¤åããã¼ããã©ã³ã·ã³ã°ç¨ã®OpenWrtç¬èªããã±ã¼ã¸ã§ãiptablesã®ã©ããã¼ã§ããä»åã®ããã«å¤åãã¤ã³ã¿ã¼ãã§ã¼ã¹ã使ãåãããã ãã®å ´åã«ã¯ãªã¼ãã¼ã¹ããã¯ã§ãããWeb管çç»é¢ããè¨å®ã§ãã¦æ¥½ãªã®ã§å©ç¨ãã¦ãã¾ãã
mwan3ã®è¨å®ã§ãå ã»ã©ä½ã£ãforce_usã»ããã«ãããããIPã¢ãã¬ã¹å®ã¦ãªãå¥ã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã使ãããè¨å®ãã¦ããã¾ãããã
ã¾ãWeb管çç»é¢ãNetworkããLoad BalancingããInterfacesãã®ãAddãããvpnusã¤ã³ã¿ã¼ãã§ã¼ã¹ï¼OpenVPNã§è¨å®ããVPNãã³ãã«ã¤ã³ã¿ã¼ãã§ã¼ã¹ï¼ãè¨å®ãã¾ããããã§æ¢åã¤ã³ã¿ã¼ãã§ã¼ã¹ãmwan3ã®ç®¡çä¸ã«ç½®ããã¦æ»æ´»ç£è¦ãè¡ãããããã«ãªãã¾ãã
次ã«ããNetworkããLoad BalancingããMembersãããvpnus_m1_w3ã¨ããã¡ã³ãã¼ã追å ãã¾ããããã§ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¨ãã¦å ã»ã©è¨å®ããvpnusã¤ã³ã¿ã¼ãã§ã¼ã¹ãæå®ãã¾ãã
ããã«ãNetworkããLoad BalancingããPoliciesãããvpnus_onlyããªã·ã¼ã追å ãã¾ããããã§å ã»ã©ã®vpnus_m1_w3ã¡ã³ãã¼ãæå®ãã¾ãã
æå¾ã«ãNetworkããLoad BalancingããRulesãã§force_us_v4ã¨ããã«ã¼ã«ãä½ãã¾ããIPsetã«ã¤ãã¦ã¯å ã»ã©ä½æãããforce_usããæå®ãããPolicy assignedãã¯å ã»ã©ä½æãããvpnus_onlyãããªã·ã¼ãæå®ãã¾ãã
以ä¸ã®è¨å®ã§ãç¹å®ãã¹ãå®ã®éä¿¡ãVPNçµç±ã«ãããã¨ãã§ãã¾ããã
ipsetã®ä¿å
ã«ã¼ã¿ãåèµ·åãã¦ãåãè¨å®ãç¶æãããããIPsetã®force_usã»ãããã«ã¼ã¿èµ·åæã«ä½ãããã«ãã¾ãã
/etc/config/firewall
ãç´æ¥å¤æ´ãã¾ãããã
config ipset option enabled '1' option name 'force_us' option storage 'hash' option family 'ipv4' option match 'dest_ip'
å¶éäºé
ä»åã®ä»çµã¿ãæå¾ éãåä½ããããã«ã¯ãéä¿¡ãè¡ãåã«DNSã®æ£å¼ããè¡ãããå¿ è¦ãããã¾ããéã«è¨ãã¨ãIPã¢ãã¬ã¹ã§ã¢ã¯ã»ã¹ãããããªãµã¼ãã¹ã§ã¯ä½¿ãã¾ãããã¹ããªã¼ãã³ã°ç³»ãµã¼ãã¹ã®ä¸ã«ã¯APIãµã¼ãããã¹ããªã¼ãã³ã°ãµã¼ãã®IPã¢ãã¬ã¹ãè¿ã£ã¦ãããããªãã®ãããã¾ãããããããå ´åã«ã¯é©ç¨ã§ãã¾ãããã¾ãã端æ«ãã«ã¼ã¿ã®DNSãå©ç¨ãã¦ããªããããªå ´åãç¡åã§ãã
ã¾ã¨ã
OpenWrtã«ã¼ã¿ä¸ã§dnsmasqã¨IPsetãé£æºããã¦ç¹å®ãã¡ã¤ã³ã»ç¹å®ãã¹ãå®ã®éä¿¡ã ããVPNçµç±ã«ãããã¨ãã§ãã¾ããã1ã¶æã»ã©ä½¿ã£ã¦ãã¾ãããä»ã®ã¨ããæå¾ éãã«åä½ãã¦ãã¾ãã
åèURL
- EdgeRouter X - 10. æµ·å¤ããè¦ãããªããµã¤ããè¦ãï¼ ( Domain Based Routing / Dnsmasq ) | yabe.jp EdgeRouterã§åå 容ãå®ç¾ãã¦ãããã®ãEdgeRouterã®æ¹ãç°¡åããã«è¦ããâ¦
- OpenWRT+mwan3ã§WANåç·ãåé·åãã - Qiita
- https://openwrt.org/docs/guide-user/firewall/fw3_configurations/fw3_config_ipset
go-shellwordsã§Unixã·ã§ã«çãªãã®ãå®è£ ãã
ç§ã¯Slackã®å ¥åããã¹ãã«å¯¾å¿ãã¦å¤é¨ã³ãã³ããèµ·åããbotãGoã§èªä½ãã¦ãã¾ãããã®botã«æè¿ã&&ããªã©Unixã·ã§ã«ã®æ¼ç®åãé¨åçã«å®è£ ããã®ã§ããããã®égo-shellwordsã便å©ã ã£ãã¨ãã話ãç´¹ä»ãã¾ãã
ç§ã®ä½ã£ã¦ããSlack botã®ç°¡åãªç´¹ä»
ç§ã®ä½ã£ã¦ããSlack botã¯å ¥åããã¹ãã®ãã¿ã¼ã³ããããè¡ã対å¿ããå¤é¨ã³ãã³ããå®è¡ãããããªãã®ã§ããå®è¡ä¾ãä¸è¨ã«ç¤ºãã¾ãã
ãã®ä¾ã§ã¯éè¡ãµã¤ãããæ å ±åå¾ããNode.jsã¹ã¯ãªãã2ã¤ï¼å£åº§æ¯æ¿ç §ä¼ãæ®é«ç §ä¼ï¼ãé£ç¶ã§å®è¡ãã¦éè¡å¼è½ã«å¿ è¦ãªæ®é«ããããã確èªãã¦ãã¾ãã
go-shellwordsã¨ã¯
go-shellwordsã¯mattnããä½ã®Goã©ã¤ãã©ãªã§ãã³ãã³ãã©ã¤ã³æååãåãåã£ã¦ã³ãã³ãå¼æ°ã®é åãè¿ããããªãã®ã§ãã
Goã®exec.Command()
ã¯ã³ãã³ãå¼æ°ã®é
åãåãåãä»æ§ãªã®ã§ãä»åã®Slack botã®ããã«å¼æ°ãå«ãã¦ã¼ã¶ã¼å
¥åãåãåã£ã¦ã³ãã³ããèµ·åããå ´åã¯å¼æ°ã®é
åã«åå²ããå¿
è¦ãããã¾ããåç´ãªã³ãã³ãããåãä»ããªãã®ã§ããã°string.Split()
ã§åå²ãã¦ãããã®ã§ãããUnixã·ã§ã«ã®ãããªã¯ã©ã¼ãã£ã³ã°ãã¨ã¹ã±ã¼ãã«å¯¾å¿ãããå ´åã¯go-shellwordsã使ãã¨ä¾¿å©ã§ãã
ã¾ããgo-shellwordsã¯Unixã·ã§ã«ã®ç¹æ®æåãåºç¾ããã¨parseãæ¢ãã¦ãããã®ã§ãã&&ãã«ããè¤æ°ã³ãã³ãå®è¡ã«ã対å¿ã§ãã¾ããç°¡æã³ã¼ãã§ãããç§ã¯æ¬¡ã®ãããªã³ã¼ããæ¸ãã¾ããã
for { // ã³ãã³ãã¨ã¿ãªããã¨ããã¾ã§parse args, err := parser.Parse(line) if parser.Position < 0 { // æååæ«å°¾ã¾ã§parseãã return } // ã³ãã³ãã®å®è¡ï¼ã¾ãã¯ç´åã®ã³ãã³ãå®è¡çµæã¨æ¼ç®å次第ã§ã¯å®è¡ããªãï¼ // parseã§ããªãã£ãã¨ããããæ¼ç®åãæ¢ã i := parser.Position token := line[i:] operators := []string{";", "&&", "||"} for _, op := range operators { if strings.HasPrefix(token, op) { // æ¼ç®åãä¿å i += len(op) break } } // ãããããæ¼ç®åã®å¾ããã次ã®ã«ã¼ãã§parseãã line = string(line[i:]) }
ã¨ã©ã¼å¦çãçãã¦ããã¨ã¯ãããããªãã·ã³ãã«ã«å®ç¾ã§ããã®ããããã¨æãã¾ãããã£ã¨ããä»åã¯ã&&ãã||ãã;ãã®3ã¤ãã対å¿ãã¦ããªãããã·ã³ãã«ã«æ¸ããå´é¢ãããã¾ãããªãã¤ã¬ã¯ããã«ãã³ã«å¯¾å¿ãããã¨æã£ããããå°ãçé¢ç®ã«å¦çãæ¸ãå¿ è¦ãããã§ãããã
ã¨ã©ã¼å¦çãå«ãå®éã®ã³ã¼ãã«èå³ãããå ´åã¯ç§ã®å®è£ ï¼executor.goï¼ãã覧ãã ããã
å®è£ ããæ¼ç®åãå·¦çµåã ãã§æ¸ãã¨æ¥½
ã&&ãã||ãã;ãã®3ã¤ã ãã§ãå®è£ 大å¤ãããªãï¼æ¨æ§é ä½ãå¿ è¦ããããï¼ã¨èãã人ãããããããã¾ãããç§ãããæã£ã¦ããã®ã§ãããUnixã·ã§ã«ã®å ´åã¯å¶ç¶ãéãªã£ã¦å é ããé次å¦çãã¦ããã ãã§å®ç¾ã§ãã¾ããã
確ãã«ãæ®éã®ããã°ã©ãã³ã°è¨èªã§ããã°æ¼ç®åã||ãããã&&ãã®åªå
度ãé«ãã®ã§ãä¾ãã° A || B && C
ã¨ããè«çæ¼ç®ã¯ A || (B && C)
ã¨è§£éããå¿
è¦ãããããããå®ç¾ããã«ã¯æ¨æ§é ãä½ãå¿
è¦ãããããã§ãã
ããããUnixã·ã§ã«ã§ã¯ã&&ãã¨ã||ãã®åªå 度ã¯åãã§ãï¼åèï¼Bash Reference Manual 3.2.4 Lists of Commandsï¼ãã;ãã ãã¯ããã¥ã¢ã«ä¸ã§åªå 度ãä½ãã®ã§ãããåãåªå 度ã¨èãã¦ãçç¾ã¯çããªãããã§ã1ã
å ¨é¨ã®æ¼ç®åãå·¦çµåã ã¨é ããã«ã¼ãã§å®è£ ã§ããã®ã§æ¥½ã§ãããã¨ããææããã¯ããã¯ã®ç´¹ä»ã§ããã
æ¬ç©ã®ã·ã§ã«ã使ããªãçç±
è足ãã¨ã¯æãã¾ãããUnixã·ã§ã«ã£ã½ããã¨ãå®ç¾ãããã¨ãã«æ¬ç©ã®Unixã·ã§ã«ã使ãã®ã¯ãªã¹ã¹ã¡ãã¾ããããã»ã©æ³¨æããªãã¨å¤é¨æååãå ã«ä»»æã³ãã³ããå®è¡ãããèå¼±æ§ï¼OSã³ãã³ãã¤ã³ã¸ã§ã¯ã·ã§ã³ï¼ãä½ãè¾¼ãã§ãã¾ãã¾ãã
ä»åã®å¦çãªãexec.Command("sh","-c",line)
ãªã©ã¨ããã°ã·ã§ã«ã®ã³ãã³ãã©ã¤ã³ã®ãã«æ©è½ãå©ç¨ã§ãã¾ãããline
ãã·ã§ã«ã«æ¸¡ãã¦å®å
¨ãªæååã§ãããã¨ãä¿è¨¼ããã®ã¯å°é£ã ã¨æãã¾ããéã®è¦æ¹ãããã°ãUnixã·ã§ã«çãªæ©è½ãå®ç¾ããã®ã«æ¬ç©ã®Unixã·ã§ã«ã使ããªãããããgo-shellwordsã便å©ãªããã§ãã
ã¾ã¨ã
- Unixã·ã§ã«ã£ã½ãæååå¦çãããã®ã«go-shellwordsã使ãã¨æ¥½ã ãå®å ¨
- ã·ã§ã«ã®æ¼ç®åã®ãã¡ã&&ãã||ãã;ãã ãå®ç¾ããã®ã¯æå¤ã¨æ¥½
-
A && B ; C && D
ãä¾ã«èããã¨ã(A && B) ; (C && D)
ã¨(A && B ; C) && D
ã¯ã©ã¡ããCãæåããã¨ãã ãDãå®è¡ããããã§ãããç価ã§ããä»ã®ä¾ãèãã¦ãå®å ¨ã«ç価ã ã¨æãã®ã§ãããæ°å¦çã«ç¤ºãããã¯ããã£ã¦ãã¾ãããæ°å¦ç帰ç´æ³ã®åºçªããªãâ¦ï¼↩