$30 off During Our Annual Pro Sale. View Details »
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
980
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 プロキシの定量評価 / Quantitative Evaluation of Transparent SMTP Proxy in Email Sending Server Aggregation
linyows
0
45
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
250
研究の再現性を高める 仕組みをGoでつくる / Creating a system to improve the reproducibility of research using go
linyows
1
130
奥が深いメールのシステム / The depth of Email system
linyows
4
440
IaCにおけるテスト考察 / Tests in IaC
linyows
2
460
リバースエンジニアリングとGoでSlackの認知負荷を下げる / Reducing cognitive load in Slack with Reverse-engineering and Go
linyows
2
290
透過型SMTPプロキシによる送信メールの可観測性向上 / Improved observability of outgoing emails with transparent smtp proxy
linyows
2
990
プロダクションで使うGo Pluginの利便性とパフォーマンス性 / Simplicity and Performance of Go plugin for Production
linyows
0
530
求められるソフトウェアエンジニア像とキャリア戦略 / Engineers and Career Strategies Required Now
linyows
2
490
Other Decks in Programming
See All in Programming
eBPF Deep Dive: Architecture and Safety Mechanisms
takehaya
12
1.2k
Gestaltung digitaler Lösungen – Produktions- oder Designprozess?
techstories
0
120
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
110
layerx_20241129.pdf
kyoheig3
2
240
Leveling Up Developer Tooling for the Modern Rails & Hotwire Era @ Ruby Türkiye, November 2024
marcoroth
0
160
かんたんデザイン編集やってみた~「完全に理解した」までの道のり~
morit4ryo
1
110
WebAssembly Unleashed: Powering Server-Side Applications
chrisft25
0
2.1k
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
350
カンファレンスでLTしました / kashiwarb5
nhayato
0
100
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
0
240
MoQとか勉強会#2 発表資料
yuki_uchida
2
130
Criando Commits Incríveis no Git
marcelgsantos
1
120
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
693
190k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Done Done
chrislema
181
16k
Being A Developer After 40
akosma
87
590k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
How to Think Like a Performance Engineer
csswizardry
21
1.2k
Designing the Hi-DPI Web
ddemaree
280
34k
Typedesign – Prime Four
hannesfritz
40
2.4k
Into the Great Unknown - MozCon
thekraken
33
1.5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
A Tale of Four Properties
chriscoyier
157
23k
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 \ʕ⊙౪⚆ʔ/