#LeapMotion でKeynoteスライドショーしてみましたよ

話題のLeapMotionが届いたのでさっそくKeynoteのスライドショーを制御してみました!

会社のカフェを借りて動画を撮ったので、まずはそちらを見ていただくと何ができるかすぐ分かっていただけると思います!


#LeapMotion Keynote slideshow using Leap Motion ...

とりあえず今回はKeynoteスライドショーの制御なんですが、調理や作業で手が汚れているときにページをめくったりと色々実用的な使い方もできそうです。 あ、スライドは以前勉強会で使ったやつなんですが、手元にあるなかで一番問題なさそうだっただけでとくに意味ないです。

LeapMotionってなに?

という方もおられると思うので簡単に説明を。

一言でいうと「空中の手と指を検出するデバイス」でしょうか。 FRISKサイズのコントローラをPCにUSBでつないで上の"空間"で手を動かすと検出してくれます。

f:id:mazgi:20130728221431j:plain

例えば右手ならこんな感じです。

f:id:mazgi:20141203073834p:plain

対応OSは、Mac OS X 10.6以上、Windows 7以上、"alpha-quality"ながらLinuxにも対応するようです。 開発者登録するとダウンロードできるSDKを使って↓の各種言語でアプリを実装できます。

  • C++
  • Objective-C
  • C#(Unity含)
  • Java
  • Python
  • JavaScript

Twitterみてると続々とLeapMotionユーザーの方増えてるようですし、ハッカソンやってみたいですねq^

#YuruUni ゆるめの #Unity 勉強会が開催されましたよー!

昨日7/9、Unityエバンジェリストの伊藤周(いとう まこと)さんをお招きして株式会社ドリコムで「ゆるゆに - ゆる系Unity入門会」というイベントを開催しました!

メインセッション

「Unityといえばゲーム」な印象が強いと思うのですが、伊藤さんによるメインセッションでは、Unityの3Dゲームエンジンとしての特長がゲーム以外で活かされてる実例をいろいろと紹介していただきました。

f:id:mazgi:20130709192917j:plain

例えば、消防などの危険で即時の判断が求められるうえに失敗が許されない職業の訓練にUnityによる3Dシミュレーションが取り入れられているそうです。

じつは以前伊藤さんの講演を聴いた際に、この「ゲーム以外でのUnityによるゲームシステムの活用」のお話にとても感銘を受けたことが今回のイベント開催の動機の1つだったりします。

メインセッション後半では、Unity Asset Storeで提供されているカーレースゲームとクマのモデルをベースに、その場でゲームを作るというライブデモンストレーションを見せてくださいました。 Asset Storeの存在ってほんと大きいですね(もちろん伊藤さんの技術あってのライブデモですが)。

ちなみにデモしてくださったゲーム自体はじつに牧歌的でした(個人の感想であり、ゲームの仕様を客観的に伝えるものではありません)。

懇親会

1時間のメインセッションを楽しんだあとは場所を社内カフェに移し、軽くお酒を飲みながらの懇親会を行いました。 Oculus Riftの話題で盛り上がり、なんと弊社の新人エンジニア氏が懇親会中にOculus Riftを買ったようです。

f:id:mazgi:20130709210522j:plain

今回は初回ということもありUnityを知らない方でも楽しめる内容で講演していただいたのですが、次回が開催できたら実際に手を動かしてUnityでゲームを作る場になったらなーと思っております!

最後になりましたが、Unityのすばらしいお話を楽しく講演してくださったエバンジェリストの伊藤さん、本当にありがとうございました!

資料など

Ustはこちらで配信してました。

Video streaming by Ustream

Togetterなどまとめてみましたのでご覧くださいー。

enchantMOON Nightに行ってきました!

昨日4/23、五反田のゲンロンカフェenchantMOONのtouch and tryイベント「enchantMOON Night」が開催されたので行ってきました。

enchantMOONといえば「手書きにこだわったUI」「プログラミング可能」などなど話題になっていました…が、私は

  • 安倍吉俊さんが本体をデザイン
  • PVがかっこいい

というなんともミーハーな理由で触りに行ってしまいました!

いざ会場へ

会場の1Fに着くと、アラン・ケイ氏の"People who are really serious about software should make their own hardware.(ソフトウェアに本当に真剣な人は独自のハードウェアを作るべき)"という言葉が迎えてくれました。 enchantMOONにピッタリですね!

f:id:mazgi:20130423205002j:plain

開始時刻前に着いたのですが、エレベーターの前には10名前後の方が並んでいました。 エレベーターを1回待ち中に入るとすでに超満員で熱気が! #enchantMOON Night来た。超満員!

清水亮氏のプレゼン

「enchantMOON Night」は開発元であるユビキタスエンターテインメント(UEI)CEOの清水亮氏のプレゼンではじまりました。

お話を聴きながら色々なことを考えたのですが、とくに「"手書きへのこだわり"というのは、書き心地や書き味を超えて"手書きという思考プロセス"への強いこだわりなんだな」ということを強く感じました。

「紙に書き、紙を見て理解する」のは「思考の動脈と静脈」なのでとても大事なのだけど「紙は共有に弱い」という欠点もある。一方iPadやiPhoneは情報を受けるには素晴らしいデバイスだが、情報を生み出すには無理があると感じる。だったら「紙自身がコンピュータになればいい」というお話をされていて、自分の中でなんとなく感じていて明文化できていなかった気持ちを明確な言葉として聴けた気がしました。

とても刺激を受けたので機会があったら思ったことをもうちょっと書きたいです。

touch and try!

プレゼンのあとは念願のenchantMOONおさわりタイムだったのですが、本当に大盛況で第一陣だけでもすごい人数でした。 話に聞くところでは会場の外まで長蛇の列だったようです。

f:id:mazgi:20130423203852j:plain

首を長くして(ワイン片手に)待ち続けること30分くらいでしょうか?やっと待望のenchantMOONに触れることができました!

触れる時間は一人1分。 その他制約としては、今回は電波法的な理由でまだWi-Fiが接続できないためオフラインでの操作となりました。

せっかくなのでiPhoneで動画を撮ってみました。


enchantMOON touch and try - YouTube

お約束ですが、ペンで"MOON"と文字を書いて指で囲ってみました。じつはユーザー登録画面で"lain"と書く気まんまんで行ったのですがそんな時間はありませんでした、残念。。 1分じゃなくてもうちょっと触ってみたかったですね(笑)仕方ないですが。

動画が縦なのと、撮影に夢中で本体を持ち上げてみるのを忘れたのはとても反省しています。

おまけ

カフェの壁には、いかにもという端末がディスプレイされPVがエンドレス再生されていてとても素敵でした♪


enchantMOON Night Wall Display - YouTube

こちらは清水CEOおすすめのCALERAのワイン。 enchantMOONを触るまでの待ち時間でいただいてきました。 #enchantMOON 実機おさわり順番待ちのカレラ

会場となったゲンロンカフェは電源とWi-Fiを使わせていただけるそうで、会社から近いしぜひまた伺いたいです♪

f:id:mazgi:20130423185243j:plain

ビルの1Fに貼ってあるこの看板(?)が目印です。

f:id:mazgi:20130423205008j:plain

社内Jenkins勉強会でLTしました

私が勤めている株式会社ドリコムではよく社内勉強会が発生するのですが、今回は sue445の「やりましょう!」という呼びかけでJenkins勉強会が開催されました。 チラっとお呼ばれしてLTさせてもらいましたので資料を公開します。

ドリコム社内勉強会LT資料

「RubyならRDoc, JavaならJavadocを使えばいいのですが、(私が今開発している)C/C++/Objective-CだったらDoxygen使えるよ!」という内容です。

Jenkins氏、とても器用なのでRubyコードのCIや今回のドキュメンテーションに限らずもっと活用していきたいですね。 以外にもSIerドキュメントがウケて、ひさびさにExcelを起動した甲斐がありました(笑)

あと社内にsue445みたいなJenkinsブン回してる人が居てすぐ質問できるってのは幸せだなーと改めて思いました。

なおドリコムではエンジニアを募集中とのことですので「CIならまかせろー」という方やC/C++/Objective-Cのコードにマサカリ投げたい方はぜひよしてつ侍さんまでお声がけください!(で、いいんですよね?)

conferenceWithDevelopers( #confwd )のLT資料とソースコード

年始から(また)Objective-Cを書いてるのですが、昨日(2013/2/23)、六本木ヒルズのGREEさんで行われたiOS開発者向けのカンファレンスに行ってきました。

conferenceWithDevelopers公式サイト Togetter

じつは10:00〜20:00という時間の長さに少しビビりながらの参加だったのですが、セッションがどれも素晴らしくて本当に行ってよかったです! 私もLTをさせていただきましたので資料を公開します。

LT資料

LTのタイトルは、カンファレンスの名前がObjective-Cのメソッドっぽかったのでもじってます。 内容は、UIWindowのサブクラスをアプリのkeyWindowにしてメモリ使用量やらコンソールログっぽいものやら表示できると実機デバッグしてるときになんかあってもスクショ撮れば最低限の情報残せるしなにかと便利だよね!と思って作ってみたお話です。

ソースはGitHubに置いてますのでなにかの参考になればうれしいです。 「ライセンス明記してないソースって使いづらいよね…」ってどこかから聞こえた気がしたのであわててMITライセンスの条文追加しました><

preziで不安もありましたが好評いただけたようでうれしかったです♪

あと、憧れのあきすてさんにTimer周りのコードを褒められたので帰り道ずっとニヤニヤしてました///

登壇された方々、運営してくださったスタッフの方々、参加者の皆様、そして会場と食事を用意してくださったGREE様、本当にありがとうございました。

さくらVPSにEthernet BridgingなOpenVPNをインストールしてみました

さくらVPS上のGentoo LinuxをOpenVPNサーバーに仕立ててみました。 出先から自宅のPCに接続したいという動機でVPNを構築したのですが、どうにか使えるようになったので記録を残しておきます。

構成

まず今回構築するVPNの構成です。

f:id:mazgi:20141210070213p:plain

※画像素材をYAMAHA株式会社よりお借りしています。 さくらVPS上にOpenVPNサーバーを立て、自宅ネットワーク上のホストに出先のノートPCから接続できるようにします。 また、OpenVPNをEthernet Bridgeモードで構築し、出先のノートPCと自宅ネットワークのホストは互いにBonjourAvahiで名前解決できるようにします。

ホストは以下の3台とします。

Bowmore
さくらVPS, OpenVPNサーバー
Caolila
MacBook Air, OpenVPNクライアント, 出先から接続
PortEllen
VirtualBoxゲスト, OpenVPNクライアント, 自宅ネットワーク上

個人向けVPSサービスでTAPドライバを使ってEthernet BridgeモードでOpenVPSサーバーをセットアップする場合、NICがグローバル接続用のもの1つしかなく、bridgeにこの唯一のNICを組み入れてしまうとグローバル接続ができなくなってしまうという問題があります。 しかしこの問題はLinuxカーネルに含まれるDummy net driverを使うことで対処できます。

今回はGentoo LinuxをOpenVPNサーバーにしましたが、パッケージ管理システムとカーネルモジュールに関する部分を読み替えていただければCentOSやDebian GNU/Linuxでも同じ要領でセットアップできると思います。

OpenVPNのセットアップ

まずOpenVPN自体をセットアップします。

OpenVPNパッケージインストール

PortageでOpenVPNパッケージをインストールします。 USEフラグ(configureオプション)はこんな感じです。

[root@Bowmore] # emerge -pv openvpn
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild   R    ] net-misc/openvpn-2.2.2  USE="examples pam ssl -iproute2 -minimal -passwordsave -pkcs11 (-selinux) -static" 0 kB
Total: 1 package (1 reinstall), Size of downloads: 0 kB

認証局の設定

OpenVPNを使うためにはCA(認証局)が必要となりますが、今回はOpenVPNパッケージに含まれているeasy-rsaという簡易CAツールを使います。 CA, OpenVPNサーバー, OpenVPNクライアントにそれぞれ証明書が必要ですが、すべてOpenVPNサーバーとなるホスト上で作ることにします。

Gentoo Linuxの場合、easy-rsaは/usr/share/openvpn/easy-rsaにインストールされます。 varsという環境変数を設定するためのファイルがありますので、証明書を作成する前にKEY_ではじまる値を編集します。

[root@Bowmore] # grep -E '^\s*[^#;]' /usr/share/openvpn/easy-rsa/vars
export EASY_RSA="`pwd`"
export OPENSSL="openssl"
export PKCS11TOOL="pkcs11-tool"
export GREP="grep"
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`
export KEY_DIR="$EASY_RSA/keys"
echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR
export PKCS11_MODULE_PATH="dummy"
export PKCS11_PIN="dummy"
export KEY_SIZE=1024
export CA_EXPIRE=3650
export KEY_EXPIRE=3650
export KEY_COUNTRY="JP"
export KEY_PROVINCE="Tokyo"
export KEY_CITY="Suginami"
export KEY_ORG="BooMTown"
export KEY_EMAIL="openvpn@example.com"
export KEY_CN="ca.openvpn.example.com"
export KEY_NAME="Jhon Doe"
export KEY_OU="personal"
export PKCS11_MODULE_PATH=changeme
export PKCS11_PIN=1234

CA証明書の作成

build-caスクリプトを実行してCAの秘密鍵と証明書を作ります。

[root@Bowmore] # cd /usr/share/openvpn/easy-rsa
[root@Bowmore] # . ./vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/share/openvpn/easy-rsa/keys
[root@Bowmore] # ./clean-all
[root@Bowmore] # ./build-ca
Generating a 1024 bit RSA private key
............++++++
writing new private key to 'ca.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [JP]:
State or Province Name (full name) [Tokyo]:
Locality Name (eg, city) [Suginami]:
Organization Name (eg, company) [BooMTown]:
Organizational Unit Name (eg, section) [personal]:
Common Name (eg, your name or your server's hostname) [ca.openvpn.example.com]:
Name [Jhon Doe]:
Email Address [openvpn@example.com]:

2つのファイルが作られます。

  • ca.key : CAの秘密鍵
  • ca.crt : CAの証明書
[root@Bowmore] # ls -l /usr/share/openvpn/easy-rsa/keys/ca.(key|crt)
-rw-r--r-- 1 root root 1440  /usr/share/openvpn/easy-rsa/keys/ca.crt
-rw------- 1 root root  916  /usr/share/openvpn/easy-rsa/keys/ca.key

サーバー証明書の作成

build-key-serverスクリプトを実行して、OpenVPNサーバーの秘密鍵と証明書を作ります。

[root@Bowmore] # cd /usr/share/openvpn/easy-rsa && . ./vars && ./build-key-server bowmore
NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/share/openvpn/easy-rsa/keys
Generating a 1024 bit RSA private key
.............++++++
writing new private key to 'bowmore.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [JP]:
State or Province Name (full name) [Tokyo]:
Locality Name (eg, city) [Suginami]:
Organization Name (eg, company) [BooMTown]:
Organizational Unit Name (eg, section) [personal]:
Common Name (eg, your name or your server's hostname) [bowmore]:
Name [Jhon Doe]:
Email Address [openvpn@example.com]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /usr/share/openvpn/easy-rsa/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'JP'
stateOrProvinceName :PRINTABLE:'Tokyo'
localityName :PRINTABLE:'Suginami'
organizationName :PRINTABLE:'BooMTown'
organizationalUnitName:PRINTABLE:'personal'
commonName :PRINTABLE:'bowmore'
name :PRINTABLE:'Jhon Doe'
emailAddress :IA5STRING:'openvpn@example.com'
Certificate is to be certified until Nov 23 11:15:12 2022 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

3つのファイルが作られます。

  • ${サーバー名}.key : サーバーの秘密鍵
  • ${サーバー名}.csr : サーバーからCAへの証明書署名要求
  • ${サーバー名}.crt : サーバーの証明書
[root@Bowmore] # ls -l /usr/share/openvpn/easy-rsa/keys/bowmore.(crt|csr|key)
-rw-r--r-- 1 root root 4188  /usr/share/openvpn/easy-rsa/keys/bowmore.crt
-rw-r--r-- 1 root root  733  /usr/share/openvpn/easy-rsa/keys/bowmore.csr
-rw------- 1 root root  912  /usr/share/openvpn/easy-rsa/keys/bowmore.key

クライアント証明書の作成

build-keyスクリプトを実行してクライアントの秘密鍵と証明書を作ります。

[root@Bowmore] # cd /usr/share/openvpn/easy-rsa && . ./vars && ./build-key PortEllen
NOTE: If you run ./clean-all, I will be doing a rm -rf on /usr/share/openvpn/easy-rsa/keys
Generating a 1024 bit RSA private key
...............++++++
writing new private key to 'PortEllen.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [JP]:
State or Province Name (full name) [Tokyo]:
Locality Name (eg, city) [Suginami]:
Organization Name (eg, company) [BooMTown]:
Organizational Unit Name (eg, section) [personal]:
Common Name (eg, your name or your server's hostname) [PortEllen]:
Name [Jhon Doe]:
Email Address [openvpn@example.com]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /usr/share/openvpn/easy-rsa/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'JP'
stateOrProvinceName   :PRINTABLE:'Tokyo'
localityName          :PRINTABLE:'Suginami'
organizationName      :PRINTABLE:'BooMTown'
organizationalUnitName:PRINTABLE:'personal'
commonName            :PRINTABLE:'PortEllen'
name                  :PRINTABLE:'Jhon Doe'
emailAddress          :IA5STRING:'openvpn@example.com'
Certificate is to be certified until Dec  2 05:21:17 2022 GMT (3650 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

各クライアント毎に3つずつファイルが作られます。

  • ${クライアント名}.key : クライアントの秘密鍵
  • ${クライアント名}.csr : クライアントからCAへの証明書署名要求
  • ${クライアント名}.crt : クライアントの証明書
[root@Bowmore] # ls -l /usr/share/openvpn/easy-rsa/keys/(PortEllen|Caolila).(crt|csr|key)
-rw-r--r-- 1 root root 4066  /usr/share/openvpn/easy-rsa/keys/Caolila.crt
-rw-r--r-- 1 root root  733  /usr/share/openvpn/easy-rsa/keys/Caolila.csr
-rw------- 1 root root  916  /usr/share/openvpn/easy-rsa/keys/Caolila.key
-rw-r--r-- 1 root root 4072  /usr/share/openvpn/easy-rsa/keys/PortEllen.crt
-rw-r--r-- 1 root root  737  /usr/share/openvpn/easy-rsa/keys/PortEllen.csr
-rw------- 1 root root  916  /usr/share/openvpn/easy-rsa/keys/PortEllen.key

build-dhスクリプトを実行して、Diffie-Hellman鍵交換用のパラメータを生成します。

[root@Bowmore] # ./build-dh
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
.......................+.......+........
[root@Bowmore] # ls -l /usr/share/openvpn/easy-rsa/keys/dh1024.pem
-rw-r--r-- 1 root root 245  /usr/share/openvpn/easy-rsa/keys/dh1024.pem

サーバー側設定ファイルの編集

/usr/share/openvpn/easy-rsa/keys/から/etc/openvpn/に以下のファイルをコピーします。

  • ca.crt : CAの証明書
  • ${サーバー名}.key : サーバーの秘密鍵
  • ${サーバー名}.crt : サーバーの証明書

OpenVPNサーバーの設定ファイルを/etc/openvpn/server.confという名前作ります。 内容は以下の通りです。

[root@Bowmore] # grep -E '^\s*[^#;]' /etc/openvpn/server.conf
port 1194
proto udp
dev tap
ca ca.crt
cert server.crt
key server.key # This file should be kept secret
dh dh1024.pem
server-bridge 172.16.255.1 255.255.255.0 172.16.255.16 172.16.255.31
client-to-client
duplicate-cn
keepalive 10 120
comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 4

設定ファイルで書いたファイル名に合わせてシンボリックリンクを張ります。

[root@Bowmore] # ls -l /etc/openvpn/
total 64
-rw-r--r-- 1 root root  4188  bowmore.crt
-rw------- 1 root root   912  bowmore.key
-rw-r--r-- 1 root root  1440  ca.crt
-rw-r--r-- 1 root root   245  dh1024.pem
-r-xr-xr-x 1 root root   943  down.sh
lrwxrwxrwx 1 root root    11  openvpn.conf -> server.conf
-rw-r--r-- 1 root root 10360  server.conf
lrwxrwxrwx 1 root root    11  server.crt -> bowmore.crt
lrwxrwxrwx 1 root root    11  server.key -> bowmore.key
-r-xr-xr-x 1 root root  2594  up.sh

クライアント側設定ファイルの編集

easy-rsaを実行したホストの/usr/share/openvpn/easy-rsa/keys/から各クライアントの/etc/openvpn/に以下のファイルをコピーします。

  • ca.crt : CAの証明書
  • ${クライアント名}.key : クライアントの秘密鍵
  • ${クライアント名}.crt : クライアントの証明書

OpenVPNクライアントの設定ファイルを/etc/openvpn/client.confという名前作ります。 内容は以下の通りです。

[root@PortEllen] # grep -E '^\s*[^#;]' /etc/openvpn/client.conf
client
dev tap
proto udp
remote bowmore.example.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
ns-cert-type server
comp-lzo
verb 3

設定ファイルで書いたファイル名に合わせてシンボリックリンクを張ります。

[root@PortEllen] # ls -l /etc/openvpn/
total 24
-rw-r--r-- 1 root 4072 Dec 11 06:11 PortEllen.crt
-rw------- 1 root  916 Dec 11 06:11 PortEllen.key
-rw-r--r-- 1 root 1440 Nov 25 20:14 ca.crt
-rw-r--r-- 1 root  415 Dec 11 07:09 client.conf
lrwxrwxrwx 1 root   13 Dec 11 07:16 client.crt -> PortEllen.crt
lrwxrwxrwx 1 root   13 Dec 11 07:16 client.key -> PortEllen.key
-rwxr-xr-x 1 root  943 Dec  4 15:01 down.sh*
lrwxrwxrwx 1 root   11 Dec 11 07:27 openvpn.conf -> client.conf
-rwxr-xr-x 1 root 2594 Dec  4 15:01 up.sh*

ここまででOpenVPN自体のセットアップは完了しているので、Routingモードでの動作確認を行うこともできます。

Ethernet Bridgeのセットアップ

Dummy net driverのカーネルモジュールが足りなかったのでビルドするところからはじめます。 以下のいずれかで出力があれば、すでにDummy net driver supportは有効になっています。改めてカーネルモジュールをビルドする必要はないと思います。

  • lsmod | grep -E '^dummy\s'
  • zcat /proc/config.gz | grep -E '^CONFIG_DUMMY=(y|m)$'

(必要なら)カーネルモジュールのビルド

genkernel–menuconfig付きで実行、またはmake menuconfig等を実行します。

f:id:mazgi:20141210070354p:plain

OSを再起動したくないのでDummy net driver supportをモジュール(CONFIG_DUMMY=m)にします。genkernelを使う場合は/usr/src/linuxが現在起動しているカーネルと同じバージョンを指していることを確認してください。

[root@Bowmore] # uname -a
Linux Bowmore 3.3.8-gentoo #2 SMP Sat Aug 4 09:57:38 JST 2012 x86_64 Intel(R) Xeon(R) CPU E5645 GenuineIntel GNU/Linux
[root@Bowmore] # ls -l /usr/src/linux
lrwxrwxrwx 1 root root 18  /usr/src/linux -> linux-3.3.8-gentoo
[root@Bowmore] # genkernel --menuconfig --no-clean --no-mrproper --lvm all
* Gentoo Linux Genkernel; Version 3.4.24_p2
* Running with options: --menuconfig --no-clean --no-mrproper --lvm all

* Linux Kernel 3.3.8-gentoo for x86_64...
* kernel: --mrproper is disabled; not running 'make mrproper'.
*         >> Running oldconfig...
* kernel: --clean is disabled; not running 'make clean'.
* kernel: >> Invoking menuconfig...
#
# configuration written to .config
#

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

*         >> Compiling 3.3.8-gentoo bzImage...
*         >> Not installing firmware as it's included in the kernel already (CONFIG_FIRMWARE_IN_KERNEL=y)...
*         >> Compiling 3.3.8-gentoo modules...
* Copying config for successful build to /etc/kernels/kernel-config-x86_64-3.3.8-gentoo
* blkid: >> Using cache
* busybox: >> Using cache
* initramfs: >> Initializing...
*         >> Appending base_layout cpio data...
*         >> Appending auxilary cpio data...
*         >> Appending busybox cpio data...
*         >> Appending lvm cpio data...
*           LVM: Adding support (using local static binary /sbin/lvm.static)...
*         >> Appending modules cpio data...
*         >> Appending blkid cpio data...
*
* Kernel compiled successfully!
*
* Required Kernel Parameters:
*     real_root=/dev/$ROOT
*
*     Where $ROOT is the device node for your root partition as the
*     one specified in /etc/fstab
*
* If you require Genkernel's hardware detection features; you MUST
* tell your bootloader to use the provided INITRAMFS file. Otherwise;
* substitute the root argument for the real_root argument if you are
* not planning to use the initramfs...

* WARNING... WARNING... WARNING...
* Additional kernel cmdline arguments that *may* be required to boot properly...
* add "dolvm" for lvm support
* With support for several ext* filesystems around it may be needed to
* add "rootfstype=ext3" or "rootfstype=ext4"

* Do NOT report kernel bugs as genkernel bugs unless your bug
* is about the default genkernel configuration...
*
* Make sure you have the latest ~arch genkernel before reporting bugs.

起動しているカーネルと同じバージョンでモジュールをビルドしたので、OSは再起動せずにmodprobeだけ実行します。 もしDummy net driverがモジュールとしてビルドされていて読み込まれていない場合には同様にmodprobe dummyを実行してください。

[root@Bowmore] # modprobe dummy
[root@Bowmore] # lsmod | grep dummy
dummy                   1946  0

bridge-utilsパッケージのインストール

bridge-utilsがインストールされていなければインストールします。

[root@Bowmore] # emerge -pv bridge-utils

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] net-misc/bridge-utils-1.4  0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

Bridge Interfaceの設定

IP Forwardingが有効になっていることを確認します。

[root@Bowmore] # cat /proc/sys/net/ipv4/ip_forward
1

/etc/conf.d/netdummy0br0インタフェースの設定を追記します。

[root@Bowmore] # grep -E '^\s*[^#;]' /etc/conf.d/net | grep -v 'eth0'
config_dummy0=(null)
tuntap_tap0="tap"
config_tap0=("0.0.0.0 promisc")
bridge_br0="dummy0 tap0"
config_br0=(null)
depend_br0() {
  need net.dummy0 net.tap0
}

起動スクリプトnet.dummy0net.br0を作ります。

[root@Bowmore] # cd /etc/init.d
[root@Bowmore] # ln -s net.lo net.dummy0
[root@Bowmore] # ln -s net.lo net.br0

net.br0をdefaultランレベルに追加します。

[root@Bowmore] # rc-update add net.br0 default
 * service net.br0 added to runlevel default

動作確認

起動確認

net.br0を起動します。

[root@Bowmore] # /etc/init.d/net.br0 start
 * Bringing up interface br0
 *   Creating bridge br0 ...
 *   Adding ports to br0
 *     dummy0 ...                                                         [ ok ]
 *     tap0 ...                                                           [ ok ]
 *   You are using a bash array for config_br0.
 *   This feature will be removed in the future.
 *   Please see net.example for the correct format for config_br0.        [ ok ]

OpenVPNをフォアグラウンドで起動してみます。

[root@Bowmore] # cd /etc/openvpn
[root@Bowmore] # openvpn server.conf
Mon Nov 26 01:21:04 2012 OpenVPN 2.2.2 x86_64-pc-linux-gnu [SSL] [LZO2] [EPOLL] [eurephia] built on Aug 27 2012
Mon Nov 26 01:21:04 2012 NOTE: when bridging your LAN adapter with the TAP adapter, note that the new bridge adapter will often take on its own IP address that is different from what the LAN adapter was previously set to
Mon Nov 26 01:21:04 2012 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Mon Nov 26 01:21:04 2012 TUN/TAP device tap0 opened
Mon Nov 26 01:21:04 2012 UDPv4 link local (bound): [undef]:1194
Mon Nov 26 01:21:04 2012 UDPv4 link remote: [undef]
Mon Nov 26 01:21:04 2012 Initialization Sequence Completed

問題なさそうです。

接続確認

サーバー側の起動は確認できたのでOpenVPNをサービスとして起動しておきます。

[root@Bowmore] # /etc/init.d/openvpn start
 * Starting openvpn ...                                                   [ ok ]

クライアントから接続してみます。

[root@Bowmore] # tailf /var/log/openvpn/openvpn.log
Wed Dec 12 07:02:55 2012 us=331767 MULTI: multi_create_instance called
Wed Dec 12 07:02:55 2012 us=332026 113.xxx.yyy.zzz:51127 Re-using SSL/TLS context
Wed Dec 12 07:02:55 2012 us=332106 113.xxx.yyy.zzz:51127 LZO compression initialized
Wed Dec 12 07:02:55 2012 us=332542 113.xxx.yyy.zzz:51127 Control Channel MTU parms [ L:1574 D:138 EF:38 EB:0 ET:0 EL:0 ]
Wed Dec 12 07:02:55 2012 us=332612 113.xxx.yyy.zzz:51127 Data Channel MTU parms [ L:1574 D:1450 EF:42 EB:135 ET:32 EL:0 AF:3/1 ]
Wed Dec 12 07:02:55 2012 us=332657 113.xxx.yyy.zzz:51127 Local Options String: 'V4,dev-type tap,link-mtu 1574,tun-mtu 1532,proto UDPv4,comp-lzo,cipher BF-CBC,auth SHA1,keysize 128,key-method 2,tls-server'
Wed Dec 12 07:02:55 2012 us=332677 113.xxx.yyy.zzz:51127 Expected Remote Options String: 'V4,dev-type tap,link-mtu 1574,tun-mtu 1532,proto UDPv4,comp-lzo,cipher BF-CBC,auth SHA1,keysize 128,key-method 2,tls-client'
Wed Dec 12 07:02:55 2012 us=332715 113.xxx.yyy.zzz:51127 Local Options hash (VER=V4): 'dcf96af5'
Wed Dec 12 07:02:55 2012 us=332763 113.xxx.yyy.zzz:51127 Expected Remote Options hash (VER=V4): '156e3b19'
Wed Dec 12 07:02:55 2012 us=332865 113.xxx.yyy.zzz:51127 TLS: Initial packet from 113.xxx.yyy.zzz:51127, sid=215ada78 94de0d6d
Wed Dec 12 07:02:55 2012 us=488484 113.xxx.yyy.zzz:51127 VERIFY OK: depth=1, /C=JP/ST=Tokyo/L=Suginami/O=BooMTown/OU=personal/CN=ca.openvpn.example.com/name=Jhon_Doe/emailAddress=openvpn@example.com
Wed Dec 12 07:02:55 2012 us=488729 113.xxx.yyy.zzz:51127 VERIFY OK: depth=0, /C=JP/ST=Tokyo/L=Suginami/O=BooMTown/OU=personal/CN=PortEllen/name=Jhon_Doe/emailAddress=openvpn@example.com
Wed Dec 12 07:02:55 2012 us=543289 113.xxx.yyy.zzz:51127 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Wed Dec 12 07:02:55 2012 us=543381 113.xxx.yyy.zzz:51127 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Dec 12 07:02:55 2012 us=543467 113.xxx.yyy.zzz:51127 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Wed Dec 12 07:02:55 2012 us=543523 113.xxx.yyy.zzz:51127 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Dec 12 07:02:55 2012 us=554146 113.xxx.yyy.zzz:51127 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
Wed Dec 12 07:02:55 2012 us=554254 113.xxx.yyy.zzz:51127 [PortEllen] Peer Connection Initiated with 113.xxx.yyy.zzz:51127
Wed Dec 12 07:02:57 2012 us=840876 PortEllen/113.xxx.yyy.zzz:51127 PUSH: Received control message: 'PUSH_REQUEST'
Wed Dec 12 07:02:57 2012 us=841145 PortEllen/113.xxx.yyy.zzz:51127 SENT CONTROL [PortEllen]: 'PUSH_REPLY,route-gateway 172.16.255.1,ping 10,ping-restart 120,ifconfig 172.16.255.18 255.255.255.0' (status=1)
Wed Dec 12 07:02:57 2012 us=870797 PortEllen/113.xxx.yyy.zzz:51127 MULTI: Learn: 66:de:0c:66:9d:56 -> PortEllen/113.xxx.yyy.zzz:51127
[root@PortEllen] # cd /etc/openvpn
[root@PortEllen] # openvpn client.conf
Wed Dec 12 07:02:33 2012 OpenVPN 2.2.2 x86_64-pc-linux-gnu [SSL] [LZO2] [EPOLL] [eurephia] built on Dec  4 2012
Wed Dec 12 07:02:33 2012 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Wed Dec 12 07:02:33 2012 LZO compression initialized
Wed Dec 12 07:02:33 2012 Control Channel MTU parms [ L:1574 D:138 EF:38 EB:0 ET:0 EL:0 ]
Wed Dec 12 07:02:33 2012 Socket Buffers: R=[212992->131072] S=[212992->131072]
Wed Dec 12 07:02:33 2012 Data Channel MTU parms [ L:1574 D:1450 EF:42 EB:135 ET:32 EL:0 AF:3/1 ]
Wed Dec 12 07:02:33 2012 Local Options hash (VER=V4): '156e3b19'
Wed Dec 12 07:02:33 2012 Expected Remote Options hash (VER=V4): 'dcf96af5'
Wed Dec 12 07:02:33 2012 UDPv4 link local: [undef]
Wed Dec 12 07:02:33 2012 UDPv4 link remote: 49.aaa.bbb.ccc:1194
Wed Dec 12 07:02:33 2012 TLS: Initial packet from 49.aaa.bbb.ccc:1194, sid=f493363c d005952c
Wed Dec 12 07:02:33 2012 VERIFY OK: depth=1, /C=JP/ST=Tokyo/L=Suginami/O=BooMTown/OU=personal/CN=ca.openvpn.example.com/name=Jhon_Doe/emailAddress=openvpn@example.com
Wed Dec 12 07:02:33 2012 VERIFY OK: nsCertType=SERVER
Wed Dec 12 07:02:33 2012 VERIFY OK: depth=0, /C=JP/ST=Tokyo/L=Suginami/O=BooMTown/OU=personal/CN=bowmore/name=Jhon_Doe/emailAddress=openvpn@example.com
Wed Dec 12 07:02:34 2012 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Wed Dec 12 07:02:34 2012 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Dec 12 07:02:34 2012 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Wed Dec 12 07:02:34 2012 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Dec 12 07:02:34 2012 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
Wed Dec 12 07:02:34 2012 [bowmore] Peer Connection Initiated with 49.aaa.bbb.ccc:1194
Wed Dec 12 07:02:36 2012 SENT CONTROL [bowmore]: 'PUSH_REQUEST' (status=1)
Wed Dec 12 07:02:36 2012 PUSH: Received control message: 'PUSH_REPLY,route-gateway 172.16.255.1,ping 10,ping-restart 120,ifconfig 172.16.255.18 255.255.255.0'
Wed Dec 12 07:02:36 2012 OPTIONS IMPORT: timers and/or timeouts modified
Wed Dec 12 07:02:36 2012 OPTIONS IMPORT: --ifconfig/up options modified
Wed Dec 12 07:02:36 2012 OPTIONS IMPORT: route-related options modified
Wed Dec 12 07:02:36 2012 TUN/TAP device tap0 opened
Wed Dec 12 07:02:36 2012 TUN/TAP TX queue length set to 100
Wed Dec 12 07:02:36 2012 /bin/ifconfig tap0 172.16.255.18 netmask 255.255.255.0 mtu 1500 broadcast 172.16.255.255
Wed Dec 12 07:02:36 2012 Initialization Sequence Completed
^CWed Dec 12 07:02:38 2012 event_wait : Interrupted system call (code=4)
Wed Dec 12 07:02:38 2012 TCP/UDP: Closing socket
Wed Dec 12 07:02:38 2012 Closing TUN/TAP interface
Wed Dec 12 07:02:38 2012 /bin/ifconfig tap0 0.0.0.0
Wed Dec 12 07:02:38 2012 SIGINT[hard,] received, process exiting

MacBook Air(Caolila)にもHomebrewでOpenVPNを入れてつないでみます。 回線はau iPhoneのテザリングです。

f:id:mazgi:20141210070453j:plain

無事接続できました!

Fluentd meetup #3 LT資料

最近ずーっと仕事で使わせていただいていて個人的になじみ深いOSSとなったFluentdですが、先日IIJ様でFluentd meetup #3が開催されましたので行ってきました。

今回のイベントではLTをさせていただきましたので資料を公開します。

LT資料

補足

現状はあくまで独自に拙訳しただけですので、引き続きFluentd Projectの日本語版作成に関するissueでより良い翻訳・公開の方法を相談させていただきたいと考えています。

資料にも記載していますが…

また、誤訳や日本語の言い回しで気になる部分がありましたらGitHubのissueなどでお知らせいただけるとうれしいです。

f:id:mazgi:20121111125745j:plain

主催者の皆様、すばらしい会場と機材を提供してくださったIIJ様、参加者の皆様、 ありがとうございました!