Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Goでつくる透過型SMTPプロキシ / Transparent SMTP proxy in Go
Search
linyows
June 10, 2021
Programming
1
970
Goでつくる透過型SMTPプロキシ / Transparent SMTP proxy in Go
Fukuoka.go #17 Jun 10, 2021 の発表資料です。
linyows
June 10, 2021
Tweet
Share
More Decks by linyows
See All by linyows
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
研究の再現性を高める 仕組みをGoでつくる / Creating a system to improve the reproducibility of research using go
linyows
1
120
奥が深いメールのシステム / The depth of Email system
linyows
3
420
IaCにおけるテスト考察 / Tests in IaC
linyows
2
440
リバースエンジニアリングとGoでSlackの認知負荷を下げる / Reducing cognitive load in Slack with Reverse-engineering and Go
linyows
2
280
透過型SMTPプロキシによる送信メールの可観測性向上 / Improved observability of outgoing emails with transparent smtp proxy
linyows
2
960
プロダクションで使うGo Pluginの利便性とパフォーマンス性 / Simplicity and Performance of Go plugin for Production
linyows
0
510
求められるソフトウェアエンジニア像とキャリア戦略 / Engineers and Career Strategies Required Now
linyows
2
480
CloudflareのCAPTCHAを使って ユーザ体験を下げず不正利用を排除する / Cloudflare's captcha case study that does not degrade ux
linyows
0
360
Other Decks in Programming
See All in Programming
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
200
受け取る人から提供する人になるということ
little_rubyist
0
230
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
最新TCAキャッチアップ
0si43
0
140
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
160
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Embracing the Ebb and Flow
colly
84
4.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Code Review Best Practice
trishagee
64
17k
Producing Creativity
orderedlist
PRO
341
39k
Music & Morning Musume
bryan
46
6.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Transcript
Fukuoka.go #17 Tomohisa Oda / Jun 10, 2021 Transparent SMTP
Proxy in Go GoͰͭ͘ΔಁաܕSMTPϓϩΩγ
Fukuoka.go #17 @linyows Blog: tomohisaoda.com Af fi liation: GMO pepabo,
inc. Fukuoka.go and Fukuoka.ts Organizer
Fukuoka.go #17 @linyows Blog: tomohisaoda.com Af fi liation: GMO pepabo,
inc. Fukuoka.go and Fukuoka.ts Organizer ࠷ۙɺNotionʹࣅإֆΛॻ͍ͯΒ͍·ͨ͠ɻ
Fukuoka.go #17 ๏ ϗεςΟϯάࣄۀ෦ Senior Engineering Lead ࣄۀ෦ͷCTOVPoEͷΑ͏ͳͷ ๏ ϖύϘݚڀॴ
भେֶڞಉݚڀ 2020 Պݚඅ࠾ https://kaken.nii.ac.jp/grant/KAKENHI-PROJECT-20K11791/ ܰྔίϯςφʹΑΔେنߴूੵϝʔϧϗεςΟϯάج൫ʹ͓͚Δૹ৴ػೳͷߴػೳԽ In Pepabo…
Fukuoka.go #17 Private Projects ΞϓϦέʔγϣϯ͕ࣗϦϙδτϦ͔ Β࠷৽ͷίʔυΛݕͯࣗ͠ಈͰσϓϩ ΠͱσϦόϦʔΛߦ͏πʔϧ linuxͷuser໊લղܾΛGitHubͷ TeamϝϯόʔϦϙδτϦͷΞΫηε ݖݶऀ͔Βߦ͏πʔϧ
ϝʔϧૹ৴༻ͷಁաܕSMTPϓϩΩγͰ ϦΫΤετͱϨεϙϯεΛϩάσʔλ ϕʔεʹग़ྗ͢Δ͜ͱ͕Ͱ͖Δ New!!
Fukuoka.go #17 ϝʔϧͷΈͱϝʔϧϗεςΟϯάͷ՝
Fukuoka.go #17 ✉ Architecture 💻 🖥 Mail Submission Agent :587
Mail Transfer Agent :25 Mail Delivery Agent :993 Postfix Postfix Dovecot ✉ ✉ SMTP SMTP LMTP IMAP 📱 📱 DNS MX TXT(SPF, DKIM, DMARC…)
Fukuoka.go #17 ✉ Architecture 💻 🖥 Mail Submission Agent :587
Mail Transfer Agent :25 Mail Delivery Agent :993 Postfix Postfix Dovecot ✉ ✉ SMTP SMTP LMTP IMAP 📱 📱
[email protected]
DNS MX TXT(SPF, DKIM, DMARC…)
[email protected]
Bob Alice ϝʔϧϗεςΟϯάʹ͓͍ͯ ϝʔϧΛ૬खઌʹ ౸ୡͤ͞Δ͜ͱ͕ॏཁ
Fukuoka.go #17 ϝʔϧͷ౸ୡੑʹӨڹΛ༩͑Δ̐ͭͷ͜ͱ via: https://sendgrid.kke.co.jp/blog/?p=4494 by Jillian Smith ๏ ϝʔϧΠϯϑϥͷ݈શੑʢωοτϫʔΫͱDNSʣ
๏ ϝʔϧͷίϯςϯπʢఴϑΝΠϧ, ຊจ, ϔομʔͳͲʣ ๏ ϝʔϧͷૹ৴ݩʢૹ৴ݩIP, υϝΠϯ, ૹ৴ྔͳͲʣ ๏ ड৴ଆαʔόͷՄ༻ੑ
Fukuoka.go #17 ๏ ϝʔϧΠϯϑϥͷ݈શੑʢωοτϫʔΫͱDNSʣ ๏ ϝʔϧͷίϯςϯπʢఴϑΝΠϧ, ຊจ, ϔομʔͳͲʣ ๏ ϝʔϧͷૹ৴ݩʢૹ৴ݩIP,
υϝΠϯ, ૹ৴ྔͳͲʣ ๏ ड৴ଆαʔόͷՄ༻ੑ ϝʔϧͷ౸ୡੑʹӨڹΛ༩͑Δ̐ͭͷ͜ͱ via: https://sendgrid.kke.co.jp/blog/?p=4494 by Jillian Smith %/4#-ʹొ͞ΕΔͳͲ ϨϐϡςʔγϣϯʢධʣʹӨڹ͢Δ
Fukuoka.go #17 ๏ ༷ʑͳϢʔβ͕͏ϚϧνςφϯτͰ͋ΔͨΊɺϝʔϧΛৗతʹͨ͘͞Μૹ৴͢ ΔΞΧϯτ͋Εɺීஈগͳ͍͕ͨ·ʹେྔૹ৴͢ΔΞΧϯτ͋Δ ๏ ͦͦΞΧϯτΛͬऔΒΕΔέʔε͋Δ ๏ ड৴ऀ͕ͳͥड͚औΓڋ൱Λͨ͠ͷ͔͕͔Γʹ͍͘ʢDMARCରԠ͕͋Εผʣ ๏
ϝʔϧํͷΓͱΓͳͷͰɺૹ৴ଆ͕εύϜߦҝͱࢥ͍ͬͯͳͯ͘ड৴ऀ͕ εύϜߦҝͩͱײ͡Δ͜ͱ͋Γ͏Δ ϝʔϧϗεςΟϯάʹ͓͚Δ՝
Fukuoka.go #17 ๏ ༷ʑͳϢʔβ͕͏ϚϧνςφϯτͰ͋ΔͨΊɺϝʔϧΛৗతʹͨ͘͞Μૹ৴͢ ΔΞΧϯτ͋Εɺීஈগͳ͍͕ͨ·ʹେྔૹ৴͢ΔΞΧϯτ͋Δ ๏ ͦͦΞΧϯτΛͬऔΒΕΔέʔε͋Δ ๏ ड৴ऀ͕ͳͥड͚औΓڋ൱Λͨ͠ͷ͔͕͔Γʹ͍͘ʢDMARCରԠ͕͋Εผʣ ๏
ϝʔϧํͷΓͱΓͳͷͰɺૹ৴ଆ͕εύϜߦҝͱࢥ͍ͬͯͳͯ͘ड৴ऀ͕ εύϜߦҝͩͱײ͡Δ͜ͱ͋Γ͏Δ ϝʔϧϗεςΟϯάʹ͓͚Δ՝ ϝʔϧૹ৴࣌ͷͲΜͳৼΔ͍͕ड৴ڋ൱ʹࢸ͔ͬͨʁ ੳ͠ݕͰ͖ΔΑ͏ʹ͍ͨ͠ʂ
Fukuoka.go #17 ✉ Architecture 💻 🖥 Mail Submission Agent :587
Mail Transfer Agent :25 Mail Delivery Agent :993 Postfix Postfix Dovecot ✉ ✉ SMTP SMTP LMTP IMAP 📱 📱
[email protected]
DNS MX TXT(SPF, DKIM, DMARC…)
[email protected]
Bob Alice ͜ͷΓͱΓΛੳͰ͖Δɺ͔ͭ ΛݕͰ͖Ε ૹ৴ΛϒϩοΫͰ͖ΔΈ͕ඞཁ
Fukuoka.go #17 ࣮ݱํ๏ͷൺֱ
Fukuoka.go #17 ϝʔϧϦϨʔ vs. ಁաܕϓϩΩγ Mail Transfer Agent :25 Mail
Transfer Agent :25 Postfix Postfix
[email protected]
Transparent Proxy :25 Mail Transfer Agent :25 ? Postfix
[email protected]
Mail Submission Agent :587 Postfix
[email protected]
Mail Submission Agent :587 Postfix
[email protected]
✉ ✉ ✉ ✉ ϝʔϧϦϨʔΛߦ͏ͱϗοϓ͕૿͑ ϝʔϧΩϡʔͷཧ͕ෳࡶʹͳΔ 4.51ड͚ྲྀ͢ಁաܕϓϩΩγͩͱ ϝʔϧΩϡʔཧ͕ݱߦͱมΘΒͣ γϯϓϧͰ͋Δɻ͔͠͠ɺͦͷΑ͏ ͳϛυϧΣΞ͕ݟͨΒͳ͍ɻ
Fukuoka.go #17 ϝʔϧϦϨʔ vs. ಁաܕϓϩΩγ Mail Transfer Agent :25 Mail
Transfer Agent :25 Postfix Postfix
[email protected]
Transparent Proxy :25 Mail Transfer Agent :25 ? Postfix
[email protected]
Mail Submission Agent :587 Postfix
[email protected]
Mail Submission Agent :587 Postfix
[email protected]
✉ ✉ ✉ ✉ ϝʔϧϦϨʔΛߦ͏ͱϗοϓ͕૿͑ ϝʔϧΩϡʔͷཧ͕ෳࡶʹͳΔ 4.51ड͚ྲྀ͢ಁաܕϓϩΩγͩͱ ϝʔϧΩϡʔཧ͕ݱߦͱมΘΒͣ γϯϓϧͰ͋Δɻ͔͠͠ɺͦͷΑ͏ ͳϛυϧΣΞ͕ݟͨΒͳ͍ɻ
Fukuoka.go #17 GoͰͭ͘ΔಁաܕSMTPϓϩΩγ
Fukuoka.go #17 Ͳ͏ͬͯಁաܕϓϩΩγΛ࣮ݱ͢Δ͔ ๏ Port25൪ѼΛDNATͰશͯProxyʹૹΔ ๏ getsockopt(2)ͰѼઌมߋલͷΞυϨεΛऔಘ͢Δ
Fukuoka.go #17 SMTP Example via: https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol 4.5104*-ͷͱͯγϯϓϧͳϓϩτίϧ
Fukuoka.go #17 Goͷio.CopyΛָ͑উͳΜ͡Όͳ͍ʁ
Fukuoka.go #17 Transparent Proxy Go Mail Transfer Agent Postfix
[email protected]
Mail Submission Agent Postfix
[email protected]
io.Copy(internalConn, externalConn) io.Copy(externalConn, internalConn)
Fukuoka.go #17 PoC ී௨ʹϝʔϧΛૹड৴Ͱ͖ͨͷͰશʹ͏·͍ͬ͘ ͨͱࢥͬͨɻ ͔͠͠ɺHPSPVUJOFͷมΛग़ྗͯ͠ΈΔͱɺ ్த͔Βจࣈ͕ಡΊͳ͍ײ͡ʹ
Fukuoka.go #17 STARTTLSͷ͜ͱΛΕ͍ͯͨ!!!
Fukuoka.go #17 μϯάϨʔυ߈ܸରԠʹ͢Δ
Fukuoka.go #17 ୯ʹJP$PQZͰͳ͘ 5-4ίωΫγϣϯ·Ͱ ੍ޚ͢Δඞཁ͕͋ͬͨ
Fukuoka.go #17 45"355-4ʹରԠͯ͠ͳ͍ Ϩεϙϯεʹ͢Δ
Fukuoka.go #17 όοϑΝϦϯάͨ͠σʔλΛ5-4 ίωΫγϣϯͱͦͷޙͷఆܕΓ औΓޙʹૹ৴͢Δ
Fukuoka.go #17 Demo: ࣌ؒͳ͍͔
Fukuoka.go #17 ๏ Integration Testͷख๏Λߟ͑ΔʢPostfix ґଘΛͲ͏͖͔͢ʣ ๏ ऩूͨ͠ใΛDatabaseʹੵͱੳ ๏ IptablesґଘϧʔςΟϯάΛBPF/XDPΛ
͏Α͏ʹ͢Δ ๏ ProductionΧφϦΞϦϦʔε ࠓޙͷܭը — github.com/linyows/warp
Fukuoka.go #17 ๏ ϝʔϧͷ౸ୡੑʹؔΘΔ̐ͭͷ߲͕͋Δ ๏ ϝʔϧϗεςΟϯάʹ͓͚Δ՝ड৴ڋ൱ͷཧ༝͕Θ͔Βͳ͍͜ͱ ๏ ϝʔϧૹ৴࣌ͷΞΧϯτ͝ͱͷৼΔ͍ͱड৴ڋ൱ͷؔΛݟ͚ͭΔͨΊͷಁաܕϓϩ Ωγ ๏
ಁաܕϓϩΩγʹ͢ΔʹDNATͱgetsockoptΛͬͨ ๏ SMTPͷಁաܕϓϩΩγͷ࣮io.Copy͢Δ͚ͩͰμϝͰμϯάϨʔυ߈ܸΛରԠ ͢Δඞཁ͕͋Γ࣮͕গ͠ෳࡶ Conclusion
Fukuoka.go #17 Thank you \ʕ⊙౪⚆ʔ/