我編譯故我在:誰說 Node.js 程式不能編成 binary
-
Upload
fred-chien -
Category
Technology
-
view
10.102 -
download
7
Transcript of 我編譯故我在:誰說 Node.js 程式不能編成 binary
我編譯故我在
誰說 Node.js 程式不能編成 Binary
Fred Chien
錢逢祥
Fred Chien
Mandice
cfsghost At gmail.com
fred-zone.blogspot.com
StemWonderful JavaScript OS
stem.mandice.org
"You do Everything." customer said.
客戶一向說我是萬能的
But
但
Hard to get paid for Everything
從他們口袋裡多拿錢
卻萬萬不能
One day
某天
More requests are coming
客戶又要追加一堆免錢功能
Fucx
很 X
Do It
於是我決定
At night
做完那天晚上
Be Strong
硬起來
Only 72 hours for getting paid
給自己 72 小時通諜的勇氣
Damn It !
但是
The Next Day
第二天
Customer goes abroad
客戶就出國去了
And Ignore me
直接忽略了我的請款
oops
!@#$%^&*
Assert ourself
悍衛主權啦!
So
於是
Do some hacks
我把軍艦開到他家
Hide everything
把程式碼都藏起來
The Next Morning
第二天早上
Customers surrendered themself
客戶立馬從國外
打電話回來說要付錢
Customers surrendered themself
還派他的特使小姐
來收我的發票
in 72 hours
72 小時的成果
Node.js Packaging Utility
NPK
Node.js 程式碼封裝工具
NPK
https://github.com/cfsghost/npk
npk at Github
npm install npk -g
Install via NPM
Obfuscation
面目全非
Compress and Minify
壓縮
Bundle all in single file
封裝成單一檔案
Compile it to binary file
編譯成二進位檔
The point is
最酷的是
Supported 3 levels
NPK 支援三種封裝等級
Remove mock-up
卸了妝 認不得
Your Mom doesn't recognize
媽媽不認得
Your Dad doesn't recognize as well
爸爸也不認得
So
所以
It make sense
這樣的設計應該很合理
$ npk . --remove-mockup
$ npk . --mom-doesnt-recognize
$ npk . --dad-doesnt-recognize
Trying to explain these levels
簡單來說
縮排脫掉,變數脫掉,空白脫掉,通通脫掉
卸了妝
加密壓縮程式碼
媽都不認得
用 Compiler 編譯成 Binary
爸也不認得
Workflow
js filejs file
js file
js file
Generate Symbol Table and Object files
Link all to generate final package file
Package your Node.js code
打包你的 Node.js 程式
Modify package.json for NPK
修改 package.json
{"name": "example-project","desciption": "Example program","version": "0.0.1","npk_target": {
"app.js": {"sources": [
"app.js","lib/a.js","lib/b.js"
]}
}}
Modifying package.json
Pack Now!
開始打包!
npk /home/fred/myproject
npk [project path]
可以配合服用爸媽不認得參數
你將會得到
out/app.js/app.js
Where is the thing dad doesn't recognize?
爸不認得的Code在哪?
out/app.js/build/Release/npk.node
:-)
Live Demo
You might ask what ...
你可能最想問的是
Is it reliable to protect our code?
NPK 真的靠的住嗎?
Absolutely No
靠不住
Gentleman should not steal code
防君子
Customer should pay for code
防客戶
Somebody is evil
但是最怕
Source code is still there
失傳的還我漂漂拳
What's Next?
Encryption, LLVM... etc
歡迎命名投搞
也許有下一個封裝等級?
Welcome to punch my face
打臉時間
Advertisement
最後宣傳一下
StemWonderful JavaScript OS
stem.mandice.org
需要 JS 開發者的幫忙!Wanted You
JavaScript 硬起來!
歡迎跟我聯繫或交換名片 :-)
cfsghost At gmail.com
Thanks